Merge pull request #615 from KKonstantinov/bugfix/authorization-url-generate-state
OAuth Flow: generate random state parameter in oauth state machine
This commit is contained in:
commit
33dbf8399e
1 changed files with 8 additions and 0 deletions
|
|
@ -113,6 +113,13 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
||||||
scope = metadata.scopes_supported.join(" ");
|
scope = metadata.scopes_supported.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate a random state
|
||||||
|
const array = new Uint8Array(32);
|
||||||
|
crypto.getRandomValues(array);
|
||||||
|
const state = Array.from(array, (byte) =>
|
||||||
|
byte.toString(16).padStart(2, "0"),
|
||||||
|
).join("");
|
||||||
|
|
||||||
const { authorizationUrl, codeVerifier } = await startAuthorization(
|
const { authorizationUrl, codeVerifier } = await startAuthorization(
|
||||||
context.serverUrl,
|
context.serverUrl,
|
||||||
{
|
{
|
||||||
|
|
@ -120,6 +127,7 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
|
||||||
clientInformation,
|
clientInformation,
|
||||||
redirectUrl: context.provider.redirectUrl,
|
redirectUrl: context.provider.redirectUrl,
|
||||||
scope,
|
scope,
|
||||||
|
state: state,
|
||||||
resource: context.state.resource ?? undefined,
|
resource: context.state.resource ?? undefined,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue