-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[Preview] MSAL and shared token cache support #9982
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
…emove this dependency)
tools/RepoTasks/RepoTasks.RemoteWorker/RepoTasks.RemoteWorker.csproj
Outdated
Show resolved
Hide resolved
src/Accounts/Authentication/Authentication/DelegatingAuthenticator.cs
Outdated
Show resolved
Hide resolved
| public ManagedServiceIdentityParameters( | ||
| IAzureEnvironment environment, | ||
| IAzureTokenCache tokenCache, | ||
| string tenantId, |
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.
Seems like this should contain parameters to contain identity type (SystemAssigned, ClientOrObjectId, ResourceId and identity id (string). These are all properties of IAzureAccount, but seems like we could use them to populate the account here.
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.
Also, MSISecret, and MSiEndpoint
|
|
||
| if (account.IsPropertySet(AppServiceManagedIdentityFlag)) | ||
| { | ||
| return new ManagedServiceAppServiceAccessToken(account, environment, GetFunctionsResourceId(resourceId, environment), tenant); |
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.
Would it be cleaner to have one authenticator for AppServiceMSI first in the chain, and the authenticator for Compute MSI after?
src/Accounts/Authentication/Authentication/Clients/AuthenticationClientFactory.cs
Show resolved
Hide resolved
| public const string AppServiceManagedIdentityFlag = "AppServiceManagedIdentityFlag"; | ||
|
|
||
| public const string CommonAdTenant = "Common", | ||
| public const string CommonAdTenant = "organizations", |
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.
Seems like we should have this constant in one place, and use it evwerywhere. Also, same question as before about whether thsi works with MSA
| } | ||
|
|
||
| DefaultContextKey = profile.DefaultContextKey ?? "Default"; | ||
| DefaultContextKey = profile.DefaultContextKey ?? (profile.Contexts.Any() ? null : "Default"); |
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.
Setting the defautl key to null if there are contexts but none selected - when would this occur?
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.
Needs validate: If logged in in VS (not PS), when first time runing PS command (not select-context), should be prompted with "please select a context"
| var accounts = authenticationClientFactory.ListAccounts(); | ||
| if (!accounts.Any()) | ||
| { | ||
| if (!Contexts.Any(c => c.Key != "Default" && c.Value.Account.Type == AzureAccount.AccountType.User)) |
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 think this method could use a bit of breaking up.
RemoveUserContexts()
RemoveUnmatchedUserContexts()
etc.
Also, as stated above, we need soem tracing here so we can tell why a context was removed if soemthign goes wrong.
src/Accounts/Authentication/Authentication/Clients/AuthenticationClientFactory.cs
Show resolved
Hide resolved
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
| return authenticator as IAuthenticatorBuilder; | ||
| }); | ||
| AppendAuthenticator(() => { return new InteractiveUserAuthenticator(); }); | ||
| var defaultBuilder = new DefaultAuthenticatorBuilder(); |
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.
Wouldn't that be 2 InteractiveUserAuthenticators 🤔 ?
to support IAzureMsalTokenCache
6c69f84 to
b941dca
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
44f6f2a to
fbcc1dc
Compare
a640cbf to
9c9c7c8
Compare
Description
Checklist
CONTRIBUTING.mdChangeLog.mdfile(s) has been updated:ChangeLog.mdfile can be found atsrc/{{SERVICE}}/{{SERVICE}}/ChangeLog.md## Upcoming Releaseheader -- no new version header should be added