diff --git a/src/handlers.rs b/src/handlers.rs index 6560880..18e911b 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -58,24 +58,9 @@ pub async fn introspect( let identity_provider = token_data.claims.identity_provider(state.cfg); let claims = match identity_provider { - Some(IdentityProvider::Maskinporten) => state - .maskinporten - .write() - .await - .introspect(request.token) - .await, - Some(IdentityProvider::AzureAD) => state - .azure_ad_obo - .write() - .await - .introspect(request.token) - .await, - Some(IdentityProvider::TokenX) => state - .token_x - .write() - .await - .introspect(request.token) - .await, + Some(IdentityProvider::Maskinporten) => state.maskinporten.write().await.introspect(request.token).await, + Some(IdentityProvider::AzureAD) => state.azure_ad_obo.write().await.introspect(request.token).await, + Some(IdentityProvider::TokenX) => state.token_x.write().await.introspect(request.token).await, None => panic!("Unknown issuer: {}", token_data.claims.iss), }; diff --git a/src/jwks.rs b/src/jwks.rs index baa5619..1cc6a04 100644 --- a/src/jwks.rs +++ b/src/jwks.rs @@ -1,4 +1,3 @@ -use crate::jwks::Error::{InvalidToken, KeyNotInJWKS}; use jsonwebkey as jwk; use jsonwebtoken as jwt; use serde::Deserialize; @@ -78,7 +77,7 @@ impl Jwks { let signing_key = match self.keys.get(&key_id) { None => { self.refresh().await?; - self.keys.get(&key_id).ok_or(KeyNotInJWKS)? + self.keys.get(&key_id).ok_or(Error::KeyNotInJWKS)? } Some(key) => key, }; @@ -88,7 +87,7 @@ impl Jwks { &signing_key.key.to_decoding_key(), &validation, ) - .map_err(InvalidToken)? + .map_err(Error::InvalidToken)? .claims) } }