Return OIDC errors instead of "failed to decode token"
This commit is contained in:
@@ -14,6 +14,7 @@ If you are upgrading from v0.16.x, replace the binary (or run `docker pull`). If
|
||||
## Fixed
|
||||
- Directory:
|
||||
- Invalidate caches when group memberships change on an external directory.
|
||||
- Return OIDC errors instead of "failed to decode token".
|
||||
- User impersonation.
|
||||
- Log viewer: All events show as `INFO`.
|
||||
- Registry: Allow changing object variants.
|
||||
|
||||
@@ -331,6 +331,9 @@ impl Server {
|
||||
} else {
|
||||
self.get_default_directory()
|
||||
};
|
||||
|
||||
// Try external directory authentication first if supported, then fallback to internal OAuth.
|
||||
let mut external_error = None;
|
||||
if let Some(directory) = directory
|
||||
&& directory.has_bearer_token_support()
|
||||
{
|
||||
@@ -341,18 +344,30 @@ impl Server {
|
||||
Err(err) => {
|
||||
if !err.matches(trc::EventType::Auth(trc::AuthEvent::Failed)) {
|
||||
return Err(err);
|
||||
} else {
|
||||
external_error = Some(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Internal OAuth
|
||||
let token_info = self
|
||||
match self
|
||||
.validate_access_token(GrantType::AccessToken.into(), token)
|
||||
.await?;
|
||||
self.access_token(token_info.account_id)
|
||||
.await
|
||||
.and_then(|token| AccessToken::new(token, req.remote_ip))
|
||||
{
|
||||
Ok(token_info) => self
|
||||
.access_token(token_info.account_id)
|
||||
.await
|
||||
.and_then(|token| AccessToken::new(token, req.remote_ip)),
|
||||
Err(err) => {
|
||||
if let Some(external_error) = external_error {
|
||||
Err(external_error)
|
||||
} else {
|
||||
Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user