Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(authentication): improve edge case handling

anirudhprmarcca84b0574ae
diff --git a/react/features/authentication/functions.native.ts b/react/features/authentication/functions.native.ts
index ed6bcc94a8..53f91b9bec 100644
--- a/react/features/authentication/functions.native.ts
+++ b/react/features/authentication/functions.native.ts
@@ -57,7 +57,7 @@ export const getTokenAuthUrl = (
return Promise.resolve(undefined);
}
- if (url.indexOf('{state}')) {
+ if (url.includes('{state}')) {
const state = _getTokenAuthState(
locationURL,
{
diff --git a/react/features/authentication/functions.web.ts b/react/features/authentication/functions.web.ts
index 4141eb5cea..350d90c353 100644
--- a/react/features/authentication/functions.web.ts
+++ b/react/features/authentication/functions.web.ts
@@ -75,7 +75,7 @@ export const getTokenAuthUrl = (
return Promise.resolve(undefined);
}
- if (url.indexOf('{state}')) {
+ if (url.includes('{state}')) {
const state = _getTokenAuthState(
locationURL,
{
@@ -99,7 +99,7 @@ export const getTokenAuthUrl = (
url = url.replace('{room}', roomName);
- if (url.indexOf('{code_challenge}')) {
+ if (url.includes('{code_challenge}')) {
let codeVerifier = '';
// random string
@@ -132,5 +132,11 @@ export const getTokenAuthUrl = (
});
}
+ try {
+ window.sessionStorage.removeItem('code_verifier');
+ } catch (error) {
+ logger.error('Unable to remove code verifier from session storage', error);
+ }
+
return Promise.resolve(url);
};
diff --git a/static/sso.html b/static/sso.html
index 7e7642e2a0..a680ae0f72 100644
--- a/static/sso.html
+++ b/static/sso.html
@@ -233,8 +233,14 @@
// Retrieve code_verifier and oauth_nonce from sessionStorage (set during login initiation)
const codeVerifier = sessionStorage.getItem('code_verifier');
- if (!codeVerifier) {
- throw new Error('No PKCE code verifier found in session');
+ const params = {
+ grant_type: 'authorization_code',
+ code: code,
+ redirect_uri: window.location.origin + window.location.pathname,
+ client_id: sso.clientId
+ };
+ if (codeVerifier) {
+ params.code_verifier = codeVerifier;
}
const oauthNonce = sessionStorage.getItem('oauth_nonce');
@@ -252,13 +258,7 @@
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
- body: new URLSearchParams({
- grant_type: 'authorization_code',
- code: code,
- redirect_uri: window.location.origin + window.location.pathname,
- client_id: sso.clientId,
- code_verifier: codeVerifier
- })
+ body: new URLSearchParams(params)
});
if (!tokenResponse.ok) {