-
Notifications
You must be signed in to change notification settings - Fork 498
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
Private Preview AAD: Adds AAD support to the SDK #1798
Conversation
Send AAD token in authorization header. Add a constructor of CosmosClient that takes TokenCredential as an input. Token will be obtained from TokenCredential, cached, and efficiently refreshed in CosmosClient. Update versions of some DLLs (e.g. System.Threading.Tasks.Extensions) as required by [Azure.Core](https://www.nuget.org/packages/Azure.Core/) dependencies. Tests of this change are in !337606 (See /Product/SDK/.net/Microsoft.Azure.Cosmos.Friends/tests/TokenCredentialCacheTests.cs and /Product/Tests/CosmosFabricTest/TestClass/AzureActiveDirectoryTests/AadLegacyGatewayTests.cs) ## Type of change - [ ] New feature (non-breaking change which adds functionality) ## Assignee junyguo
2. Switched from a token refresh that only occurred when it was expiring to a background task that continuously updates the token. This increases availability because the last 5 minutes there might a service outage and the token won't get refreshed in time.
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 follow the required format: "[Internal] Category: (Adds|Fixes|Refactors) Description"
Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.
...zure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Utils/LocalEmulatorTokenCredential.cs
Show resolved
Hide resolved
…azure-cosmos-dotnet-v3 into users/jawilley/aad/AddAAD
Microsoft.Azure.Cosmos/src/Authorization/TokenCredentialCache.cs
Outdated
Show resolved
Hide resolved
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.
LGTM
Microsoft.Azure.Cosmos/src/Authorization/AuthorizationTokenProviderTokenCredential.cs
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Authorization/TokenCredentialCache.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Authorization/TokenCredentialCache.cs
Outdated
Show resolved
Hide resolved
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.
LGTM
Closing due to in-activity, pease feel free to re-open. |
Pull Request Template
Description
Adds a constructor to take a TokenCredential
Adds a new TokenCredentialCache which store the AAD token while it is valid, and has a background task to refresh the token roughly 25% of the token lifespan.
AuthorizationTokenProvider is created as a base contract for all the authorization interfaces. Each authorization type now has it's own implementation. This avoids runtime exceptions and all the if else logic that is copy pasted everywhere.
Type of change
Please delete options that are not relevant.
Closing issues
To automatically close an issue: closes #IssueNumber