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

Commit 799d445

Browse files
committed
Pass all properties from idp provider to jitsi
1 parent 27425ca commit 799d445

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ struct Session {
4747

4848
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
4949
struct MyClaims {
50-
affiliation: Option<String>,
50+
#[serde(flatten)]
51+
other: HashMap<String, String>,
5152
}
5253

5354
impl AdditionalClaims for MyClaims {}

src/routes.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use openidconnect::{
1313
};
1414
use serde::{self, Serializer};
1515
use serde::{Deserialize, Serialize};
16+
use std::collections::HashMap;
1617
use time::{Duration, OffsetDateTime};
1718
use tracing::{error, warn};
1819
use uuid::Uuid;
@@ -240,12 +241,12 @@ fn id_token_claims(
240241
Ok(Some(JitsiUser {
241242
id: uid,
242243
email: claims.email().map(|email| email.to_string()),
243-
affiliation: claims.additional_claims().affiliation.clone(),
244244
name: get_display_name_id_token(claims),
245245
avatar: claims
246246
.picture()
247247
.and_then(|x| x.get(None))
248248
.map(|x| x.to_string()),
249+
other: claims.additional_claims().other.clone(),
249250
}))
250251
}
251252

@@ -270,12 +271,12 @@ async fn user_info_claims(
270271
None => claims.subject().to_string(),
271272
},
272273
email: claims.email().map(|email| email.to_string()),
273-
affiliation: claims.additional_claims().affiliation.clone(),
274274
name: get_display_name(&claims),
275275
avatar: claims
276276
.picture()
277277
.and_then(|x| x.get(None))
278278
.map(|x| x.to_string()),
279+
other: claims.additional_claims().other.clone(),
279280
}))
280281
}
281282
Err(ConfigurationError::MissingUrl(_)) => Ok(None),
@@ -299,6 +300,8 @@ struct JitsiClaims {
299300
iat: OffsetDateTime,
300301
#[serde(serialize_with = "jwt_numeric_date")]
301302
exp: OffsetDateTime,
303+
#[serde(flatten)]
304+
other: HashMap<String, String>,
302305
}
303306

304307
#[derive(Serialize)]
@@ -311,9 +314,10 @@ struct JitsiContext {
311314
struct JitsiUser {
312315
id: String,
313316
email: Option<String>,
314-
affiliation: Option<String>,
315317
name: Option<String>,
316318
avatar: Option<String>,
319+
#[serde(flatten)]
320+
other: HashMap<String, String>,
317321
}
318322

319323
fn create_jitsi_jwt(
@@ -328,13 +332,12 @@ fn create_jitsi_jwt(
328332
let iat = OffsetDateTime::now_utc();
329333
let exp = iat + Duration::days(1);
330334

331-
let context = JitsiContext {
332-
user,
333-
group: Some(group),
334-
};
335-
336335
let claims = JitsiClaims {
337-
context,
336+
other: user.other.clone(),
337+
context: JitsiContext {
338+
user,
339+
group: Some(group),
340+
},
338341
aud,
339342
iss,
340343
sub,

0 commit comments

Comments
 (0)