1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-07-29 22:01:14 +03:00

WIP: upstream OIDC provider support

This commit is contained in:
Quentin Gliech
2022-11-22 18:28:16 +01:00
parent 7f9be07e8d
commit bedcf44741
28 changed files with 1505 additions and 96 deletions

View File

@ -524,6 +524,52 @@ impl Route for CompatLoginSsoComplete {
}
}
/// `GET /upstream/authorize/:id`
pub struct UpstreamOAuth2Authorize {
id: Ulid,
}
impl UpstreamOAuth2Authorize {
#[must_use]
pub const fn new(id: Ulid) -> Self {
Self { id }
}
}
impl Route for UpstreamOAuth2Authorize {
type Query = ();
fn route() -> &'static str {
"/upstream/authorize/:provider_id"
}
fn path(&self) -> std::borrow::Cow<'static, str> {
format!("/upstream/authorize/{}", self.id).into()
}
}
/// `GET /upstream/callback/:id`
pub struct UpstreamOAuth2Callback {
id: Ulid,
}
impl UpstreamOAuth2Callback {
#[must_use]
pub const fn new(id: Ulid) -> Self {
Self { id }
}
}
impl Route for UpstreamOAuth2Callback {
type Query = ();
fn route() -> &'static str {
"/upstream/callback/:provider_id"
}
fn path(&self) -> std::borrow::Cow<'static, str> {
format!("/upstream/callback/{}", self.id).into()
}
}
/// `GET /assets`
pub struct StaticAsset {
path: String,

View File

@ -14,6 +14,7 @@
//! Utility to build URLs
use ulid::Ulid;
use url::Url;
use crate::traits::Route;
@ -97,4 +98,16 @@ impl UrlBuilder {
pub fn static_asset(&self, path: String) -> Url {
self.url_for(&crate::endpoints::StaticAsset::new(path))
}
/// Upstream redirect URI
#[must_use]
pub fn upstream_oauth_callback(&self, id: Ulid) -> Url {
self.url_for(&crate::endpoints::UpstreamOAuth2Callback::new(id))
}
/// Upstream authorize URI
#[must_use]
pub fn upstream_oauth_authorize(&self, id: Ulid) -> Url {
self.url_for(&crate::endpoints::UpstreamOAuth2Authorize::new(id))
}
}