Skip to content

Commit

Permalink
fix: correct assertion for get_token
Browse files Browse the repository at this point in the history
Co-authored-by: Tommy Trøen <[email protected]>
Co-authored-by: Kim Tore Jensen <[email protected]>
  • Loading branch information
3 people committed Nov 4, 2024
1 parent 0fc48ff commit c2266b4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/identity_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use axum::response::IntoResponse;
use log::error;
use reqwest::StatusCode;
use crate::handlers::{ApiError, HandlerState};
use crate::types::{TokenRequest, TokenResponse};
use crate::types::{IdentityProvider, TokenRequest, TokenResponse};

pub trait TokenRequestFactory {
fn token_request(config: TokenRequestConfig) -> Option<Self>
Expand Down Expand Up @@ -189,7 +189,11 @@ where
_state: HandlerState,
request: TokenRequest,
) -> Result<impl IntoResponse, ApiError> {
let assertion = self.create_assertion(AssertionClaimType::WithScope(request.target.clone())).unwrap();
let assertion = match request.identity_provider {
IdentityProvider::AzureAD => self.create_assertion(AssertionClaimType::WithSub(self.client_id.clone())).unwrap(),
IdentityProvider::TokenX => self.create_assertion(AssertionClaimType::WithScope(self.client_id.clone())).unwrap(),
IdentityProvider::Maskinporten => self.create_assertion(AssertionClaimType::WithScope(request.target.clone())).unwrap()
};

let params = T::token_request(TokenRequestConfig {
target: request.target,
Expand Down

0 comments on commit c2266b4

Please sign in to comment.