1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-31 09:24:31 +03:00

Save the application_type and the contacts in the OAuth 2.0 clients

This also removes the dedicated "redirect_uris" table and makes it a field of the "oauth2_clients" table
This commit is contained in:
Quentin Gliech
2023-08-28 12:31:17 +02:00
parent f9dabf0bbc
commit 096386e9b9
22 changed files with 312 additions and 257 deletions

View File

@ -17,7 +17,7 @@ use async_graphql::{Context, Description, Enum, Object, ID};
use chrono::{DateTime, Utc};
use mas_data_model::SessionState;
use mas_storage::{oauth2::OAuth2ClientRepository, user::BrowserSessionRepository};
use oauth2_types::scope::Scope;
use oauth2_types::{oidc::ApplicationType, scope::Scope};
use ulid::Ulid;
use url::Url;
@ -110,6 +110,16 @@ impl OAuth2Session {
}
}
/// The application type advertised by the client.
#[derive(Enum, Copy, Clone, Eq, PartialEq)]
pub enum OAuth2ApplicationType {
/// Client is a web application.
Web,
/// Client is a native application.
Native,
}
/// An OAuth 2.0 client
#[derive(Description)]
pub struct OAuth2Client(pub mas_data_model::Client);
@ -150,6 +160,19 @@ impl OAuth2Client {
pub async fn redirect_uris(&self) -> &[Url] {
&self.0.redirect_uris
}
/// List of contacts advertised by the client.
pub async fn contacts(&self) -> &[String] {
&self.0.contacts
}
/// The application type advertised by the client.
pub async fn application_type(&self) -> Option<OAuth2ApplicationType> {
match self.0.application_type? {
ApplicationType::Web => Some(OAuth2ApplicationType::Web),
ApplicationType::Native => Some(OAuth2ApplicationType::Native),
}
}
}
/// An OAuth 2.0 consent represents the scope a user consented to grant to a