You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-07-28 11:02:02 +03:00
data-model: simplify the oauth2 clients
This commit is contained in:
@ -165,7 +165,7 @@ pub struct AuthorizationGrant<T: StorageBackend> {
|
||||
#[serde(flatten)]
|
||||
pub stage: AuthorizationGrantStage<T>,
|
||||
pub code: Option<AuthorizationCode>,
|
||||
pub client: Client<T>,
|
||||
pub client: Client,
|
||||
pub redirect_uri: Url,
|
||||
pub scope: oauth2_types::scope::Scope,
|
||||
pub state: Option<String>,
|
||||
@ -183,7 +183,7 @@ impl<S: StorageBackendMarker> From<AuthorizationGrant<S>> for AuthorizationGrant
|
||||
data: (),
|
||||
stage: g.stage.into(),
|
||||
code: g.code,
|
||||
client: g.client.into(),
|
||||
client: g.client,
|
||||
redirect_uri: g.redirect_uri,
|
||||
scope: g.scope,
|
||||
state: g.state,
|
||||
|
@ -20,10 +20,9 @@ use mas_jose::jwk::PublicJsonWebKeySet;
|
||||
use oauth2_types::requests::GrantType;
|
||||
use serde::Serialize;
|
||||
use thiserror::Error;
|
||||
use ulid::Ulid;
|
||||
use url::Url;
|
||||
|
||||
use crate::traits::{StorageBackend, StorageBackendMarker};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum JwksOrJwksUri {
|
||||
@ -34,11 +33,9 @@ pub enum JwksOrJwksUri {
|
||||
JwksUri(Url),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
#[serde(bound = "T: StorageBackend")]
|
||||
pub struct Client<T: StorageBackend> {
|
||||
#[serde(skip_serializing)]
|
||||
pub data: T::ClientData,
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||
pub struct Client {
|
||||
pub id: Ulid,
|
||||
|
||||
/// Client identifier
|
||||
pub client_id: String,
|
||||
@ -98,31 +95,6 @@ pub struct Client<T: StorageBackend> {
|
||||
pub initiate_login_uri: Option<Url>,
|
||||
}
|
||||
|
||||
impl<S: StorageBackendMarker> From<Client<S>> for Client<()> {
|
||||
fn from(c: Client<S>) -> Self {
|
||||
Client {
|
||||
data: (),
|
||||
client_id: c.client_id,
|
||||
encrypted_client_secret: c.encrypted_client_secret,
|
||||
redirect_uris: c.redirect_uris,
|
||||
response_types: c.response_types,
|
||||
grant_types: c.grant_types,
|
||||
contacts: c.contacts,
|
||||
client_name: c.client_name,
|
||||
logo_uri: c.logo_uri,
|
||||
client_uri: c.client_uri,
|
||||
policy_uri: c.policy_uri,
|
||||
tos_uri: c.tos_uri,
|
||||
jwks: c.jwks,
|
||||
id_token_signed_response_alg: c.id_token_signed_response_alg,
|
||||
userinfo_signed_response_alg: c.userinfo_signed_response_alg,
|
||||
token_endpoint_auth_method: c.token_endpoint_auth_method,
|
||||
token_endpoint_auth_signing_alg: c.token_endpoint_auth_signing_alg,
|
||||
initiate_login_uri: c.initiate_login_uri,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum InvalidRedirectUriError {
|
||||
#[error("redirect_uri is not allowed for this client")]
|
||||
@ -135,7 +107,7 @@ pub enum InvalidRedirectUriError {
|
||||
NoneRegistered,
|
||||
}
|
||||
|
||||
impl<S: StorageBackend> Client<S> {
|
||||
impl Client {
|
||||
pub fn resolve_redirect_uri<'a>(
|
||||
&'a self,
|
||||
redirect_uri: &'a Option<Url>,
|
||||
|
@ -27,7 +27,7 @@ pub struct Session<T: StorageBackend> {
|
||||
#[serde(skip_serializing)]
|
||||
pub data: T::SessionData,
|
||||
pub browser_session: BrowserSession,
|
||||
pub client: Client<T>,
|
||||
pub client: Client,
|
||||
pub scope: Scope,
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ impl<S: StorageBackendMarker> From<Session<S>> for Session<()> {
|
||||
Session {
|
||||
data: (),
|
||||
browser_session: s.browser_session,
|
||||
client: s.client.into(),
|
||||
client: s.client,
|
||||
scope: s.scope,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user