use crate::{
AccessToken, AdditionalClaims, AdditionalProviderMetadata, AuthDisplay, AuthPrompt, AuthType,
AuthUrl, AuthenticationFlow, AuthorizationCode, AuthorizationRequest, ClaimName, ClaimType,
ClientAuthMethod, ClientCredentialsTokenRequest, ClientId, ClientSecret, CodeTokenRequest,
ConfigurationError, CsrfToken, DeviceAccessTokenRequest, DeviceAuthorizationRequest,
DeviceAuthorizationResponse, DeviceAuthorizationUrl, EndpointMaybeSet, EndpointNotSet,
EndpointSet, EndpointState, ErrorResponse, ExtraDeviceAuthorizationFields, GenderClaim,
GrantType, IdTokenVerifier, IntrospectionRequest, IntrospectionUrl, IssuerUrl, JsonWebKey,
JsonWebKeySet, JweContentEncryptionAlgorithm, JweKeyManagementAlgorithm, JwsSigningAlgorithm,
Nonce, PasswordTokenRequest, ProviderMetadata, RedirectUrl, RefreshToken, RefreshTokenRequest,
ResourceOwnerPassword, ResourceOwnerUsername, ResponseMode, ResponseType, RevocableToken,
RevocationRequest, RevocationUrl, Scope, SubjectIdentifier, SubjectIdentifierType,
TokenIntrospectionResponse, TokenResponse, TokenUrl, UserInfoRequest, UserInfoUrl,
};
use std::marker::PhantomData;
const OPENID_SCOPE: &str = "openid";
#[derive(Clone, Debug)]
pub struct Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
> where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse,
HasAuthUrl: EndpointState,
HasDeviceAuthUrl: EndpointState,
HasIntrospectionUrl: EndpointState,
HasRevocationUrl: EndpointState,
HasTokenUrl: EndpointState,
HasUserInfoUrl: EndpointState,
{
oauth2_client: oauth2::Client<
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
>,
pub(crate) client_id: ClientId,
client_secret: Option<ClientSecret>,
pub(crate) issuer: IssuerUrl,
userinfo_endpoint: Option<UserInfoUrl>,
pub(crate) jwks: JsonWebKeySet<K>,
id_token_signing_algs: Option<Vec<K::SigningAlgorithm>>,
use_openid_scope: bool,
_phantom: PhantomData<(AC, AD, GC, JE, P, HasUserInfoUrl)>,
}
impl<AC, AD, GC, JE, K, P, TE, TR, TIR, RT, TRE>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
EndpointNotSet,
EndpointNotSet,
EndpointNotSet,
EndpointNotSet,
EndpointNotSet,
EndpointNotSet,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
{
pub fn new(client_id: ClientId, issuer: IssuerUrl, jwks: JsonWebKeySet<K>) -> Self {
Client {
oauth2_client: oauth2::Client::new(client_id.clone()),
client_id,
client_secret: None,
issuer,
userinfo_endpoint: None,
jwks,
id_token_signing_algs: None,
use_openid_scope: true,
_phantom: PhantomData,
}
}
}
impl<AC, AD, GC, JE, K, P, TE, TR, TIR, RT, TRE>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
EndpointSet,
EndpointNotSet,
EndpointNotSet,
EndpointNotSet,
EndpointMaybeSet,
EndpointMaybeSet,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
{
pub fn from_provider_metadata<A, CA, CN, CT, G, JK, RM, RS, S>(
provider_metadata: ProviderMetadata<A, AD, CA, CN, CT, G, JE, JK, K, RM, RS, S>,
client_id: ClientId,
client_secret: Option<ClientSecret>,
) -> Self
where
A: AdditionalProviderMetadata,
CA: ClientAuthMethod,
CN: ClaimName,
CT: ClaimType,
G: GrantType,
JK: JweKeyManagementAlgorithm,
RM: ResponseMode,
RS: ResponseType,
S: SubjectIdentifierType,
{
let mut oauth2_client = oauth2::Client::new(client_id.clone())
.set_auth_uri(provider_metadata.authorization_endpoint().clone())
.set_token_uri_option(provider_metadata.token_endpoint().cloned());
if let Some(ref client_secret) = client_secret {
oauth2_client = oauth2_client.set_client_secret(client_secret.to_owned());
}
Client {
oauth2_client,
client_id,
client_secret,
issuer: provider_metadata.issuer().clone(),
userinfo_endpoint: provider_metadata.userinfo_endpoint().cloned(),
jwks: provider_metadata.jwks().to_owned(),
id_token_signing_algs: Some(
provider_metadata
.id_token_signing_alg_values_supported()
.to_owned(),
),
use_openid_scope: true,
_phantom: PhantomData,
}
}
}
impl<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
HasAuthUrl: EndpointState,
HasDeviceAuthUrl: EndpointState,
HasIntrospectionUrl: EndpointState,
HasRevocationUrl: EndpointState,
HasTokenUrl: EndpointState,
HasUserInfoUrl: EndpointState,
{
pub fn set_auth_type(mut self, auth_type: AuthType) -> Self {
self.oauth2_client = self.oauth2_client.set_auth_type(auth_type);
self
}
pub fn auth_type(&self) -> &AuthType {
self.oauth2_client.auth_type()
}
pub fn set_auth_uri(
self,
auth_uri: AuthUrl,
) -> Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
EndpointSet,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
> {
Client {
oauth2_client: self.oauth2_client.set_auth_uri(auth_uri),
client_id: self.client_id,
client_secret: self.client_secret,
issuer: self.issuer,
userinfo_endpoint: self.userinfo_endpoint,
jwks: self.jwks,
id_token_signing_algs: self.id_token_signing_algs,
use_openid_scope: self.use_openid_scope,
_phantom: PhantomData,
}
}
pub fn client_id(&self) -> &ClientId {
&self.client_id
}
pub fn set_client_secret(mut self, client_secret: ClientSecret) -> Self {
self.oauth2_client = self.oauth2_client.set_client_secret(client_secret.clone());
self.client_secret = Some(client_secret);
self
}
pub fn set_device_authorization_url(
self,
device_authorization_url: DeviceAuthorizationUrl,
) -> Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
EndpointSet,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
> {
Client {
oauth2_client: self
.oauth2_client
.set_device_authorization_url(device_authorization_url),
client_id: self.client_id,
client_secret: self.client_secret,
issuer: self.issuer,
userinfo_endpoint: self.userinfo_endpoint,
jwks: self.jwks,
id_token_signing_algs: self.id_token_signing_algs,
use_openid_scope: self.use_openid_scope,
_phantom: PhantomData,
}
}
pub fn set_introspection_url(
self,
introspection_url: IntrospectionUrl,
) -> Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
EndpointSet,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
> {
Client {
oauth2_client: self.oauth2_client.set_introspection_url(introspection_url),
client_id: self.client_id,
client_secret: self.client_secret,
issuer: self.issuer,
userinfo_endpoint: self.userinfo_endpoint,
jwks: self.jwks,
id_token_signing_algs: self.id_token_signing_algs,
use_openid_scope: self.use_openid_scope,
_phantom: PhantomData,
}
}
pub fn set_redirect_uri(mut self, redirect_url: RedirectUrl) -> Self {
self.oauth2_client = self.oauth2_client.set_redirect_uri(redirect_url);
self
}
pub fn redirect_uri(&self) -> Option<&RedirectUrl> {
self.oauth2_client.redirect_uri()
}
pub fn set_revocation_url(
self,
revocation_uri: RevocationUrl,
) -> Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
EndpointSet,
HasTokenUrl,
HasUserInfoUrl,
> {
Client {
oauth2_client: self.oauth2_client.set_revocation_url(revocation_uri),
client_id: self.client_id,
client_secret: self.client_secret,
issuer: self.issuer,
userinfo_endpoint: self.userinfo_endpoint,
jwks: self.jwks,
id_token_signing_algs: self.id_token_signing_algs,
use_openid_scope: self.use_openid_scope,
_phantom: PhantomData,
}
}
pub fn set_token_uri(
self,
token_uri: TokenUrl,
) -> Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
EndpointSet,
HasUserInfoUrl,
> {
Client {
oauth2_client: self.oauth2_client.set_token_uri(token_uri),
client_id: self.client_id,
client_secret: self.client_secret,
issuer: self.issuer,
userinfo_endpoint: self.userinfo_endpoint,
jwks: self.jwks,
id_token_signing_algs: self.id_token_signing_algs,
use_openid_scope: self.use_openid_scope,
_phantom: PhantomData,
}
}
pub fn set_user_info_url(
self,
userinfo_endpoint: UserInfoUrl,
) -> Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
EndpointSet,
> {
Client {
oauth2_client: self.oauth2_client,
client_id: self.client_id,
client_secret: self.client_secret,
issuer: self.issuer,
userinfo_endpoint: Some(userinfo_endpoint),
jwks: self.jwks,
id_token_signing_algs: self.id_token_signing_algs,
use_openid_scope: self.use_openid_scope,
_phantom: PhantomData,
}
}
pub fn enable_openid_scope(mut self) -> Self {
self.use_openid_scope = true;
self
}
pub fn disable_openid_scope(mut self) -> Self {
self.use_openid_scope = false;
self
}
pub fn id_token_verifier(&self) -> IdTokenVerifier<'_, K> {
let verifier = if let Some(ref client_secret) = self.client_secret {
IdTokenVerifier::new_confidential_client(
self.client_id.clone(),
client_secret.clone(),
self.issuer.clone(),
self.jwks.clone(),
)
} else {
IdTokenVerifier::new_public_client(
self.client_id.clone(),
self.issuer.clone(),
self.jwks.clone(),
)
};
if let Some(id_token_signing_algs) = self.id_token_signing_algs.clone() {
verifier.set_allowed_algs(id_token_signing_algs)
} else {
verifier
}
}
}
impl<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
EndpointSet,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
HasDeviceAuthUrl: EndpointState,
HasIntrospectionUrl: EndpointState,
HasRevocationUrl: EndpointState,
HasTokenUrl: EndpointState,
HasUserInfoUrl: EndpointState,
{
pub fn auth_uri(&self) -> &AuthUrl {
self.oauth2_client.auth_uri()
}
pub fn authorize_url<NF, RS, SF>(
&self,
authentication_flow: AuthenticationFlow<RS>,
state_fn: SF,
nonce_fn: NF,
) -> AuthorizationRequest<'_, AD, P, RS>
where
NF: FnOnce() -> Nonce + 'static,
RS: ResponseType,
SF: FnOnce() -> CsrfToken + 'static,
{
let request = AuthorizationRequest {
inner: self.oauth2_client.authorize_url(state_fn),
acr_values: Vec::new(),
authentication_flow,
claims_locales: Vec::new(),
display: None,
id_token_hint: None,
login_hint: None,
max_age: None,
nonce: nonce_fn(),
prompts: Vec::new(),
ui_locales: Vec::new(),
};
if self.use_openid_scope {
request.add_scope(Scope::new(OPENID_SCOPE.to_string()))
} else {
request
}
}
}
impl<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasUserInfoUrl,
>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
EndpointSet,
HasUserInfoUrl,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
HasAuthUrl: EndpointState,
HasDeviceAuthUrl: EndpointState,
HasIntrospectionUrl: EndpointState,
HasRevocationUrl: EndpointState,
HasUserInfoUrl: EndpointState,
{
pub fn exchange_client_credentials(&self) -> ClientCredentialsTokenRequest<'_, TE, TR> {
self.oauth2_client.exchange_client_credentials()
}
pub fn exchange_code(&self, code: AuthorizationCode) -> CodeTokenRequest<'_, TE, TR> {
self.oauth2_client.exchange_code(code)
}
pub fn exchange_device_access_token<'a, EF>(
&'a self,
auth_response: &'a DeviceAuthorizationResponse<EF>,
) -> DeviceAccessTokenRequest<'a, 'static, TR, EF>
where
EF: ExtraDeviceAuthorizationFields,
{
self.oauth2_client
.exchange_device_access_token(auth_response)
}
pub fn exchange_password<'a>(
&'a self,
username: &'a ResourceOwnerUsername,
password: &'a ResourceOwnerPassword,
) -> PasswordTokenRequest<'a, TE, TR> {
self.oauth2_client.exchange_password(username, password)
}
pub fn exchange_refresh_token<'a>(
&'a self,
refresh_token: &'a RefreshToken,
) -> RefreshTokenRequest<'a, TE, TR> {
self.oauth2_client.exchange_refresh_token(refresh_token)
}
pub fn token_uri(&self) -> &TokenUrl {
self.oauth2_client.token_uri()
}
}
impl<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasUserInfoUrl,
>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
EndpointMaybeSet,
HasUserInfoUrl,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
HasAuthUrl: EndpointState,
HasDeviceAuthUrl: EndpointState,
HasIntrospectionUrl: EndpointState,
HasRevocationUrl: EndpointState,
HasUserInfoUrl: EndpointState,
{
pub fn exchange_client_credentials(
&self,
) -> Result<ClientCredentialsTokenRequest<'_, TE, TR>, ConfigurationError> {
self.oauth2_client.exchange_client_credentials()
}
pub fn exchange_code(
&self,
code: AuthorizationCode,
) -> Result<CodeTokenRequest<'_, TE, TR>, ConfigurationError> {
self.oauth2_client.exchange_code(code)
}
pub fn exchange_device_access_token<'a, EF>(
&'a self,
auth_response: &'a DeviceAuthorizationResponse<EF>,
) -> Result<DeviceAccessTokenRequest<'a, 'static, TR, EF>, ConfigurationError>
where
EF: ExtraDeviceAuthorizationFields,
{
self.oauth2_client
.exchange_device_access_token(auth_response)
}
pub fn exchange_password<'a>(
&'a self,
username: &'a ResourceOwnerUsername,
password: &'a ResourceOwnerPassword,
) -> Result<PasswordTokenRequest<'a, TE, TR>, ConfigurationError> {
self.oauth2_client.exchange_password(username, password)
}
pub fn exchange_refresh_token<'a>(
&'a self,
refresh_token: &'a RefreshToken,
) -> Result<RefreshTokenRequest<'a, TE, TR>, ConfigurationError> {
self.oauth2_client.exchange_refresh_token(refresh_token)
}
pub fn token_uri(&self) -> Option<&TokenUrl> {
self.oauth2_client.token_uri()
}
}
impl<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
EndpointSet,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
HasAuthUrl: EndpointState,
HasIntrospectionUrl: EndpointState,
HasRevocationUrl: EndpointState,
HasTokenUrl: EndpointState,
HasUserInfoUrl: EndpointState,
{
pub fn exchange_device_code(&self) -> DeviceAuthorizationRequest<'_, TE> {
let request = self.oauth2_client.exchange_device_code();
if self.use_openid_scope {
request.add_scope(Scope::new(OPENID_SCOPE.to_string()))
} else {
request
}
}
pub fn device_authorization_url(&self) -> &DeviceAuthorizationUrl {
self.oauth2_client.device_authorization_url()
}
}
impl<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
EndpointSet,
HasRevocationUrl,
HasTokenUrl,
HasUserInfoUrl,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
HasAuthUrl: EndpointState,
HasDeviceAuthUrl: EndpointState,
HasRevocationUrl: EndpointState,
HasTokenUrl: EndpointState,
HasUserInfoUrl: EndpointState,
{
pub fn introspect<'a>(&'a self, token: &'a AccessToken) -> IntrospectionRequest<'a, TE, TIR> {
self.oauth2_client.introspect(token)
}
pub fn introspection_url(&self) -> &IntrospectionUrl {
self.oauth2_client.introspection_url()
}
}
impl<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasTokenUrl,
HasUserInfoUrl,
>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
EndpointSet,
HasTokenUrl,
HasUserInfoUrl,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
HasAuthUrl: EndpointState,
HasDeviceAuthUrl: EndpointState,
HasIntrospectionUrl: EndpointState,
HasTokenUrl: EndpointState,
HasUserInfoUrl: EndpointState,
{
pub fn revoke_token(
&self,
token: RT,
) -> Result<RevocationRequest<'_, RT, TRE>, ConfigurationError> {
self.oauth2_client.revoke_token(token)
}
pub fn revocation_url(&self) -> &RevocationUrl {
self.oauth2_client.revocation_url()
}
}
impl<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
EndpointSet,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
HasAuthUrl: EndpointState,
HasDeviceAuthUrl: EndpointState,
HasIntrospectionUrl: EndpointState,
HasRevocationUrl: EndpointState,
HasTokenUrl: EndpointState,
{
pub fn user_info(
&self,
access_token: AccessToken,
expected_subject: Option<SubjectIdentifier>,
) -> UserInfoRequest<'_, JE, K> {
self.user_info_impl(self.user_info_url(), access_token, expected_subject)
}
pub fn user_info_url(&self) -> &UserInfoUrl {
self.userinfo_endpoint
.as_ref()
.expect("should have user info endpoint")
}
}
impl<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
>
Client<
AC,
AD,
GC,
JE,
K,
P,
TE,
TR,
TIR,
RT,
TRE,
HasAuthUrl,
HasDeviceAuthUrl,
HasIntrospectionUrl,
HasRevocationUrl,
HasTokenUrl,
EndpointMaybeSet,
>
where
AC: AdditionalClaims,
AD: AuthDisplay,
GC: GenderClaim,
JE: JweContentEncryptionAlgorithm<
KeyType = <K::SigningAlgorithm as JwsSigningAlgorithm>::KeyType,
>,
K: JsonWebKey,
P: AuthPrompt,
TE: ErrorResponse + 'static,
TR: TokenResponse<AC, GC, JE, K::SigningAlgorithm>,
TIR: TokenIntrospectionResponse,
RT: RevocableToken,
TRE: ErrorResponse + 'static,
HasAuthUrl: EndpointState,
HasDeviceAuthUrl: EndpointState,
HasIntrospectionUrl: EndpointState,
HasRevocationUrl: EndpointState,
HasTokenUrl: EndpointState,
{
pub fn user_info(
&self,
access_token: AccessToken,
expected_subject: Option<SubjectIdentifier>,
) -> Result<UserInfoRequest<'_, JE, K>, ConfigurationError> {
Ok(self.user_info_impl(
self.userinfo_endpoint
.as_ref()
.ok_or(ConfigurationError::MissingUrl("user info"))?,
access_token,
expected_subject,
))
}
pub fn user_info_url(&self) -> Option<&UserInfoUrl> {
self.userinfo_endpoint.as_ref()
}
}