From 890a901441035732028232337553bd620de00a9c Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 3 Sep 2024 14:53:49 +0100 Subject: [PATCH] Remove unnecessary trait bound on AuthorizationRequest --- src/authorization.rs | 20 +++++--------------- src/client.rs | 10 ++++------ src/pushed_authorization.rs | 21 +++++++-------------- 3 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/authorization.rs b/src/authorization.rs index a2d3864..eccbe03 100644 --- a/src/authorization.rs +++ b/src/authorization.rs @@ -1,4 +1,4 @@ -use std::{borrow::Cow, marker::PhantomData}; +use std::borrow::Cow; use oauth2::{CsrfToken, PkceCodeChallenge}; use serde::{Deserialize, Serialize}; @@ -9,25 +9,15 @@ use crate::{ types::{IssuerState, IssuerUrl, UserHint}, }; -pub struct AuthorizationRequest<'a, AD> -where - AD: AuthorizationDetailsProfile, -{ +pub struct AuthorizationRequest<'a> { inner: oauth2::AuthorizationRequest<'a>, - _pd: PhantomData, } // TODO 5.1.2 scopes -impl<'a, AD> AuthorizationRequest<'a, AD> -where - AD: AuthorizationDetailsProfile, -{ +impl<'a> AuthorizationRequest<'a> { pub(crate) fn new(inner: oauth2::AuthorizationRequest<'a>) -> Self { - Self { - inner, - _pd: PhantomData, - } + Self { inner } } pub fn url(self) -> (Url, CsrfToken) { @@ -39,7 +29,7 @@ where self } - pub fn set_authorization_details( + pub fn set_authorization_details( mut self, authorization_details: Vec>, ) -> Result { diff --git a/src/client.rs b/src/client.rs index 55c5ee4..31fe1ce 100644 --- a/src/client.rs +++ b/src/client.rs @@ -13,7 +13,7 @@ use crate::{ credential_issuer::{CredentialIssuerMetadataDisplay, CredentialMetadata}, AuthorizationServerMetadata, CredentialIssuerMetadata, }, - profiles::{AuthorizationDetailsProfile, Profile}, + profiles::Profile, pushed_authorization::PushedAuthorizationRequest, token, types::{BatchCredentialUrl, CredentialUrl, DeferredCredentialUrl, IssuerUrl, ParUrl}, @@ -117,13 +117,12 @@ where } } - pub fn pushed_authorization_request( + pub fn pushed_authorization_request( &self, state_fn: S, - ) -> Result, Error> + ) -> Result where S: FnOnce() -> CsrfToken, - AD: AuthorizationDetailsProfile, { let Some(par_url) = self.par_auth_url.as_ref() else { return Err(Error::ParUnsupported); @@ -141,10 +140,9 @@ where )) } - pub fn authorize_url(&self, state_fn: S) -> Result, Error> + pub fn authorize_url(&self, state_fn: S) -> Result where S: FnOnce() -> CsrfToken, - AD: AuthorizationDetailsProfile, { let inner = self .inner diff --git a/src/pushed_authorization.rs b/src/pushed_authorization.rs index 36ca737..a76a3df 100644 --- a/src/pushed_authorization.rs +++ b/src/pushed_authorization.rs @@ -65,21 +65,15 @@ pub struct PushedAuthorizationResponse { pub expires_in: u64, } -pub struct PushedAuthorizationRequest<'a, AD> -where - AD: AuthorizationDetailsProfile, -{ - inner: AuthorizationRequest<'a, AD>, +pub struct PushedAuthorizationRequest<'a> { + inner: AuthorizationRequest<'a>, par_auth_url: ParUrl, auth_url: AuthUrl, } -impl<'a, AD> PushedAuthorizationRequest<'a, AD> -where - AD: AuthorizationDetailsProfile, -{ +impl<'a> PushedAuthorizationRequest<'a> { pub(crate) fn new( - inner: AuthorizationRequest<'a, AD>, + inner: AuthorizationRequest<'a>, par_auth_url: ParUrl, auth_url: AuthUrl, ) -> Self { @@ -129,7 +123,6 @@ where where 'a: 'c, C: AsyncHttpClient<'c>, - AD: 'c, { Box::pin(async move { let mut auth_url = self.auth_url.url().clone(); @@ -221,7 +214,7 @@ where self } - pub fn set_authorization_details( + pub fn set_authorization_details( mut self, authorization_details: Vec>, ) -> Result { @@ -321,10 +314,10 @@ mod test { let state = CsrfToken::new("state".into()); let (_, body, _) = client - .pushed_authorization_request::<_, CoreProfilesAuthorizationDetails>(move || state) + .pushed_authorization_request(move || state) .unwrap() .set_pkce_challenge(pkce_challenge) - .set_authorization_details(vec![]) + .set_authorization_details::(vec![]) .unwrap() .prepare_request() .unwrap();