-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[ACS][Common] OPS - Dual Persona #46383
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
Merged
AikoBB
merged 253 commits into
Azure:feature/communication/entra-identity
from
AikoBB:feature/aigerimb/ops_dual_personas
Oct 25, 2024
Merged
Changes from 29 commits
Commits
Show all changes
253 commits
Select commit
Hold shift + click to select a range
ee7faad
Merge remote-tracking branch 'upstream/main'
38a4d97
Merge remote-tracking branch 'upstream/main'
37cc2ca
Merge remote-tracking branch 'upstream/main'
3a86a55
Merge remote-tracking branch 'upstream/main'
d629199
Merge remote-tracking branch 'upstream/main'
ecb5346
Merge remote-tracking branch 'upstream/main'
f725f38
Merge remote-tracking branch 'upstream/main'
60eab70
Merge remote-tracking branch 'upstream/main'
5f11aab
Merge remote-tracking branch 'upstream/main'
8fa0742
Merge remote-tracking branch 'upstream/main'
e8c72f2
Add Entra token credentials
657b1c7
fixed api comments & regenerated api
AikoBB 57db1d3
added implementation
AikoBB 941b315
Merge branch 'main' into feature/aigerimb/ops_dual_personas
AikoBB 2a3d6b3
fixed exchange implementation
AikoBB df1b9c2
fixed docs
AikoBB 176c024
fixed docs
AikoBB 67dfd71
added token cache and covered with tests
AikoBB dd98d15
added read-me
AikoBB 8e1b595
[Storage] [DataMovement] [API-Change] Changed ShareFilesStorageResour…
nickliu-msft 65846ee
Update Nginx changelog to support API version 2024-06-01-preview (#46…
SpencerOfwiti 7f20f77
[Service Bus] October 2024 Release Prep (#46438)
jsquire 7275c78
Storage STG 96 (#45604)
seanmcc-msft a70001f
Fix missing HybridSearch in copy method of SearchOptions (#46425)
nielsheeren f97a346
changed scopes to opt.param
AikoBB e6fd97a
Update AutoRest C# version to 3.0.0-beta.20241007.1 (#46457)
azure-sdk 2e0cdce
fixed generated api
AikoBB 0598a8e
Onboard Azure.Developer.MicrosoftPlaywrightTesting sdk (#45044)
Sid200026 984ecd1
STG 96 beta changelogs (#46451)
seanmcc-msft e1469a2
Azure.Monitor.Query: invalid date string format in MetricsClient (#45…
wps0 bdef6a6
Persist oidc env vars in deploy template (#46477)
azure-sdk f892913
Increment version for storage releases (#46479)
azure-sdk ee9547d
Increment package version after release of Azure.Messaging.ServiceBus…
azure-sdk 7c8f16d
[Event Hubs] Convert tests to use identity auth (#46330)
jsquire 31c0f37
[EngSys] Update central Service Bus version (#46483)
jsquire 6b8988c
Use equality function check for persist oidc token step (#46485)
azure-sdk 3f46696
Sync eng/common directory with azure-sdk-tools for PR 9106 (#46482)
azure-sdk 6220065
addressed comments
AikoBB 4fcbc80
addressed the latest comments
AikoBB d891541
Update version of System.Text.Json (#46508)
m-redding a2665e9
Update Maps codeowners (#46494)
dubiety cc82fce
[Storage][DataMovement] Fix perf test cleanup + other minor fixes (#4…
jalauzon-msft dc0f1c6
TransferManager tests (#46449)
jaschrep-msft a59a648
Prep for release (#46512)
m-redding b3ee3eb
Remove heaths as codeowner and add myself (#46488)
JonathanCrd 37d33af
Only treat critical vulnerabilities as errors (#46515)
weshaggard 15bd590
[Storage] [DataMovement] Moved all blob related tests out of DataMove…
nickliu-msft 262f229
Enable-WriteCore-feature-for-networkcloud (#46469)
welovej 4e1a9aa
Update AutoRest C# version to 3.0.0-beta.20241009.1 (#46507)
azure-sdk 6b1dccb
2024-05 Fleet .NET sdk generation (#46353)
frantran 1b4c390
Support handling function return value from worker process (#46158)
Y-Sindo 4a2b1bd
fix(digitaltwins): bump System.Text.Json to 6.0.10 (#46523)
archerzz 4cdb45f
add release date to Fleet .NET SDK latest version (#46524)
frantran bacd676
Update AutoRest C# version to 3.0.0-beta.20241009.4 (#46526)
azure-sdk a08bddf
Increment version for core releases (#46517)
azure-sdk 7178070
added pre-warm logic
AikoBB abd5a14
Update Packages.Data.props (#46534)
m-redding 991f2e6
[Storage] Prepare for Storage Base Packages Preview Patch Release and…
amnguye bb158f4
[Key Vault] Add CAE support & update System.ClientModel dependency ve…
JonathanCrd 7f91404
Update AutoRest C# version to 3.0.0-beta.20241010.1 (#46561)
azure-sdk 81ad181
Increment version for signalr releases (#46562)
azure-sdk 38b8bd1
Enable WriteCore feature for storagecache (#46502)
melina5656 dfa313b
Enable WriteCore feature for healthcareapis (#46491)
melina5656 289b076
Enable-WriteCore-feature-for-servicelinker (#46520)
welovej ae887ea
Enable WriteCore feature for trafficmanager (#46497)
melina5656 2769d86
Enable WriteCore feature for storage (#46501)
melina5656 e84f5af
Enable-WriteCore-feature-for-servicefabricmanagedclusters (#46518)
welovej ccc4b02
Enable-WriteCore-feature-for-servicebus (#46505)
welovej 94384c7
Enable-WriteCore-feature-for-securityinsights (#46504)
welovej e32939a
Enable-WriteCore-feature-for-purview (#46498)
welovej e08ef6a
Enable-WriteCore-feature-for-securitycenter (#46503)
welovej 1f01865
Enable-WriteCore-feature-for-privatedns (#46496)
welovej 6eb2ca1
Enable write core feature for peering (#46493)
welovej 8138c50
Enable-WriteCore-feature-for-orbital (#46492)
welovej 386e4ed
Enable-WriteCore-feature-for-sphere (#46268)
welovej e1b37dd
Enable-WriteCore-feature-for-recoveryservices-backup (#46243)
welovej 420b3e4
Enable-WriteCore-feature-for-hdinsightcontainers (#46463)
welovej de9e665
Enable-WriteCore-feature-for-mysql (#46466)
welovej 96c97ad
Enable-WriteCore-feature-for-eventgrid (#46461)
welovej acdb8a0
Enable-WriteCore-feature-for-labservices (#46464)
welovej 2dffe0b
Enable-WriteCore-feature-for-network (#46467)
welovej 6af3487
Enable-WriteCore-feature-for-resourcemover (#46499)
welovej a6d178f
Enable-WriteCore-feature-for-devtestlabs (#46455)
welovej 893b607
Enable-WriteCore-feature-for-edgeorder (#46459)
welovej 57844b8
Enable-WriteCore-feature-for-springappdiscovery (#46521)
welovej d6b5287
add entra token cashing logic
AikoBB 3142625
Update CODEOWNERS for SignalR(#46458)
Y-Sindo 86b7e38
Initial commit (#46535)
nickliu-msft c04f11e
[Event Hubs] Resilient management link creation (#46544)
jsquire 6a35bdf
Add generation of 2023-07-01-preview and new tests for dns resolver d…
jamesvoongms 5ae1c69
[CODEOWNERS] Adjust baseline errors (#46567)
jsquire 7ba92a4
[AzureMonitorDistro] Fix livemetrics reporting incorrect values (#46429)
611f1d2
Increment version for storage releases (#46542)
azure-sdk c47c872
[AzureMonitorExporter] prep release 1.4.0 beta2 (#45906)
faccbb8
Increment version for storage releases (#46543)
azure-sdk 0103d7a
Azure.Provisioning: Update Redis to provide IsAccessKeyAuthentication…
tg-msft bc34307
Sync eng/common directory with azure-sdk-tools for PR 9102 (#46546)
azure-sdk 584f9c0
Increment package version after release of Azure.Monitor.OpenTelemetr…
azure-sdk 177f044
[AzureMonitorDistro] prep release 1.3.0 beta2 (#46572)
24d493b
Enable-WriteCore-feature-for-fleet (#46462)
welovej e79e2b0
Enable-WriteCore-feature-for-newrelicobservability (#46490)
welovej afc0efd
Prepare for release (#46576)
JoshLove-msft d018fa4
Update CODEOWNERS (#46575)
rahuls-microsoft 3d93132
Enable WriteCore feature for websubsub and release a new version (#46…
melina5656 a0d8034
Enable-WriteCore-feature-for-websites and release a new version (#46305)
welovej 6bc7e54
Bump version of MGC (#46565)
live1206 6eb56b7
update ContainerServiceFleet variables for more clear naming (#46582)
frantran f38dc95
Enable-WriteCore-feature-for-operationalinsights (#46225)
welovej ed6ed2b
Enable WriteCore feature for containerservice (#46355)
melina5656 d851a07
Enable-WriteCore-feature-for-recoveryservices (#46242)
welovej fb0b80d
Update commit to fix tsp compile (#46587)
live1206 2d1b484
Increment package version after release of Azure.ResourceManager.WebP…
azure-sdk fb9fb16
Increment package version after release of Azure.Messaging.EventGrid …
azure-sdk 1486aab
Storage json hotfix (#46591)
seanmcc-msft 98bcb1c
Increment package version after release of Azure.ResourceManager.AppS…
azure-sdk dcfb2ef
fix(playwighttesting): Removed cancellationToken from SetupAsync meth…
kashish2508 8a252ab
Update test-resources.bicep (#46573)
nisha-bhatia fabfa6c
Added the ability to provision AOAI as an optional component (#46570)
KrzysztofCwalina eee60a1
DM Lib beta release (#46596)
seanmcc-msft e499bcc
[EngSys] Bump package versions (#46595)
jsquire bb73175
Prepare for October GA release (#46600)
christothes 59c2c7a
Fixed DM Lib Shares dependency (#46603)
seanmcc-msft d5abc28
fix package dependency (#46609)
2cbb460
[Key Vault] Prepare release for CAE feature (#46599)
JonathanCrd 48f989c
[DocumentIntelligence] Default authentication to Token Credential (#4…
kinelski f754c0b
Increment version for storage releases (#46610)
azure-sdk 1c9d5fe
Switch to TME test subscription (#46452)
weshaggard eaacc34
[.ContainerServiceFleet] Remove the ignore attribute and fix recordin…
melina5656 f093f78
remove ignore attribute and fix the recording file when Servicelin…
welovej b6a1b77
Enable WriteCore feature for eventhub (#46169)
melina5656 3686854
Enable WriteCore feature for managedserviceidentity (#46563)
melina5656 7bc71a3
Enable-WriteCore-feature-for-compute And Release (#46310)
welovej 9b5d2fd
Enable-WriteCore-feature-for-containerregistry And Release (#46527)
welovej 75f579a
Update CHANGELOG.md (#46625)
welovej 148a3d4
Increment package version after release of Azure.ResourceManager.Cont…
azure-sdk 39b116b
Increment package version after release of Azure.ResourceManager.Comp…
azure-sdk 1a72564
Increment package version after release of Azure.ResourceManager.Mana…
azure-sdk b99cb10
Increment package version after release of Azure.ResourceManager.Cont…
azure-sdk 1498048
Increment package version after release of Azure.ResourceManager.Even…
azure-sdk 1450724
Increment package version after release of Azure.Identity (#46615)
azure-sdk f703f24
Delete DAC flow diagram (#46638)
scottaddie 49983fc
Increment package version after release of Azure.Monitor.OpenTelemetr…
azure-sdk 84f54f7
Sync .github/workflows directory with azure-sdk-tools for PR 9134 (#4…
azure-sdk abc40d3
Increment version for keyvault releases (#46647)
azure-sdk 5e8b299
cleaned up CM workspace APIs (#46649)
KrzysztofCwalina 5fb1796
[HealthcareApis/ApiManagement] Remove the ignore attribute and fix re…
melina5656 b3a28be
[ServiceBus/EventHub] Remove the ignore attribute and fix recording f…
melina5656 1ba7367
update (#46634)
welovej 0207495
Enable-WriteCore-feature-for-iothub And Release (#46178)
welovej 174e3d8
Enable-WriteCore-feature-for-logic And Release (#46184)
welovej 1ba67d8
release (#46621)
welovej 59f2ec4
release (#46620)
welovej 8b6ffb6
added acs token validity check
AikoBB 81939fb
[ContainerApps] Remove ingore attribute and fix the recording file af…
welovej 28bae8e
Mark AzureAuthorityHosts.AzureGermany as Obsolete. (#46371)
Eagle3386 c9fa717
AzurePipelinesCredential doc updates (#46668)
scottaddie 601b82b
Use BinaryData.Empty instead of bespoke solution in SCM and Azure.Cor…
annelo-msft 39986d6
[Storage] [DataMovement] Refactor Try-style methods (#46645)
nickliu-msft 7b3e5d2
Increment package version after release of Azure.ResourceManager.Logi…
azure-sdk d62dcaf
Increment package version after release of Azure.ResourceManager.Reco…
azure-sdk d1d2d36
Increment package version after release of Azure.ResourceManager.IotH…
azure-sdk e9b4733
Increment package version after release of Azure.ResourceManager.Oper…
azure-sdk dd38ca7
Sync eng/common directory with azure-sdk-tools for PR 9147 (#46682)
azure-sdk 50ec66b
Set resource group env variable early so remove always works (#46680)
azure-sdk f44fe20
Fix missing CloseAddressedIssues in gh event processor (#46678)
azure-sdk f853149
Handle missing artifacts without exception (#46676)
azure-sdk 5664b36
DevOpsInfrastructure - .Net SDK for GA stable version (#46652)
nicholasbergesen eb369aa
update1 (#46659)
welovej 11b18d0
update1 (#46660)
welovej 65a9d1f
update1 (#46662)
welovej ba54b3c
Enable-WriteCore-feature-for-cosmosdb (#46137)
welovej d5ae4b1
Update CHANGELOG.md (#46227)
melina5656 ab3850b
chore(playwrighttesting): removed fallback authentication logic (#46667)
kashish2508 130d1c7
[ElasticSan] Add support for ElasticSan auto scale policy (#46470)
yifanz7 904049f
fixed comments
AikoBB 50a2b82
fix(samples): upgrade vulnerable version of `Azure.Storage.Blobs` (#4…
archerzz 81e59aa
K8s-runtime SDK (#45651)
HE-Xinyu 17ef743
Update AutoRest C# version to 3.0.0-beta.20241017.1 (#46690)
azure-sdk 8cba7d7
Implement storage events (#46648)
christothes 4a4a28c
Annotate Azure.Messaging.EventHubs for trim/AOT compat (#46606)
sbomer dad28f1
Sync eng/common directory with azure-sdk-tools for PR 9177 (#46670)
azure-sdk d0aadf7
Fix storage tests-weekly matrix (#46651)
weshaggard e545aec
Update Readme.md and changelog for GA release. (#46684)
rhurey 02da266
Fix issue where stand-alone ManagedIdentityCredential does not consid…
christothes eb9d036
Sync eng/common directory with azure-sdk-tools for PR 9181 (#46695)
azure-sdk 68c2e95
Azure Compute Fleet GA version 2024-11-01 Minor update to Documentati…
rahuls-microsoft 823144f
Release stable version 2024-07-10 of HybridCompute (#46581)
yaotongms 4ea975a
Update Generator Version 3.0.0-beta.20241017.2 (#46699)
azure-sdk 61583cf
Increment package version after release of Azure.ResourceManager.Cont…
azure-sdk 10e73e6
Increment package version after release of Azure.ResourceManager.Hybr…
azure-sdk 13608ef
Handle cleanup for leased and encrypted storage accounts. Reduce thro…
azure-sdk 401d052
Added support for additional media message types: documents, videos, …
glorialimicrosoft b203feb
Merge transferjobinternal (#46540)
jaschrep-msft 6e5e7be
[CODEOWNERS] Removing invalid owners (#46710)
jsquire 14d9766
Azure.Provisioning: Rename after review feedback (#46715)
tg-msft 7c7f12b
[Storage][DataMovement] Record some tests that could not be previousl…
jalauzon-msft c7ffa2c
Azure.Provisioning: Unify resolvers and newslot Literal expressions (…
tg-msft d5acd65
Increment package version after release of Azure.Communication.Messag…
azure-sdk 3873c15
feat(playwrighttesting): separate api, test data processing and utili…
Sid200026 d49b532
docs(): update release date in CHANGELOG (#46730)
Sid200026 b2ccaba
fix(): remove dot from artifact safename (#46732)
Sid200026 8f98f23
Generating SDK with the latest TypeSpec commit (#46604)
hamshavathimunibyraiah 3fadc42
Azure.Provisioning: API cleanup (#46735)
tg-msft ec5fafd
Let DAC chain continue for 400 responses with 'Identity not found' (#…
christothes 19856fc
Move perf pipelines to TME subscription (#46739)
azure-sdk 2deb63c
[CODEOWNERS] Remove invalid account (#46741)
jsquire 8897cd4
Azure.Provisioning: Avoid excess `null`s in BicepStringBuilder (#46742)
tg-msft 040e54d
Sync eng/common directory with azure-sdk-tools for PR 9229 (#46743)
azure-sdk 4a51ce9
Update .NET SDK to remove property (#46272)
emmeliaAra fe44601
AI Face SDK update (#45402)
Han-msft 8981012
fix(playwrighttesting): logger name and flaky tests (#46746)
Sid200026 d21af4c
Increment package version after release of Azure.ResourceManager.Comp…
azure-sdk f25b742
Update Nginx SDK version (#46758)
SpencerOfwiti 1f536ba
Initial commit (#46759)
nickliu-msft 9e4d98d
Update for Azure Confidential Ledger Service Attention CODEOWNERS (#4…
amruthashree18 fc7b3ae
Fix spelling of Regenerate in yaml (#46761)
azure-sdk 52a4a34
Support branch name with space in create review step (#46763)
azure-sdk a5714d4
Update MSAL to 4.66.1 (#46764)
christothes 6a756a6
[NetAppFiles] update to 2024-07-01 (#46640)
audunn 6fd5181
Increment package version after release of Azure.AI.Vision.Face (#46770)
azure-sdk 5d4321a
[CognitiveServices] Prepare to release a new version (#46701)
melina5656 b949f5a
[signalr] Prepare to release a new version (#46727)
melina5656 8236e8d
docs(playwrighttesting): dotnet namespace fix and CHANGELOG update (#…
Sid200026 47f3c9b
Implement Response abstraction for Azure (#46530)
live1206 c166df8
Fix scenario where IMDS probe succeeds, but MI is unavailable (#46787)
christothes f8154ee
Publish pipeline artifact with converted symbols (#46738)
hallipr 9ad8747
Fixed a bug in AZD integration code (#46791)
KrzysztofCwalina e665cae
Fix symbol artifact output (#46797)
hallipr 11bb421
run Update-Mgmt-CI.ps1 in automation (#46748)
chunyu3 47fa5d4
DataFactory DotNet SDK Release (#46744)
wangbwn af1ab08
Increment package version after release of Azure.ResourceManager.Data…
azure-sdk 94d2be0
AVS 2023-09-01 SDK generation (#46324)
anaarias-msft 11b61b6
Prepare release for Azure.ResourceManager.ContainerInstance 1.3.0-bet…
ArthurMa1978 6928b39
chore(): 1.0.0-beta.1 post release changes (#46809)
Sid200026 02c5753
Increment package version after release of Azure.ResourceManager.Elas…
azure-sdk cf787a1
feat(playwrighttesting): Add support to publish attachments (#46780)
puagarwa 85d7532
Sync eng/common directory with azure-sdk-tools for PR 9236 (#46818)
azure-sdk 1556e06
Prep Identity for 1.13.1 patch release (#46817)
christothes fb11960
Increment package version after release of Azure.ResourceManager.Cont…
azure-sdk 6d72f21
Increment package version after release of Azure.ResourceManager.Avs …
azure-sdk 3db918d
[Azure.AI.Inference] Beta 2 (#45757)
trangevi fd0b3e7
[Storage][DataMovement] Add perf tests for DMLib Track1 (#46768)
jalauzon-msft 4dacd22
Adds SensitivityMask to DialogSensitivityUpdate (#46796)
calvinkwtang fe13140
Increment package version after release of Azure.AI.Vision.ImageAnaly…
azure-sdk fe91f47
Increment package version after release of Azure.AI.Inference (#46821)
azure-sdk cabfa4a
Allow default matrix selection override (#46825)
azure-sdk 730b202
Enable-WriteCore-for-Azure.Developer.DevCenter (#46779)
welovej dda8e31
added setter for scopes
AikoBB 31eda01
small test fix
AikoBB 67b0688
Merge remote-tracking branch 'upstream/main' into feature/aigerimb/op…
AikoBB File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
sdk/communication/Azure.Communication.Common/src/EntraCommunicationTokenCredentialOptions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Azure.Core; | ||
|
|
||
| namespace Azure.Communication | ||
| { | ||
| /// <summary> | ||
| /// The Entra Communication Token Options. | ||
| /// </summary> | ||
| public class EntraCommunicationTokenCredentialOptions | ||
| { | ||
| private static string[] DefaultScopes = { "https://communication.azure.com/clients/.default" }; | ||
| /// <summary> | ||
| /// The URI of the Azure Communication Services resource. | ||
| /// </summary> | ||
| public string ResourceEndpoint { get; } | ||
|
|
||
| /// <summary> | ||
| /// The credential capable of fetching an Entra user token. You can provide any implementation of <see cref="Azure.Core.TokenCredential"/>. | ||
| /// </summary> | ||
| public TokenCredential TokenCredential { get; } | ||
|
|
||
| /// <summary> | ||
| /// The scopes required for the Entra user token. These scopes determine the permissions granted to the token. For example, ["https://communication.azure.com/clients/VoIP"]. | ||
| /// </summary> | ||
| public string[] Scopes { get; } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="EntraCommunicationTokenCredentialOptions"/>. | ||
| /// </summary> | ||
| /// <param name="resourceEndpoint">The URI of the Azure Communication Services resource.For example, https://myResource.communication.azure.com.</param> | ||
| /// <param name="entraTokenCredential">The credential capable of fetching an Entra user token.</param> | ||
| /// <param name="scopes">The scopes required for the Entra user token.</param> | ||
| public EntraCommunicationTokenCredentialOptions( | ||
| string resourceEndpoint, | ||
| TokenCredential entraTokenCredential, | ||
| string[] scopes) | ||
| { | ||
| Argument.AssertNotNullOrEmpty(resourceEndpoint, nameof(resourceEndpoint)); | ||
| Argument.AssertNotNull(entraTokenCredential, nameof(entraTokenCredential)); | ||
| Argument.AssertNotNullOrEmpty(scopes, nameof(scopes)); | ||
|
|
||
| this.ResourceEndpoint = resourceEndpoint; | ||
| this.TokenCredential = entraTokenCredential; | ||
| this.Scopes = scopes; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="EntraCommunicationTokenCredentialOptions"/>. | ||
| /// </summary> | ||
| /// <param name="resourceEndpoint">The URI of the Azure Communication Services resource.For example, https://myResource.communication.azure.com.</param> | ||
| /// <param name="entraTokenCredential">The credential capable of fetching an Entra user token.</param> | ||
| public EntraCommunicationTokenCredentialOptions( | ||
| string resourceEndpoint, | ||
| TokenCredential entraTokenCredential) : this( | ||
| resourceEndpoint, | ||
| entraTokenCredential, | ||
| DefaultScopes) | ||
| { | ||
| } | ||
| } | ||
| } |
145 changes: 145 additions & 0 deletions
145
sdk/communication/Azure.Communication.Common/src/EntraTokenCredential.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Text.Json; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Azure.Core; | ||
| using Azure.Core.Pipeline; | ||
|
|
||
| namespace Azure.Communication | ||
| { | ||
| /// <summary> | ||
| /// Represents a credential that exchanges an Entra token for an Azure Communication Services (ACS) token, enabling access to ACS resources. | ||
| /// </summary> | ||
| internal sealed class EntraTokenCredential : ICommunicationTokenCredential | ||
| { | ||
| private HttpPipeline _pipeline; | ||
| private string _resourceEndpoint; | ||
| private readonly ThreadSafeRefreshableAccessTokenCache _accessTokenCache; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of <see cref="EntraTokenCredential"/>. | ||
| /// </summary> | ||
| /// <param name="options">The options for how the token will be fetched</param> | ||
| /// <param name="pipelineTransport">Only for testing.</param> | ||
| public EntraTokenCredential(EntraCommunicationTokenCredentialOptions options, HttpPipelineTransport pipelineTransport = null) | ||
DominikMe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| this._resourceEndpoint = options.ResourceEndpoint; | ||
| _pipeline = CreatePipelineFromOptions(options, pipelineTransport); | ||
| _accessTokenCache = new ThreadSafeRefreshableAccessTokenCache( | ||
| ExchangeEntraToken, | ||
| ExchangeEntraTokenAsync, | ||
| false, null, null); | ||
| _accessTokenCache.GetValueAsync(default); | ||
| } | ||
AikoBB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private HttpPipeline CreatePipelineFromOptions(EntraCommunicationTokenCredentialOptions options, HttpPipelineTransport pipelineTransport) | ||
| { | ||
| var authenticationPolicy = new BearerTokenAuthenticationPolicy(options.TokenCredential, options.Scopes); | ||
| var entraTokenGuardPolicy = new EntraTokenGuardPolicy(); | ||
| var clientOptions = ClientOptions.Default; | ||
| if (pipelineTransport != null) | ||
| { | ||
| clientOptions.Transport = pipelineTransport; | ||
| } | ||
| return HttpPipelineBuilder.Build(clientOptions, authenticationPolicy, entraTokenGuardPolicy); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public void Dispose() | ||
| { | ||
| _pipeline = default; | ||
| _accessTokenCache.Dispose(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets an <see cref="AccessToken"/>. | ||
| /// </summary> | ||
| /// <param name="cancellationToken">The cancellation token for the task.</param> | ||
| /// <returns> Contains the access token.</returns> | ||
| public AccessToken GetToken(CancellationToken cancellationToken = default) | ||
| => _accessTokenCache.GetValue(cancellationToken, () => true); | ||
|
|
||
| /// <summary> | ||
| /// Gets an <see cref="AccessToken"/>. | ||
| /// </summary> | ||
| /// <param name="cancellationToken">The cancellation token for the task.</param> | ||
| /// <returns> | ||
| /// A task that represents the asynchronous get token operation. The value of its <see cref="ValueTask{AccessToken}.Result"/> property contains the access token. | ||
| /// </returns> | ||
| public ValueTask<AccessToken> GetTokenAsync(CancellationToken cancellationToken = default) | ||
| => _accessTokenCache.GetValueAsync(cancellationToken, () => true); | ||
|
|
||
| private AccessToken ExchangeEntraToken(CancellationToken cancellationToken) | ||
AikoBB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| return ExchangeEntraTokenAsync(false, cancellationToken).EnsureCompleted(); | ||
| } | ||
|
|
||
| private async ValueTask<AccessToken> ExchangeEntraTokenAsync(CancellationToken cancellationToken) | ||
| { | ||
| var result = await ExchangeEntraTokenAsync(true, cancellationToken).ConfigureAwait(false); | ||
| return result; | ||
| } | ||
|
|
||
| private async ValueTask<AccessToken> ExchangeEntraTokenAsync(bool async, CancellationToken cancellationToken) | ||
| { | ||
| var message = CreateRequestMessage(); | ||
| if (async) | ||
| { | ||
| await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); | ||
| } | ||
| else | ||
| { | ||
| _pipeline.Send(message, cancellationToken); | ||
| } | ||
| return ParseAccessTokenFromResponse(message.Response); | ||
| } | ||
|
|
||
| private HttpMessage CreateRequestMessage() | ||
| { | ||
| var uri = new RequestUriBuilder(); | ||
| uri.Reset(new Uri(_resourceEndpoint)); | ||
| uri.AppendPath("/access/entra/:exchangeAccessToken", false); | ||
| uri.AppendQuery("api-version", "2024-04-01-preview", true); | ||
|
|
||
| var message = _pipeline.CreateMessage(); | ||
| var request = message.Request; | ||
| request.Uri = uri; | ||
| request.Method = RequestMethod.Post; | ||
| request.Headers.Add("Accept", "application/json"); | ||
| request.Headers.Add("Content-Type", "application/json"); | ||
| request.Content = "{}"; | ||
|
|
||
| return message; | ||
| } | ||
|
|
||
| private AccessToken ParseAccessTokenFromResponse(Response response) | ||
| { | ||
| switch (response.Status) | ||
| { | ||
| case 200: | ||
| try | ||
| { | ||
| var json = JsonDocument.Parse(response.Content); | ||
| var accessTokenJson = json.RootElement.GetProperty("accessToken").GetRawText(); | ||
| var acsToken = JsonSerializer.Deserialize<AcsToken>(accessTokenJson); | ||
| return new AccessToken(acsToken.token, acsToken.expiresOn); | ||
| } | ||
| catch (Exception) | ||
| { | ||
| throw new RequestFailedException(response); | ||
| } | ||
| default: | ||
| throw new RequestFailedException(response); | ||
| } | ||
| } | ||
|
|
||
| private class AcsToken | ||
| { | ||
| public string token { get; set; } | ||
| public DateTimeOffset expiresOn { get; set; } | ||
| } | ||
| } | ||
| } | ||
79 changes: 79 additions & 0 deletions
79
sdk/communication/Azure.Communication.Common/src/EntraTokenGuardPolicy.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using System.Text.Json; | ||
| using System.Threading.Tasks; | ||
| using Azure.Core; | ||
| using Azure.Core.Pipeline; | ||
|
|
||
| namespace Azure.Communication | ||
| { | ||
| internal class EntraTokenGuardPolicy : HttpPipelinePolicy | ||
AikoBB marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| private string _entraTokenCache; | ||
| private Response _responseCache; | ||
|
|
||
| public override void Process(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline) | ||
| { | ||
| ProcessAsync(message, pipeline, async: false).EnsureCompleted(); | ||
| } | ||
|
|
||
| public override ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline) | ||
| { | ||
| return ProcessAsync(message, pipeline, async: true); | ||
| } | ||
|
|
||
| private async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline, bool async) | ||
| { | ||
| var (entraTokenCacheOutdated, token) = IsEntraTokenCacheOutdated(message); | ||
| if (entraTokenCacheOutdated || IsAcsTokenCacheOutdated()) | ||
| { | ||
| _entraTokenCache = token; | ||
| if (async) | ||
| { | ||
| await ProcessNextAsync(message, pipeline).ConfigureAwait(continueOnCapturedContext: false); | ||
| } | ||
| else | ||
| { | ||
| ProcessNext(message, pipeline); | ||
| } | ||
| _responseCache = message.Response; | ||
| } | ||
| else | ||
| { | ||
| message.Response = _responseCache; | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| private (bool CacheOutdated, string EntraToken) IsEntraTokenCacheOutdated(HttpMessage message) | ||
AikoBB marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| var currentEntraToken = string.Empty; | ||
| message.Request.Headers.TryGetValue("Authorization", out currentEntraToken); | ||
| return (string.IsNullOrEmpty(_entraTokenCache) || currentEntraToken != _entraTokenCache, currentEntraToken); | ||
| } | ||
| private bool IsAcsTokenCacheOutdated() | ||
AikoBB marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| return _responseCache == null || _responseCache.Status != 200 || !IsAccessTokenValid(); | ||
| } | ||
|
|
||
| private bool IsAccessTokenValid() | ||
| { | ||
| try | ||
| { | ||
| var json = JsonDocument.Parse(_responseCache.Content); | ||
| var expiresOnString = json.RootElement | ||
| .GetProperty("accessToken") | ||
| .GetProperty("expiresOn") | ||
| .GetString(); | ||
| var expiresOn = DateTimeOffset.Parse(expiresOnString); | ||
| return DateTimeOffset.UtcNow < expiresOn; | ||
| } | ||
| catch | ||
| { | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.