-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Identity] Adding regional STS support #15778
Changes from 7 commits
4cd97eb
41991f6
c8cf76e
fcf5d5d
f75bb74
96f200b
0b24db8
59d7fc3
158acd3
76515f8
81de984
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,7 @@ export class ClientCertificateCredential implements TokenCredential { | |
|
||
// @public | ||
export interface ClientCertificateCredentialOptions extends TokenCredentialOptions { | ||
regionalAuthority?: string; | ||
sendCertificateChain?: boolean; | ||
} | ||
|
||
|
@@ -103,6 +104,7 @@ export class ClientSecretCredential implements TokenCredential { | |
|
||
// @public | ||
export interface ClientSecretCredentialOptions extends TokenCredentialOptions { | ||
regionalAuthority?: string; | ||
} | ||
|
||
// @public | ||
|
@@ -210,6 +212,63 @@ export class ManagedIdentityCredential implements TokenCredential { | |
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken>; | ||
} | ||
|
||
// @public | ||
export enum RegionalAuthority { | ||
AsiaEastValue = "eastasia", | ||
sadasant marked this conversation as resolved.
Show resolved
Hide resolved
|
||
AsiaSouthEastValue = "southeastasia", | ||
AustraliaCentral2Value = "australiacentral2", | ||
AustraliaCentralValue = "australiacentral", | ||
AustraliaEastValue = "australiaeast", | ||
AustraliaSouthEastValue = "australiasoutheast", | ||
AutoDiscoverRegion = "AUTO_DISCOVER", | ||
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. It's interesting that MSAL for node seems to use a different constant for this than .NET, which uses the string constant "TryAutoDetect" which it exposes as a constant 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. I don’t see it here: https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-node/docs/regional-authorities.md I’ll ask the MSAL team. What is the value of the 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. As discussed, I’ll use the value |
||
BrazilSouthValue = "brazilsouth", | ||
CanadaCentralValue = "canadacentral", | ||
CanadaEastValue = "canadaeast", | ||
ChinaEast2Value = "chinaeast2", | ||
ChinaEastValue = "chinaeast", | ||
ChinaNorth2Value = "chinanorth2", | ||
ChinaNorthValue = "chinanorth", | ||
EuropeNorthValue = "northeurope", | ||
EuropeWestValue = "westeurope", | ||
FranceCentralValue = "francecentral", | ||
FranceSouthValue = "francesouth", | ||
GermanyCentralValue = "germanycentral", | ||
GermanyNorthEastValue = "germanynortheast", | ||
GermanyNorthValue = "germanynorth", | ||
GermanyWestCentralValue = "germanywestcentral", | ||
GovernmentUSArizonaValue = "usgovarizona", | ||
GovernmentUSDodCentralValue = "usdodcentral", | ||
GovernmentUSDodEastValue = "usdodeast", | ||
GovernmentUSIowaValue = "usgoviowa", | ||
GovernmentUSTexasValue = "usgovtexas", | ||
GovernmentUSVirginiaValue = "usgovvirginia", | ||
IndiaCentralValue = "centralindia", | ||
IndiaSouthValue = "southindia", | ||
IndiaWestValue = "westindia", | ||
JapanEastValue = "japaneast", | ||
JapanWestValue = "japanwest", | ||
KoreaCentralValue = "koreacentral", | ||
KoreaSouthValue = "koreasouth", | ||
NorwayEastValue = "norwayeast", | ||
NorwayWestValue = "norwaywest", | ||
SouthAfricaNorthValue = "southafricanorth", | ||
SouthAfricaWestValue = "southafricawest", | ||
SwitzerlandNorthValue = "switzerlandnorth", | ||
SwitzerlandWestValue = "switzerlandwest", | ||
UAECentralValue = "uaecentral", | ||
UAENorthValue = "uaenorth", | ||
UKSouthValue = "uksouth", | ||
UKWestValue = "ukwest", | ||
USCentralValue = "centralus", | ||
USEast2Value = "eastus2", | ||
USEastValue = "eastus", | ||
USNorthCentralValue = "northcentralus", | ||
USSouthCentralValue = "southcentralus", | ||
USWest2Value = "westus2", | ||
USWestCentralValue = "westcentralus", | ||
USWestValue = "westus" | ||
} | ||
|
||
// @public | ||
export function serializeAuthenticationRecord(record: AuthenticationRecord): string; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,12 @@ import { | |
*/ | ||
export interface MsalNodeOptions extends MsalFlowOptions { | ||
tokenCredentialOptions: TokenCredentialOptions; | ||
/** | ||
* Specifies a regional authority. Please refer to the {@link RegionalAuthority} type for the accepted values. | ||
* If {@link RegionalAuthority.AutoDiscoverRegion} is specified, we will try to discover the regional authority endpoint. | ||
* If the property is not specified, uses a non-regional authority endpoint. | ||
*/ | ||
regionalAuthority?: string; | ||
} | ||
|
||
/** | ||
|
@@ -45,11 +51,13 @@ export abstract class MsalNode extends MsalBaseUtilities implements MsalFlow { | |
protected clientId: string; | ||
protected identityClient?: IdentityClient; | ||
protected requiresConfidential: boolean = false; | ||
protected azureRegion?: string; | ||
|
||
constructor(options: MsalNodeOptions) { | ||
super(options); | ||
this.msalConfig = this.defaultNodeMsalConfig(options); | ||
this.clientId = this.msalConfig.auth.clientId; | ||
this.azureRegion = options.regionalAuthority || process.env.AZURE_REGIONAL_AUTHORITY_NAME; | ||
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. This seems like the right priority, but I wonder if the env variable should trump the 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. I can see your point about auto discover, however, I think we should stick to the convention that code configuration always wins as you put it. We follow this convention with all our other supported environment variables. Altering this behavior based of the value specified adds a lot of complexity without much benefit.
sadasant marked this conversation as resolved.
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.
I’ve increased the timeout because the live regional test is very time consuming. I’ve added a no-timeouts line here to help testing. We have something similar on Key Vault.
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.
My understanding is we can't fix the tests to be fast because it depends on MSAL and MSAL is slow, even for unit tests? In theory these shouldn't be unit tests, but live tests if they need external deps.
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.
These are live tests. On playback they are pretty fast. In the three tests I’m adding here, only one does finish. The one that finishes takes 27 seconds
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 these tests are taking so long is because the test is using the region
RegionalAuthority.AutoDiscoverRegion
. This results in MSAL trying to discover the region it is running in which it does, in part, by trying to query IMDS. I'm assuming this is likely timing out if you're running in a local environment.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.
There are alternatives that may work that seem complicated in my mind. The alternative that seems simple is to remove the live test. We have two other tests that verify that the parameter is sent through MSAL, which should be enough. What do you think?
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.
Oh I can record this test with a specific region, then only enable it for playback 🤔 I’ll do that for now
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.
It’s not timing out though, the recordings show all 200s 🤔