Skip to content

Commit

Permalink
cleanup check for undefined token
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan0xC committed Jan 17, 2025
1 parent 3fcddd9 commit 04868cc
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/api/core/organizations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1818,19 +1818,17 @@ async fn list_policies(org_id: OrganizationId, _headers: AdminHeaders, mut conn:

#[get("/organizations/<org_id>/policies/token?<token>")]
async fn list_policies_token(org_id: OrganizationId, token: &str, mut conn: DbConn) -> JsonResult {
// web-vault 2024.6.2 seems to send these values and cause logs to output errors
// Catch this and prevent errors in the logs
// TODO: CleanUp after 2024.6.x is not used anymore.
if org_id.as_ref() == "undefined" && token == "undefined" || org_id.as_ref() == FAKE_ADMIN_UUID {
return Ok(Json(json!({})));
}

let invite = decode_invite(token)?;

if invite.org_id != org_id {
err!("Token doesn't match request organization");
}

// exit early when we have been invited via /admin panel
if org_id.as_ref() == FAKE_ADMIN_UUID {
return Ok(Json(json!({})));
}

// TODO: We receive the invite token as ?token=<>, validate it contains the org id
let policies = OrgPolicy::find_by_org(&org_id, &mut conn).await;
let policies_json: Vec<Value> = policies.iter().map(OrgPolicy::to_json).collect();
Expand Down

0 comments on commit 04868cc

Please sign in to comment.