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(jwt-validation): validate `kid` value only for JaaS

hmuresana582f1c191bc
diff --git a/react/features/base/jwt/constants.js b/react/features/base/jwt/constants.js
index d95eba49bb..cbc48da368 100644
--- a/react/features/base/jwt/constants.js
+++ b/react/features/base/jwt/constants.js
@@ -11,5 +11,7 @@ export const MEET_FEATURES = [
'outbound-call',
'recording',
'room',
+ 'screen-sharing',
+ 'sip-outbound-call',
'transcription'
];
diff --git a/react/features/base/jwt/functions.js b/react/features/base/jwt/functions.js
index 84a296e907..2ca973db9d 100644
--- a/react/features/base/jwt/functions.js
+++ b/react/features/base/jwt/functions.js
@@ -67,49 +67,59 @@ export function validateJwt(jwt: string) {
return errors;
}
- const { kid } = header;
+ const {
+ aud,
+ context,
+ exp,
+ iss,
+ nbf,
+ sub
+ } = payload;
- // if Key ID is missing, we return the error immediately without further validations.
- if (!kid) {
- errors.push('- Key ID(kid) missing');
+ // JaaS only
+ if (sub && sub.startsWith('vpaas-magic-cookie')) {
+ const { kid } = header;
- return errors;
- }
+ // if Key ID is missing, we return the error immediately without further validations.
+ if (!kid) {
+ errors.push('- Key ID(kid) missing');
- // JaaS only
- if (kid.startsWith('vpaas-magic-cookie')) {
- if (kid.substring(0, header.kid.indexOf('/')) !== payload.sub) {
+ return errors;
+ }
+
+ if (kid.substring(0, kid.indexOf('/')) !== sub) {
errors.push('- Key ID(kid) does not match sub');
}
- if (payload.aud !== 'jitsi') {
+
+ if (aud !== 'jitsi') {
errors.push('- invalid `aud` value. It should be `jitsi`');
}
- if (payload.iss !== 'chat') {
+ if (iss !== 'chat') {
errors.push('- invalid `iss` value. It should be `chat`');
}
- if (!payload.context?.features) {
+ if (!context?.features) {
errors.push('- `features` object is missing from the payload');
}
}
- if (!isValidUnixTimestamp(payload.nbf)) {
+ if (!isValidUnixTimestamp(nbf)) {
errors.push('- invalid `nbf` value');
- } else if (currentTimestamp < payload.nbf * 1000) {
+ } else if (currentTimestamp < nbf * 1000) {
errors.push('- `nbf` value is in the future');
}
- if (!isValidUnixTimestamp(payload.exp)) {
+ if (!isValidUnixTimestamp(exp)) {
errors.push('- invalid `exp` value');
- } else if (currentTimestamp > payload.exp * 1000) {
+ } else if (currentTimestamp > exp * 1000) {
errors.push('- token is expired');
}
- if (!payload.context) {
+ if (!context) {
errors.push('- `context` object is missing from the payload');
- } else if (payload.context.features) {
- const { features } = payload.context;
+ } else if (context.features) {
+ const { features } = context;
Object.keys(features).forEach(feature => {
if (MEET_FEATURES.includes(feature)) {