-
Notifications
You must be signed in to change notification settings - Fork 58
CM-55782: Add OIDC authentication #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ef69a11
CM-55782: Add OIDC authentication
mikita-okuneu 71f5eec
CM-55782: Fixed comments
mikita-okuneu 432bf66
CM-55782: Update README
mikita-okuneu cecfdb9
CM-55782: Fix formatting
mikita-okuneu a5eba08
CM-55782: Fix formatting
mikita-okuneu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,51 @@ | ||
| from typing import Optional | ||
|
|
||
| from cycode.cyclient.config import dev_mode | ||
| from cycode.cyclient.config_dev import DEV_CYCODE_API_URL | ||
| from cycode.cyclient.cycode_dev_based_client import CycodeDevBasedClient | ||
| from cycode.cyclient.cycode_oidc_based_client import CycodeOidcBasedClient | ||
| from cycode.cyclient.cycode_token_based_client import CycodeTokenBasedClient | ||
| from cycode.cyclient.import_sbom_client import ImportSbomClient | ||
| from cycode.cyclient.report_client import ReportClient | ||
| from cycode.cyclient.scan_client import ScanClient | ||
| from cycode.cyclient.scan_config_base import DefaultScanConfig, DevScanConfig | ||
|
|
||
|
|
||
| def create_scan_client(client_id: str, client_secret: str, hide_response_log: bool) -> ScanClient: | ||
| def create_scan_client( | ||
| client_id: str, client_secret: Optional[str] = None, hide_response_log: bool = False, id_token: Optional[str] = None | ||
| ) -> ScanClient: | ||
| if dev_mode: | ||
| client = CycodeDevBasedClient(DEV_CYCODE_API_URL) | ||
| scan_config = DevScanConfig() | ||
| else: | ||
| client = CycodeTokenBasedClient(client_id, client_secret) | ||
| if id_token: | ||
| client = CycodeOidcBasedClient(client_id, id_token) | ||
| else: | ||
| client = CycodeTokenBasedClient(client_id, client_secret) | ||
| scan_config = DefaultScanConfig() | ||
|
|
||
| return ScanClient(client, scan_config, hide_response_log) | ||
|
|
||
|
|
||
| def create_report_client(client_id: str, client_secret: str, _: bool) -> ReportClient: | ||
| client = CycodeDevBasedClient(DEV_CYCODE_API_URL) if dev_mode else CycodeTokenBasedClient(client_id, client_secret) | ||
| def create_report_client( | ||
| client_id: str, client_secret: Optional[str] = None, _: bool = False, id_token: Optional[str] = None | ||
| ) -> ReportClient: | ||
| if dev_mode: | ||
| client = CycodeDevBasedClient(DEV_CYCODE_API_URL) | ||
| elif id_token: | ||
| client = CycodeOidcBasedClient(client_id, id_token) | ||
| else: | ||
| client = CycodeTokenBasedClient(client_id, client_secret) | ||
| return ReportClient(client) | ||
|
|
||
|
|
||
| def create_import_sbom_client(client_id: str, client_secret: str, _: bool) -> ImportSbomClient: | ||
| client = CycodeDevBasedClient(DEV_CYCODE_API_URL) if dev_mode else CycodeTokenBasedClient(client_id, client_secret) | ||
| def create_import_sbom_client( | ||
| client_id: str, client_secret: Optional[str] = None, _: bool = False, id_token: Optional[str] = None | ||
| ) -> ImportSbomClient: | ||
| if dev_mode: | ||
| client = CycodeDevBasedClient(DEV_CYCODE_API_URL) | ||
| elif id_token: | ||
| client = CycodeOidcBasedClient(client_id, id_token) | ||
| else: | ||
| client = CycodeTokenBasedClient(client_id, client_secret) | ||
| return ImportSbomClient(client) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.