-
Notifications
You must be signed in to change notification settings - Fork 58
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
CAE support #966
CAE support #966
Changes from 4 commits
3f72e81
82c9dbc
a6fa001
71038ec
17b7d50
21904a0
30f917b
f7e7407
8bbbf97
5d2821e
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 |
---|---|---|
|
@@ -18,7 +18,10 @@ def config_imports(code_model, global_parameters: ParameterList, async_mode: boo | |
for gp in global_parameters: | ||
file_import.merge(gp.imports()) | ||
if code_model.options["azure_arm"]: | ||
file_import.add_from_import("azure.mgmt.core.policies", "ARMHttpLoggingPolicy", ImportType.AZURECORE) | ||
async_policy = "ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy" | ||
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. One thing to note is that the base 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. sure. 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. sounds good, it's also possible to update in this PR if you want to keep everything in one PR |
||
policy = "ARMHttpLoggingPolicy, ARMChallengeAuthenticationPolicy" | ||
file_import.add_from_import("azure.mgmt.core.policies", async_policy if async_mode else policy, | ||
ImportType.AZURECORE) | ||
return file_import | ||
|
||
|
||
|
@@ -53,7 +56,7 @@ def _service_client_imports() -> FileImport: | |
|
||
if ( | ||
self.code_model.options['credential'] and | ||
self.code_model.options['credential_default_policy_type'] == "BearerTokenCredentialPolicy" | ||
self.code_model.options['credential_default_policy_type'] == "ARMChallengeAuthenticationPolicy" | ||
): | ||
self._correct_credential_parameter() | ||
|
||
|
@@ -75,7 +78,7 @@ def serialize_config_file(self) -> str: | |
|
||
if ( | ||
self.code_model.options['credential'] and | ||
self.code_model.options['credential_default_policy_type'] == "BearerTokenCredentialPolicy" | ||
self.code_model.options['credential_default_policy_type'] == "ARMChallengeAuthenticationPolicy" | ||
): | ||
self._correct_credential_parameter() | ||
|
||
|
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.
hey @msyyc, since we're trying to not make breaking changes, this change would be breaking for anyone who explictly passes in
BearerTokenCredentialPolicy
.I realize mgmt plane wants to switch completely over to
ARMChallengeAuthenticationPolicy
, and since we check the authentication policy also in the templates, one idea is to have a@property
on theCodeModel
, i.e.challenge_auth_policy
This getter would replace every single `ARMChallengeAuthenticationPolicy that you currently have, and should have the following behavior
--credential-default-policy-type=BearerTokenCredentialPolicy
, it returnsBearerTokenCredentialPolicy
code_model.options['azure_arm'] == True
, returnARMChallengeAuthenticationPolicy
.BearerTokenCredentialPolicy
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.
Hi @iscai-msft Thank you for the detailed advice.
(1) I add
ARMChallengeAuthenticationPolicy
as one of allowed policy type instead of deletingBearerTokenCredentialPolicy
with your advice .(2) By comparing
ARMChallengeAuthenticationPolicy
withBearerTokenCredentialPolicy
(https://github.com/Azure/azure-sdk-for-python/blob/16f66ce00af0435b05bd7b88e045ba8ff42736ed/sdk/core/azure-mgmt-core/azure/mgmt/core/policies/_authentication.py#L36), we could find that the only difference is theon_challenge
and it will also return 'false' if service does not support CAE.In one word, for users who don't input policy,
ARMChallengeAuthenticationPolicy
almost has same behavior withBearerTokenCredentialPolicy
. So to simplify code, how about change the default policy directly?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.
Yeah, but
ARMChallengeAuthenticationPolicy
is arm specific, and it's inazure-mgmt-core
. So it makes sense to switch the default auth policy in the case of mgmt plane toARMChallengeAuthenticationPolicy
. However, for data-plane, we don't have users installazure-mgmt-core
at all, so this is breaking for data-plane SDKsThere 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.
Got it. For mgmt-plan, the default policy could become
ARMChallengeAuthenticationPolicy
; for data-plan, the dafault policy keeps same with before. How about this commit : 5d2821e