fix: refactor config

This commit is contained in:
2024-12-31 23:56:00 +08:00
parent abd399aacd
commit 393f704e52
56 changed files with 274 additions and 536 deletions

View File

@@ -93,7 +93,7 @@ impl AuthService for OidcAuthService {
let token_data = self.authorizer.check_auth(&token).await?;
let claims = token_data.claims;
if !claims.sub.as_deref().is_some_and(|s| !s.trim().is_empty()) {
if claims.sub.as_deref().is_none_or(|s| s.trim().is_empty()) {
return Err(AuthError::OidcSubMissingError);
}
if !claims.contains_audience(&config.audience) {
@@ -103,7 +103,7 @@ impl AuthService for OidcAuthService {
let found_scopes = claims.scopes().collect::<HashSet<_>>();
if !expected_scopes
.iter()
.all(|es| found_scopes.contains(&es as &str))
.all(|es| found_scopes.contains(es as &str))
{
return Err(AuthError::OidcExtraScopesMatchError {
expected: expected_scopes.iter().join(","),

View File

@@ -107,7 +107,7 @@ impl Initializer for AppAuthServiceInitializer {
let service = AppAuthService::from_conf(auth_conf)
.await
.map_err(|e| loco_rs::Error::wrap(e))?;
.map_err(loco_rs::Error::wrap)?;
APP_AUTH_SERVICE.get_or_init(|| service);