-
Notifications
You must be signed in to change notification settings - Fork 3k
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
{Core} Only pass data
to MSAL as kwargs
#30062
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
Core |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
|
||
scopes = _normalize_scopes(scopes) | ||
token, _ = self._get_token(scopes, **kwargs) | ||
token, _ = self._get_token(scopes, **filtered_kwargs) |
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.
As of this PR, it looks like we don't need that filtered_kwargs
at all.
token, _ = self._get_token(scopes, **filtered_kwargs) | |
token, _ = self._get_token(scopes, data=kwargs.get("data")) |
Open question:
Currently there are multiple get_token(..., **kwargs)
function scattering here and there. If/since we say - via this PR - that only data
is an expected input parameter, why don't we take one step further and refactor those functions to get_token(..., data=None)
?
Even if we somehow still want to accept and then ignore arbitrary parameters, a more readable pattern is def get_token(..., data=None, **ignored)
and then we do NOT relay the ignored
into underlying functions.
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.
The reason why I don't use data=kwargs.get("data")
is because this will cause data
always to be passed, even as None
. I want to make sure data
is passed only when the caller of get_token
passes data
.
As for not making data
a public argument, this is because Azure CLI Core is also used by other people or projects, I don't want to make data
a public argument before MSAL does the same (AzureAD/microsoft-authentication-library-for-python#755).
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.
The reason why I don't use
data=kwargs.get("data")
is because this will causedata
always to be passed, even asNone
. I want to make suredata
is passed only when the caller ofget_token
passesdata
.
Fair enough. In that case, I would suggest you put that reasoning as a comment at the line of filtered_kwargs
, to prevent a future maintainer refactoring it to the simpler way.
As for not making
data
a public argument, this is because Azure CLI Core is also used by other people or projects, I don't want to makedata
a public argument before MSAL does the same (AzureAD/microsoft-authentication-library-for-python#755).
Good point. This PR is ready to go as-is, without AzureAD/microsoft-authentication-library-for-python#755 (If we are really going to expose that in MSAL, we will revisit its naming.)
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 would suggest you put that reasoning as a comment at the line of
filtered_kwargs
, to prevent a future maintainer refactoring it to the simpler way.
I am the only one maintaining this part. Let's keep it as is, as I will change it soon.
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.
One silly question, are tenant_id
and data
the only known kwargs
that might be passed to get_token
currently?
def get_token(self, *scopes, **kwargs)
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 only support scopes
and data
, but not tenant_id
, enable_cae
. That's why anything else in kwargs
is discarded.
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.
Approved with suggested changes.
Description
Azure CLI currently passes
kwargs
received byget_token()
directly to MSAL. Since SDK is adding more keyword arguments, such asenable_cae
(Azure/azure-sdk-for-python#37358), this will cause failure asenable_cae
is not recognized by MSAL.This PR changes the behavior so that only
data
is passed to MSAL askwargs
.Also see AzureAD/microsoft-authentication-library-for-python#755
Testing Guide
az extension add --name ssh
az ssh vm -n xxx -g xxx