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: Fixes passing the hash params in state for token auth URL.

damencho144c1ce4f4b8
diff --git a/react/features/app/actions.any.ts b/react/features/app/actions.any.ts
index ac562a0393..7b2c0b18a9 100644
--- a/react/features/app/actions.any.ts
+++ b/react/features/app/actions.any.ts
@@ -104,7 +104,7 @@ export function maybeRedirectToTokenAuthUrl(
dispatch: IStore['dispatch'], getState: IStore['getState'], failureCallback: Function) {
const state = getState();
const config = state['features/base/config'];
- const { locationURL = { href: '' } } = state['features/base/connection'];
+ const { locationURL = { href: '' } as URL } = state['features/base/connection'];
if (!isTokenAuthEnabled(config)) {
return false;
@@ -120,7 +120,7 @@ export function maybeRedirectToTokenAuthUrl(
const room = state['features/base/conference'].room;
const { tenant } = parseURIString(locationURL.href) || {};
- getTokenAuthUrl(config, room, tenant, true)
+ getTokenAuthUrl(config, room, tenant, true, locationURL)
.then((tokenAuthServiceUrl: string | undefined) => {
if (!tokenAuthServiceUrl) {
logger.warn('Cannot handle login, token service URL is not set');
diff --git a/react/features/app/getRouteToRender.web.ts b/react/features/app/getRouteToRender.web.ts
index 75cf0f06dc..fc4ad60bd7 100644
--- a/react/features/app/getRouteToRender.web.ts
+++ b/react/features/app/getRouteToRender.web.ts
@@ -53,10 +53,10 @@ function _getWebConferenceRoute(state: IReduxState) {
if (!browser.isElectron() && config.tokenAuthUrl && config.tokenAuthUrlAutoRedirect
&& state['features/authentication'].tokenAuthUrlSuccessful
&& !state['features/base/jwt'].jwt && room) {
- const { locationURL = { href: '' } } = state['features/base/connection'];
+ const { locationURL = { href: '' } as URL } = state['features/base/connection'];
const { tenant } = parseURIString(locationURL.href) || {};
- return getTokenAuthUrl(config, room, tenant)
+ return getTokenAuthUrl(config, room, tenant, false, locationURL)
.then((url: string | undefined) => {
route.href = url;
diff --git a/react/features/authentication/functions.any.ts b/react/features/authentication/functions.any.ts
index 163b78f3fe..22a59f21fb 100644
--- a/react/features/authentication/functions.any.ts
+++ b/react/features/authentication/functions.any.ts
@@ -16,12 +16,14 @@ export const isTokenAuthEnabled = (config: IConfig): boolean =>
* @param {string?} roomName - The room name.
* @param {string?} tenant - The tenant name if any.
* @param {boolean} skipPrejoin - Whether to skip pre-join page.
+ * @param {URL} locationURL - The location URL.
* @returns {Object} The state object.
*/
export const _getTokenAuthState = (
roomName: string | undefined,
tenant: string | undefined,
- skipPrejoin: boolean | undefined = false): object => {
+ skipPrejoin: boolean | undefined = false,
+ locationURL: URL): object => {
const state = {
room: roomName,
roomSafe: getBackendSafeRoomName(roomName),
@@ -34,7 +36,7 @@ export const _getTokenAuthState = (
state['config.prejoinConfig.enabled'] = false;
}
- const params = new URLSearchParams(window.location.search);
+ const params = new URLSearchParams(locationURL.hash);
for (const [ key, value ] of params) {
// we allow only config and interfaceConfig overrides in the state
diff --git a/react/features/authentication/functions.native.ts b/react/features/authentication/functions.native.ts
index 18d02dd3e1..4feac2ea22 100644
--- a/react/features/authentication/functions.native.ts
+++ b/react/features/authentication/functions.native.ts
@@ -17,6 +17,7 @@ export * from './functions.any';
* @param {string} roomName - The name of the conference room for which the user will be authenticated.
* @param {string} tenant - The name of the conference tenant.
* @param {string} skipPrejoin - The name of the conference room for which the user will be authenticated.
+ * @param {URL} locationURL - The location URL.
*
* @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
* <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
@@ -26,7 +27,9 @@ export const getTokenAuthUrl = (
config: IConfig,
roomName: string | undefined,
tenant: string | undefined,
- skipPrejoin: boolean | undefined = false): Promise<string | undefined> => {
+ skipPrejoin: boolean | undefined = false,
+ // eslint-disable-next-line max-params
+ locationURL: URL): Promise<string | undefined> => {
let url = config.tokenAuthUrl;
@@ -35,7 +38,7 @@ export const getTokenAuthUrl = (
}
if (url.indexOf('{state}')) {
- const state = _getTokenAuthState(roomName, tenant, skipPrejoin);
+ const state = _getTokenAuthState(roomName, tenant, skipPrejoin, locationURL);
// Append ios=true or android=true to the token URL.
// @ts-ignore
diff --git a/react/features/authentication/functions.web.ts b/react/features/authentication/functions.web.ts
index ca06905b44..1aa0e4107d 100644
--- a/react/features/authentication/functions.web.ts
+++ b/react/features/authentication/functions.web.ts
@@ -35,6 +35,7 @@ function _cryptoRandom() {
* @param {string} roomName - The name of the conference room for which the user will be authenticated.
* @param {string} tenant - The name of the conference tenant.
* @param {string} skipPrejoin - The name of the conference room for which the user will be authenticated.
+ * @param {URL} locationURL - The current location URL.
*
* @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
* <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
@@ -44,7 +45,9 @@ export const getTokenAuthUrl = (
config: IConfig,
roomName: string | undefined,
tenant: string | undefined,
- skipPrejoin: boolean | undefined = false): Promise<string | undefined> => {
+ skipPrejoin: boolean | undefined = false,
+ // eslint-disable-next-line max-params
+ locationURL: URL): Promise<string | undefined> => {
let url = config.tokenAuthUrl;
@@ -53,7 +56,7 @@ export const getTokenAuthUrl = (
}
if (url.indexOf('{state}')) {
- const state = _getTokenAuthState(roomName, tenant, skipPrejoin);
+ const state = _getTokenAuthState(roomName, tenant, skipPrejoin, locationURL);
if (browser.isElectron()) {
// @ts-ignore
diff --git a/react/features/authentication/middleware.ts b/react/features/authentication/middleware.ts
index d093a713ad..8ef9b0499b 100644
--- a/react/features/authentication/middleware.ts
+++ b/react/features/authentication/middleware.ts
@@ -255,7 +255,7 @@ function _handleLogin({ dispatch, getState }: IStore) {
const state = getState();
const config = state['features/base/config'];
const room = state['features/base/conference'].room;
- const { locationURL = { href: '' } } = state['features/base/connection'];
+ const { locationURL = { href: '' } as URL } = state['features/base/connection'];
const { tenant } = parseURIString(locationURL.href) || {};
if (!room) {
@@ -270,7 +270,7 @@ function _handleLogin({ dispatch, getState }: IStore) {
return;
}
- getTokenAuthUrl(config, room, tenant, true)
+ getTokenAuthUrl(config, room, tenant, true, locationURL)
.then((tokenAuthServiceUrl: string | undefined) => {
if (!tokenAuthServiceUrl) {
logger.warn('Cannot handle login, token service URL is not set');