-
Notifications
You must be signed in to change notification settings - Fork 5
port updateExtensionAuthenticationRequest #61
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
base: release/3.0
Are you sure you want to change the base?
port updateExtensionAuthenticationRequest #61
Conversation
17f2d5d to
316cbaa
Compare
316cbaa to
fbf15b7
Compare
wparad
left a comment
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'm marking this as request changes, but realistically, these changes are something I expect us to do before merging on top of this PR. I'm not expecting you to go through and make these updates.
| * @param {Object} [connectionProperties] Connection specific properties to pass to the identity provider. Can be used to override default scopes for example. | ||
| * @return {Promise<AuthenticateResponse>} The authentication response. | ||
| */ | ||
| async updateExtensionAuthenticationRequest({ state, connectionId, tenantLookupIdentifier, connectionProperties, hint }) { |
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.
Will likely be a new method in:
loginApi.updateAuthenticationRequest(authenticationRequestId, { hint, tenantLookupIdentifier, connection });| connectionProperties | ||
| }); | ||
|
|
||
| return requestOptions.data; |
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'm thinking a dedicated response object that only includes the authenticationUrl to be used by the caller, rather than the full object.
|
|
||
| return requestOptions.data; | ||
| } catch (error) { | ||
| if (error.status && error.status >= 400 && error.status < 500) { |
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.
We'll want this pattern to match the other APIs error response pattern.
| } | ||
| } | ||
|
|
||
| async calculateAntiAbuseHash(props) { |
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.
Make sure to take in the explicit properties by name in the expected order, validate there aren't any additional properties, before creating the valueString.
| let fineTuner = 0; | ||
| let hash = null; | ||
| while (++fineTuner) { | ||
| hash = base64url.encode(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(`${timestamp};${fineTuner};${valueString}`))); |
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.
Will probably want the crypto.createHash version which avoids the need for the text encoder, I actually don't know if the async version is better, since this is CPU intensive, using the async method in subtle is less consistent with the other createHash crypto usages we have.
| try { | ||
| const resolvedTenantLookupIdentifier = hint || tenantLookupIdentifier; | ||
| const antiAbuseHash = await jwtManager.calculateAntiAbuseHash({ connectionId, tenantLookupIdentifier: resolvedTenantLookupIdentifier, authenticationRequestId }); | ||
| const requestOptions = await this.httpClient.patch(`/api/authentication/${authenticationRequestId}`, { |
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.
Reminder: Add the origin header.
From: https://github.com/Authress/authress-login.js/blob/release/2.6/src/index.js#L441
Allows this redirection to happen on the server and not be dependent on browser javascript.