Skip to content

Commit 3f010a5

Browse files
TimsheltessusBlackDex
authored
Change OIDC dummy identifier (#6263)
* Change OIDC dummy identifier * Update src/sso.rs Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx> * Use Org uuid as identifier --------- Co-authored-by: Helmut K. C. Tessarek <tessarek@evermeet.cx> Co-authored-by: Mathijs van Veluw <black.dex@gmail.com>
1 parent e83faad commit 3f010a5

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/api/core/accounts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ async fn post_set_password(data: Json<SetPasswordData>, headers: Headers, mut co
367367

368368
if let Some(identifier) = data.org_identifier {
369369
if identifier != crate::sso::FAKE_IDENTIFIER {
370-
let org = match Organization::find_by_name(&identifier, &mut conn).await {
370+
let org = match Organization::find_by_uuid(&identifier.into(), &mut conn).await {
371371
None => err!("Failed to retrieve the associated organization"),
372372
Some(org) => org,
373373
};

src/api/core/organizations.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ async fn get_user_collections(headers: Headers, mut conn: DbConn) -> Json<Value>
339339
}
340340

341341
// Called during the SSO enrollment
342-
// The `identifier` should be the value returned by `get_org_domain_sso_details`
342+
// The `identifier` should be the value returned by `get_org_domain_sso_verified`
343343
// The returned `Id` will then be passed to `get_master_password_policy` which will mainly ignore it
344344
#[get("/organizations/<identifier>/auto-enroll-status")]
345345
async fn get_auto_enroll_status(identifier: &str, headers: Headers, mut conn: DbConn) -> JsonResult {
@@ -349,7 +349,7 @@ async fn get_auto_enroll_status(identifier: &str, headers: Headers, mut conn: Db
349349
None => None,
350350
}
351351
} else {
352-
Organization::find_by_name(identifier, &mut conn).await
352+
Organization::find_by_uuid(&identifier.into(), &mut conn).await
353353
};
354354

355355
let (id, identifier, rp_auto_enroll) = match org {
@@ -977,17 +977,17 @@ async fn get_org_domain_sso_verified(data: Json<OrgDomainDetails>, mut conn: DbC
977977
let identifiers = match Organization::find_org_user_email(&data.email, &mut conn)
978978
.await
979979
.into_iter()
980-
.map(|o| o.name)
981-
.collect::<Vec<String>>()
980+
.map(|o| (o.name, o.uuid.to_string()))
981+
.collect::<Vec<(String, String)>>()
982982
{
983983
v if !v.is_empty() => v,
984-
_ => vec![crate::sso::FAKE_IDENTIFIER.to_string()],
984+
_ => vec![(crate::sso::FAKE_IDENTIFIER.to_string(), crate::sso::FAKE_IDENTIFIER.to_string())],
985985
};
986986

987987
Ok(Json(json!({
988988
"object": "list",
989-
"data": identifiers.into_iter().map(|identifier| json!({
990-
"organizationName": identifier, // appear unused
989+
"data": identifiers.into_iter().map(|(name, identifier)| json!({
990+
"organizationName": name, // appear unused
991991
"organizationIdentifier": identifier,
992992
"domainName": CONFIG.domain(), // appear unused
993993
})).collect::<Vec<Value>>()

src/sso.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
CONFIG,
2020
};
2121

22-
pub static FAKE_IDENTIFIER: &str = "Vaultwarden";
22+
pub static FAKE_IDENTIFIER: &str = "VW_DUMMY_IDENTIFIER_FOR_OIDC";
2323

2424
static AC_CACHE: Lazy<Cache<OIDCState, AuthenticatedUser>> =
2525
Lazy::new(|| Cache::builder().max_capacity(1000).time_to_live(Duration::from_secs(10 * 60)).build());

0 commit comments

Comments
 (0)