diff --git a/plugins/auth-backend/src/lib/OAuthProvider.ts b/plugins/auth-backend/src/lib/OAuthProvider.ts index 6faaa9f733..8d8743d24b 100644 --- a/plugins/auth-backend/src/lib/OAuthProvider.ts +++ b/plugins/auth-backend/src/lib/OAuthProvider.ts @@ -46,13 +46,13 @@ const readState = (stateString: string): OAuthState => { new URLSearchParams(decodeURIComponent(stateString)), ); return { - nonce: state.nonce ?? undefined, - env: state.env ?? undefined, + nonce: state.nonce ?? '', + env: state.env ?? '', }; } catch (e) { return { - nonce: undefined, - env: undefined, + nonce: '', + env: '', }; } }; @@ -85,7 +85,7 @@ export const verifyNonce = (req: express.Request, providerId: string) => { if (!cookieNonce) { throw new Error('Auth response is missing cookie nonce'); } - if (!stateNonce) { + if (stateNonce.length === 0) { throw new Error('Auth response is missing state nonce'); } if (cookieNonce !== stateNonce) { diff --git a/plugins/auth-backend/src/providers/types.ts b/plugins/auth-backend/src/providers/types.ts index afb136fd0f..74ed75d57a 100644 --- a/plugins/auth-backend/src/providers/types.ts +++ b/plugins/auth-backend/src/providers/types.ts @@ -345,6 +345,6 @@ export type SAMLEnvironmentProviderConfig = { export type OAuthState = { /* A type for the serialized value in the `state` parameter of the OAuth authorization flow */ - nonce?: string; - env?: string; + nonce: string; + env: string; };