Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user dropping from NSS #122

Merged
merged 1 commit into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions src/common/src/idprovider/himmelblau.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,15 @@ impl IdProvider for HimmelblauProvider {
) -> Result<UserToken, IdpError> {
/* Use the prt mem cache to refresh the user token */
let account_id = id.to_string().clone();
let prt = self.refresh_cache.refresh_token(&account_id).await?;
let prt = match self.refresh_cache.refresh_token(&account_id).await {
Ok(prt) => prt,
Err(_) => {
debug!("Unable to refresh user via PRT cache");
// Never return IdpError::NotFound. This deletes the existing
// user from the cache.
return Err(IdpError::BadRequest);
}
};
let scopes = vec!["GroupMember.Read.All"];
let token = match self
.client
Expand All @@ -506,13 +514,25 @@ impl IdProvider for HimmelblauProvider {
.await
{
Ok(token) => token,
Err(_e) => return Err(IdpError::NotFound),
Err(e) => {
error!("{:?}", e);
// Never return IdpError::NotFound. This deletes
// the existing user from the cache.
return Err(IdpError::BadRequest);
}
}
} else {
return Err(IdpError::NotFound);
// Never return IdpError::NotFound. This deletes the
// existing user from the cache.
return Err(IdpError::BadRequest);
}
}
Err(_e) => return Err(IdpError::NotFound),
Err(e) => {
error!("{:?}", e);
// Never return IdpError::NotFound. This deletes the existing
// user from the cache.
return Err(IdpError::BadRequest);
}
};
match self.token_validate(&account_id, &token).await {
Ok(AuthResult::Success { mut token }) => {
Expand All @@ -524,8 +544,10 @@ impl IdProvider for HimmelblauProvider {
}
Ok(token)
}
Ok(AuthResult::Denied) | Ok(AuthResult::Next(_)) => Err(IdpError::NotFound),
Err(e) => Err(e),
// Never return IdpError::NotFound. This deletes the existing
// user from the cache.
Ok(AuthResult::Denied) | Ok(AuthResult::Next(_)) => Err(IdpError::BadRequest),
Err(_) => Err(IdpError::BadRequest),
}
}

Expand Down