-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Core] Allow authentication via environment variables #27938
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
base: dev
Are you sure you want to change the base?
Changes from 2 commits
1022c16
8540590
706e1dc
1bf27e3
038dc23
f54f699
29aa9fa
817982f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -307,7 +307,14 @@ def __init__(self, secret_store): | |
| self._entries = [] | ||
|
|
||
| def load_entry(self, sp_id, tenant): | ||
| from azure.cli.core._profile import env_var_auth_configured, load_env_var_credential | ||
| self._load_persistence() | ||
|
|
||
| # If no login data, look for service principal credential in environment variables | ||
| if not self._entries and env_var_auth_configured(): | ||
| logger.warning("Using service principal credential configured in environment variables.") | ||
| self._entries = [load_env_var_credential()] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| matched = [x for x in self._entries if sp_id == x[_CLIENT_ID]] | ||
| if not matched: | ||
| raise CLIError("Could not retrieve credential from local cache for service principal {}. " | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1353,3 +1353,17 @@ def should_encrypt_token_cache(cli_ctx): | |||||||||||||||
| encrypt = cli_ctx.config.getboolean('core', 'encrypt_token_cache', fallback=fallback) | ||||||||||||||||
|
|
||||||||||||||||
| return encrypt | ||||||||||||||||
|
|
||||||||||||||||
| def is_guid(guid): | ||||||||||||||||
| import uuid | ||||||||||||||||
| try: | ||||||||||||||||
| uuid.UUID(guid) | ||||||||||||||||
| return True | ||||||||||||||||
| except (ValueError, TypeError): | ||||||||||||||||
| return False | ||||||||||||||||
|
||||||||||||||||
| def is_guid(guid): | |
| import uuid | |
| try: | |
| uuid.UUID(guid) | |
| return True | |
| except ValueError: | |
| return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unconditionally showing warnings can breaks pipelines which enables
failOnStderr(#18372).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not sure what you mean. How should I make this warning shown "conditionally"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well. This warning shouldn't be printed at all, as it doesn't really qualify as a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. It's been changed to a
logger.debugcall.