Refactor: Make properties of OAuthState non-optional

This commit is contained in:
Govindarajan Nagarajan
2020-08-04 18:48:38 +02:00
parent cb80b2b4f8
commit 4ae351b06f
2 changed files with 7 additions and 7 deletions
@@ -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) {
+2 -2
View File
@@ -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;
};