feat: mock oauth login wellknown

looks like we will need oauth soon to be able to use even andstatus
This commit is contained in:
əlemi 2024-04-18 05:46:10 +02:00
parent d10376529e
commit 2073015b7f
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 37 additions and 1 deletions

View file

@ -36,6 +36,7 @@ impl ActivityPubRouter for Router<crate::server::Context> {
.route("/.well-known/webfinger", get(ap::well_known::webfinger))
.route("/.well-known/host-meta", get(ap::well_known::host_meta))
.route("/.well-known/nodeinfo", get(ap::well_known::nodeinfo_discovery))
.route("/.well-known/oauth-authorization-server", get(ap::well_known::oauth_authorization_server))
.route("/nodeinfo/:version", get(ap::well_known::nodeinfo))
// actor routes
.route("/users/:id", get(ap::user::view))

View file

@ -2,7 +2,7 @@ use axum::{extract::{Path, Query, State}, http::StatusCode, response::{IntoRespo
use jrd::{JsonResourceDescriptor, JsonResourceDescriptorLink};
use sea_orm::{EntityTrait, PaginatorTrait};
use crate::{model, server::Context, VERSION};
use crate::{model, server::Context, url, VERSION};
#[derive(serde::Serialize)]
pub struct NodeInfoDiscovery {
@ -144,3 +144,38 @@ pub async fn host_meta(State(ctx): State<Context>) -> Response {
ctx.protocol(), ctx.base())
).into_response()
}
#[derive(Debug, serde::Serialize)]
pub struct OauthAuthorizationServerResponse {
issuer: String,
authorization_endpoint: String,
token_endpoint: String,
scopes_supported: Vec<String>,
response_types_supported: Vec<String>,
grant_types_supported: Vec<String>,
service_documentation: String,
code_challenge_methods_supported: Vec<String>,
authorization_response_iss_parameter_supported: bool,
}
pub async fn oauth_authorization_server(State(ctx): State<Context>) -> crate::Result<Json<OauthAuthorizationServerResponse>> {
Ok(Json(OauthAuthorizationServerResponse {
issuer: url!(ctx, ""),
authorization_endpoint: url!(ctx, "/auth"),
token_endpoint: "".to_string(),
scopes_supported: vec![
"read:account".to_string(),
"write:account".to_string(),
"read:favorites".to_string(),
"write:favorites".to_string(),
"read:following".to_string(),
"write:following".to_string(),
"write:notes".to_string(),
],
response_types_supported: vec!["code".to_string()],
grant_types_supported: vec!["authorization_code".to_string()],
service_documentation: "".to_string(),
code_challenge_methods_supported: vec![],
authorization_response_iss_parameter_supported: false,
}))
}