Skip to content

Commit

Permalink
fix: saved credentials not working
Browse files Browse the repository at this point in the history
  • Loading branch information
yuezk committed Oct 30, 2024
1 parent 54e2371 commit 516d685
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 1 addition & 5 deletions crates/gpapi/src/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,7 @@ impl Credential {
),
// Use the empty string as the password if auth_cookie is present
Credential::Cached(cred) => (
if cred.auth_cookie.is_some() {
None
} else {
cred.password()
},
cred.password(),
None,
cred.auth_cookie.as_ref().map(|c| c.user_auth_cookie()),
cred.auth_cookie.as_ref().map(|c| c.prelogon_user_auth_cookie()),
Expand Down
14 changes: 14 additions & 0 deletions crates/gpapi/src/portal/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ pub async fn retrieve_config(portal: &str, cred: &Credential, gp_params: &GpPara
let client = Client::try_from(gp_params)?;

let mut params = cred.to_params();
// Avoid sending the auth cookies for the portal config API if the password is cached
// Otherwise, the portal will return an error even if the password is correct, because
// the auth cookies could have been invalidated and the portal server takes precedence
// over the password
if let Credential::Cached(cache_cred) = cred {
info!("Using cached credentials, excluding auth cookies from the portal config request");

if cache_cred.password().is_some() {
params.remove("prelogin-cookie");
params.remove("portal-userauthcookie");
params.remove("portal-prelogonuserauthcookie");
}
}

let extra_params = gp_params.to_params();

params.extend(extra_params);
Expand Down

0 comments on commit 516d685

Please sign in to comment.