1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-06 06:02:40 +03:00

Implement the device code authorisation request

This commit is contained in:
Quentin Gliech
2023-12-07 17:59:35 +01:00
parent 286fc57103
commit 50654d2e40
8 changed files with 256 additions and 8 deletions

View File

@@ -695,6 +695,13 @@ pub struct DeviceCodeLink {
code: Option<String>,
}
impl DeviceCodeLink {
#[must_use]
pub fn with_code(code: String) -> Self {
Self { code: Some(code) }
}
}
impl Route for DeviceCodeLink {
type Query = DeviceCodeLink;
fn route() -> &'static str {
@@ -706,6 +713,14 @@ impl Route for DeviceCodeLink {
}
}
/// `POST /oauth2/device`
#[derive(Default, Serialize, Deserialize, Debug, Clone)]
pub struct OAuth2DeviceAuthorizationEndpoint;
impl SimpleRoute for OAuth2DeviceAuthorizationEndpoint {
const PATH: &'static str = "/oauth2/device";
}
/// `GET /assets`
pub struct StaticAsset {
path: String,

View File

@@ -154,6 +154,24 @@ impl UrlBuilder {
self.absolute_url_for(&crate::endpoints::OAuth2RegistrationEndpoint)
}
/// OAuth 2.0 device authorization endpoint
#[must_use]
pub fn oauth_device_authorization_endpoint(&self) -> Url {
self.absolute_url_for(&crate::endpoints::OAuth2DeviceAuthorizationEndpoint)
}
/// OAuth 2.0 device code link
#[must_use]
pub fn device_code_link(&self) -> Url {
self.absolute_url_for(&crate::endpoints::DeviceCodeLink::default())
}
/// OAuth 2.0 device code link full URL
#[must_use]
pub fn device_code_link_full(&self, code: String) -> Url {
self.absolute_url_for(&crate::endpoints::DeviceCodeLink::with_code(code))
}
// OIDC userinfo endpoint
#[must_use]
pub fn oidc_userinfo_endpoint(&self) -> Url {