Skip to content

Commit

Permalink
Small cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
kimtore committed Nov 4, 2024
1 parent 183455a commit 8391fe0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
21 changes: 3 additions & 18 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};

Expand Down
5 changes: 2 additions & 3 deletions src/jwks.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::jwks::Error::{InvalidToken, KeyNotInJWKS};
use jsonwebkey as jwk;
use jsonwebtoken as jwt;
use serde::Deserialize;
Expand Down Expand Up @@ -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,
};
Expand All @@ -88,7 +87,7 @@ impl Jwks {
&signing_key.key.to_decoding_key(),
&validation,
)
.map_err(InvalidToken)?
.map_err(Error::InvalidToken)?
.claims)
}
}

0 comments on commit 8391fe0

Please sign in to comment.