Skip to main content

securitydept_oauth_provider/
models.rs

1use std::collections::HashMap;
2
3use openidconnect::{
4    AdditionalProviderMetadata, AuthUrl, DeviceAuthorizationUrl, IntrospectionUrl, IssuerUrl,
5    JsonWebKeySetUrl, ProviderMetadata, ResponseTypes, RevocationUrl, TokenUrl, UserInfoUrl,
6    core::{
7        CoreAuthDisplay, CoreClaimName, CoreClaimType, CoreClientAuthMethod, CoreGrantType,
8        CoreJsonWebKey, CoreJweContentEncryptionAlgorithm, CoreJweKeyManagementAlgorithm,
9        CoreJwsSigningAlgorithm, CoreResponseMode, CoreResponseType, CoreSubjectIdentifierType,
10    },
11};
12use serde::{Deserialize, Serialize};
13
14#[derive(Debug, Clone, Serialize, Deserialize, Default)]
15pub struct ExtraProviderMetadata {
16    pub introspection_endpoint: Option<String>,
17    pub revocation_endpoint: Option<String>,
18    pub device_authorization_endpoint: Option<String>,
19    #[serde(flatten)]
20    pub extra: HashMap<String, serde_json::Value>,
21}
22
23impl AdditionalProviderMetadata for ExtraProviderMetadata {}
24
25pub type ProviderMetadataWithExtra = ProviderMetadata<
26    ExtraProviderMetadata,
27    CoreAuthDisplay,
28    CoreClientAuthMethod,
29    CoreClaimName,
30    CoreClaimType,
31    CoreGrantType,
32    CoreJweContentEncryptionAlgorithm,
33    CoreJweKeyManagementAlgorithm,
34    CoreJsonWebKey,
35    CoreResponseMode,
36    CoreResponseType,
37    CoreSubjectIdentifierType,
38>;
39
40#[derive(Debug, Clone)]
41pub struct OAuthProviderMetadata {
42    pub issuer: IssuerUrl,
43    pub authorization_endpoint: Option<AuthUrl>,
44    pub token_endpoint: Option<TokenUrl>,
45    pub userinfo_endpoint: Option<UserInfoUrl>,
46    pub introspection_endpoint: Option<IntrospectionUrl>,
47    pub revocation_endpoint: Option<RevocationUrl>,
48    pub device_authorization_endpoint: Option<DeviceAuthorizationUrl>,
49    pub jwks_uri: JsonWebKeySetUrl,
50    pub jwks: openidconnect::core::CoreJsonWebKeySet,
51    pub token_endpoint_auth_methods_supported: Option<Vec<CoreClientAuthMethod>>,
52    pub response_types_supported: Vec<ResponseTypes<CoreResponseType>>,
53    pub subject_types_supported: Vec<CoreSubjectIdentifierType>,
54    pub id_token_signing_alg_values_supported: Vec<CoreJwsSigningAlgorithm>,
55    pub userinfo_signing_alg_values_supported: Option<Vec<CoreJwsSigningAlgorithm>>,
56    pub additional_metadata: ExtraProviderMetadata,
57}