Skip to content

Conversation

@cranberyxl
Copy link

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.

@cranberyxl cranberyxl force-pushed the feature/updateExtensionAuthenticationRequest branch 3 times, most recently from 17f2d5d to 316cbaa Compare December 10, 2025 12:43
@cranberyxl cranberyxl force-pushed the feature/updateExtensionAuthenticationRequest branch from 316cbaa to fbf15b7 Compare December 10, 2025 13:13
Copy link
Member

@wparad wparad left a 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 }) {
Copy link
Member

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;
Copy link
Member

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) {
Copy link
Member

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) {
Copy link
Member

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}`)));
Copy link
Member

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}`, {
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants