Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 92a1801

Browse files
committed
Added option to disable access token hash verification
1 parent 7c661b4 commit 92a1801

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ services:
5959
# space seperated list of allowed actions (OPTIONAL), see
6060
# https://github.com/MarcelCoding/jitsi-openid/issues/122
6161
# - 'SCOPES=openid email jitsi' # <- OpenID Scopes, space seperated list of scopes (OPTIONAL),
62-
# default: openid email
62+
# default: openid email
63+
# - 'VERIFY_ACCESS_TOKEN_HASH=false # <- explicitly disable access token hash verification (OPTIONAL),
64+
# default: true
6365
ports:
6466
- '3000:3000'
6567

src/cfg.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub(crate) struct Cfg {
2525
#[serde(default)]
2626
#[serde(deserialize_with = "string_array2")]
2727
pub(crate) scopes: Option<Vec<String>>,
28+
#[serde(default)]
29+
pub(crate) verify_access_token_hash: Option<bool>,
2830
}
2931

3032
fn default_listen_addr() -> SocketAddr {

src/routes.rs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -196,31 +196,33 @@ fn id_token_claims(
196196
}
197197
}
198198

199-
match claims.access_token_hash() {
200-
Some(expected_access_token_hash) => {
201-
let algorithm = id_token.signing_alg().map_err(|err| {
202-
warn!(
203-
"Authentication failed, UnsupportedSigningAlgorithm: {:?}",
204-
err
205-
);
206-
UnsupportedSigningAlgorithm
207-
})?;
208-
209-
let actual_access_token_hash =
210-
AccessTokenHash::from_token(response.access_token(), &algorithm).map_err(|err| {
199+
if config.verify_access_token_hash.unwrap_or(true) {
200+
match claims.access_token_hash() {
201+
Some(expected_access_token_hash) => {
202+
let algorithm = id_token.signing_alg().map_err(|err| {
211203
warn!(
212204
"Authentication failed, UnsupportedSigningAlgorithm: {:?}",
213205
err
214206
);
215207
UnsupportedSigningAlgorithm
216208
})?;
217209

218-
if &actual_access_token_hash != expected_access_token_hash {
219-
return Err(InvalidAccessToken);
210+
let actual_access_token_hash =
211+
AccessTokenHash::from_token(response.access_token(), &algorithm).map_err(|err| {
212+
warn!(
213+
"Authentication failed, UnsupportedSigningAlgorithm: {:?}",
214+
err
215+
);
216+
UnsupportedSigningAlgorithm
217+
})?;
218+
219+
if &actual_access_token_hash != expected_access_token_hash {
220+
return Err(InvalidAccessToken);
221+
}
220222
}
221-
}
222-
None => return Err(MissingAccessTokenHash),
223-
};
223+
None => return Err(MissingAccessTokenHash),
224+
};
225+
}
224226

225227
let uid = match claims.preferred_username() {
226228
Some(name) => name.to_string(),

0 commit comments

Comments
 (0)