Repository navigation
Native Auth V2 entry and validation fixes #8898
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
Changes from 16 commits
2e88a03
915ab7d
29c0f2f
a1f023c
7acba6e
d3bafde
b74b901
dc41a62
236ed56
29af15d
d101e31
b90f6fd
cf87471
1a4e3cb
d1812dd
8a30db9
47fdcbc
0f2dffb
074bb69
c8b7661
c6d8235
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "type": "minor", | ||
| "comment": "Add Native Auth V2 authorization inputs and challenge validation fixes [#8898](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8898)", | ||
| "packageName": "@azure/msal-browser", | ||
| "email": "yongdiwang@microsoft.com", | ||
| "dependentChangeType": "patch" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,8 +142,11 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
|
|
||
| this.logger.verbose("Starting V2 sign-in.", correlationId); | ||
|
|
||
| const scopes = this.getScopes(parameters.scopes); | ||
| const entryResult = await this.apiClient.authorizeChallengeStart( | ||
| context | ||
| context, | ||
| scopes, | ||
| parameters.claims | ||
| ); | ||
| const startResult = await this.apiClient.signInStart( | ||
| this.requireLink(correlationId, entryResult.signInHref, { | ||
|
|
@@ -167,10 +170,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| const continuationState: FlowContinuationStateV2 = { | ||
| continuationToken: startResult.continuationToken, | ||
| scenario: CustomAuthFlowScenarioV2.SignIn, | ||
| scopes, | ||
| links: {}, | ||
| tokenRequest: { | ||
| scopes: parameters.scopes, | ||
| }, | ||
| }; | ||
| const methods = startResult.methods.map((method) => ({ | ||
| id: method.id, | ||
|
|
@@ -231,9 +232,11 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
|
|
||
| this.logger.verbose("Starting V2 sign-up.", correlationId); | ||
|
|
||
| const scopes = this.getScopes(parameters.scopes); | ||
| const entryResult = await this.apiClient.authorizeChallengeStart( | ||
| context, | ||
| parameters.scopes | ||
| scopes, | ||
| parameters.claims | ||
| ); | ||
| const startResult = await this.apiClient.signUpStart( | ||
| this.requireLink(correlationId, entryResult.signUpHref, { | ||
|
|
@@ -268,10 +271,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| const continuationState: FlowContinuationStateV2 = { | ||
| continuationToken: startResult.continuationToken, | ||
| scenario: CustomAuthFlowScenarioV2.SignUp, | ||
| scopes, | ||
| links: {}, | ||
| tokenRequest: { | ||
| scopes: parameters.scopes, | ||
| }, | ||
| signUp: { | ||
| passwordWasSupplied: attributes.password !== undefined, | ||
| }, | ||
|
|
@@ -318,8 +319,11 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| correlationId | ||
| ); | ||
|
|
||
| const scopes = this.getScopes(parameters.scopes); | ||
| const entryResult = await this.apiClient.authorizeChallengeStart( | ||
| context | ||
| context, | ||
| scopes, | ||
| parameters.claims | ||
| ); | ||
| const startResult = await this.apiClient.resetPasswordStart( | ||
| this.requireLink(correlationId, entryResult.resetPasswordHref, { | ||
|
|
@@ -342,6 +346,7 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| const continuationState: FlowContinuationStateV2 = { | ||
| continuationToken: startResult.continuationToken, | ||
| scenario: CustomAuthFlowScenarioV2.PasswordReset, | ||
| scopes, | ||
| links: {}, | ||
| }; | ||
| const methods = startResult.methods.map((method) => ({ | ||
|
|
@@ -492,6 +497,7 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| continuationState: { | ||
| continuationToken: verifyResult.continuationToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: { update: verifyResult.updateHref }, | ||
| }, | ||
| }); | ||
|
|
@@ -517,10 +523,10 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| const nextContinuationState: FlowContinuationStateV2 = { | ||
| continuationToken: verifyResult.continuationToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: { | ||
| submitAttributes: verifyResult.submitAttributesHref, | ||
| }, | ||
| tokenRequest: continuationState.tokenRequest, | ||
| signUp: continuationState.signUp, | ||
| }; | ||
| const attributes = verifyResult.attributes.filter( | ||
|
|
@@ -556,8 +562,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| continuationState: { | ||
| continuationToken: verifyResult.continuationToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: {}, | ||
| tokenRequest: continuationState.tokenRequest, | ||
| }, | ||
| }); | ||
| } | ||
|
|
@@ -715,6 +721,7 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| continuationState: { | ||
| continuationToken: completionToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: {}, | ||
| }, | ||
| }); | ||
|
|
@@ -756,19 +763,16 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| correlationId | ||
| ); | ||
|
|
||
| const scopes = this.getScopes(parameters.scopes); | ||
|
|
||
| const tokenResponse = await this.apiClient.completeWithTokens( | ||
| { | ||
| continuationToken: continuationState.continuationToken, | ||
| scopes, | ||
| }, | ||
| context | ||
| ); | ||
|
|
||
| const authenticationResult = await this.handleTokenResponse( | ||
| tokenResponse, | ||
| scopes, | ||
| continuationState.scopes, | ||
| correlationId, | ||
| apiId | ||
| ); | ||
|
|
@@ -802,8 +806,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| continuationState: { | ||
| continuationToken: verifyResult.continuationToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: {}, | ||
| tokenRequest: continuationState.tokenRequest, | ||
| }, | ||
| methods: verifyResult.methods.map((method) => ({ | ||
| id: method.id, | ||
|
|
@@ -846,22 +850,9 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| method.type.toLowerCase() === AuthenticationMethodTypeV2.EMAIL | ||
| ); | ||
|
|
||
| if (passwordProvided) { | ||
|
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 would say removing this is ok, they will catch on fast when they see the code being sent. Also it's big UI ibug if they have password there but use it for OTP users
Contributor
Author
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. Agreed. The stacked method-selection PR #8899 removes this automatic choice when multiple supported methods are returned and lets the application select the actual method. A supplied password is submitted automatically only when Password is the sole supported method; if Email/SMS is the sole method, the SDK returns code-required and ignores the supplied password. Focused unit coverage verifies the supplied-password + Email OTP case. |
||
| if (passwordMethod) { | ||
| return passwordMethod; | ||
| } | ||
|
|
||
| const message = | ||
| "A password was supplied, but the sign-in response did not include a password method."; | ||
| this.logger.error(message, correlationId); | ||
| throw new CustomAuthError( | ||
| UNSUPPORTED_FLOW_TRANSITION, | ||
| message, | ||
| correlationId | ||
| ); | ||
| } | ||
|
|
||
| const selectedMethod = emailMethod ?? passwordMethod; | ||
| const selectedMethod = passwordProvided | ||
| ? passwordMethod ?? emailMethod | ||
| : emailMethod ?? passwordMethod; | ||
| if (selectedMethod) { | ||
| return selectedMethod; | ||
| } | ||
|
|
@@ -889,11 +880,11 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| continuationState: { | ||
| continuationToken: result.continuationToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: { | ||
| verify: result.verifyHref, | ||
| resend: result.resendHref, | ||
| }, | ||
| tokenRequest: continuationState.tokenRequest, | ||
| signUp: continuationState.signUp, | ||
| }, | ||
| channel: result.type, | ||
|
|
@@ -914,10 +905,10 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| const nextContinuationState: FlowContinuationStateV2 = { | ||
| continuationToken: result.continuationToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: { | ||
| submitAttributes: result.submitAttributesHref, | ||
| }, | ||
| tokenRequest: continuationState.tokenRequest, | ||
| signUp: continuationState.signUp, | ||
| }; | ||
| const attributes = result.attributes.filter( | ||
|
|
@@ -950,8 +941,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| continuationState: { | ||
| continuationToken: result.continuationToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: {}, | ||
| tokenRequest: continuationState.tokenRequest, | ||
| }, | ||
| }); | ||
| } | ||
|
|
@@ -1019,10 +1010,9 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| continuationState: { | ||
| continuationToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: {}, | ||
| tokenRequest: continuationState.tokenRequest, | ||
| }, | ||
| scopes: continuationState.tokenRequest?.scopes, | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -1087,16 +1077,14 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 { | |
| return { | ||
| continuationToken: challengeResult.continuationToken, | ||
| scenario: continuationState.scenario, | ||
| scopes: continuationState.scopes, | ||
| links: { | ||
| challenge: continuationState.links.challenge, | ||
| verify: challengeResult.verifyHref, | ||
| resend: | ||
| challengeResult.resendHref ?? | ||
| continuationState.links.resend, | ||
| }, | ||
| ...(continuationState.tokenRequest && { | ||
| tokenRequest: continuationState.tokenRequest, | ||
| }), | ||
| ...(continuationState.signUp && { | ||
| signUp: continuationState.signUp, | ||
| }), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.