Return OIDC errors instead of "failed to decode token"

This commit is contained in:
Maurus Decimus
2026-04-30 11:51:36 +02:00
parent 228d13c5c9
commit 880fa40539
2 changed files with 20 additions and 4 deletions

View File

@@ -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.

View File

@@ -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)
}
}
}
}
}
}