-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Profile] az login: Add --certificate for authenticating with service principal certificate
#30091
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
Conversation
️✔️AzureCLI-FullTest
|
|
| rule | cmd_name | rule_message | suggest_message |
|---|---|---|---|
| login | cmd login added parameter certificate |
|
az login refinement |
| # Service principal | ||
| c.argument('service_principal', action='store_true', | ||
| help='Log in with a service principal.') | ||
| c.argument('certificate', help='A PEM file with key and public certificate.') |
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.
I am hesitating on whether --certificate should have an alias -c. Using full name is definitely preferred.
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.
We can add a parameter in the future, let's keep --certificate for now.
| PASSWORD_CERTIFICATE_WARNING = ( | ||
| "Using --password to pass service principal certificate is deprecated and will be removed in a " | ||
| "future release. Use --certificate instead.") |
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.
Please kindly rephase the warning message. @dcaro @dbradish-microsoft
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.
| PASSWORD_CERTIFICATE_WARNING = ( | |
| "Using --password to pass service principal certificate is deprecated and will be removed in a " | |
| "future release. Use --certificate instead.") | |
| PASSWORD_CERTIFICATE_WARNING = ( | |
| "Passing the service principal certificate with `--password` is deprecated and will be removed in a future release. Please use `--certificate` instead.") |
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.
Updated. Shall we be explicit on "a future release"?
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.
Since the next breaking change release is very close, shall we give customers more time to see this warning message?
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.
Yes, let's give sufficient time for customers to notice the warning message
dcaro
left a comment
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.
See my suggestion
| # Service principal | ||
| c.argument('service_principal', action='store_true', | ||
| help='Log in with a service principal.') | ||
| c.argument('certificate', help='A PEM file with key and public certificate.') |
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.
We can add a parameter in the future, let's keep --certificate for now.
| PASSWORD_CERTIFICATE_WARNING = ( | ||
| "Using --password to pass service principal certificate is deprecated and will be removed in a " | ||
| "future release. Use --certificate instead.") |
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.
| PASSWORD_CERTIFICATE_WARNING = ( | |
| "Using --password to pass service principal certificate is deprecated and will be removed in a " | |
| "future release. Use --certificate instead.") | |
| PASSWORD_CERTIFICATE_WARNING = ( | |
| "Passing the service principal certificate with `--password` is deprecated and will be removed in a future release. Please use `--certificate` instead.") |
|
|
||
| if username: | ||
| if not (password or client_assertion): | ||
| if not (password or client_assertion or certificate): |
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.
Shall we also add certificate check in
azure-cli/src/azure-cli/azure/cli/command_modules/profile/custom.py
Lines 123 to 126 in 6c32c4d
| if any([password, service_principal, tenant]) and identity: | |
| raise CLIError("usage error: '--identity' is not applicable with other arguments") | |
| if any([password, service_principal, username, identity]) and use_device_code: | |
| raise CLIError("usage error: '--use-device-code' is not applicable with other arguments") |
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.
No, as missing all 3 types of credentials will result in prompting for secrets.
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.
I mean, if user pass in --certificate together with --identity/--use-device-code, we should raise error as well, right?
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.
--certificate will be discarded in that case. As you can see, client_assertion is not checked either. We can do that in a separate PR.
|
|
||
| if service_principal: | ||
| from azure.cli.core.auth.identity import ServicePrincipalAuth | ||
| password = ServicePrincipalAuth.build_credential(password, client_assertion, use_cert_sn_issuer) |
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.
Passing keyword arguments as positional arguments is fragile and may break unexpectedly.
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.
Agree, I am not a big fan of positional arguments in general.
That should be also updates for this |
Related command
az loginDescription
Fix #28839
Require #30090
--certificatefor authenticating with service principal certificate--passwordto pass service principal certificateTesting Guide
History Notes
[Profile]
az login: Passing the service principal certificate with--passwordis deprecated and will be removed in version 2.67.0. Please use--certificateinstead.