feat: mock oauth login wellknown
looks like we will need oauth soon to be able to use even andstatus
This commit is contained in:
parent
d10376529e
commit
2073015b7f
2 changed files with 37 additions and 1 deletions
|
@ -36,6 +36,7 @@ impl ActivityPubRouter for Router<crate::server::Context> {
|
||||||
.route("/.well-known/webfinger", get(ap::well_known::webfinger))
|
.route("/.well-known/webfinger", get(ap::well_known::webfinger))
|
||||||
.route("/.well-known/host-meta", get(ap::well_known::host_meta))
|
.route("/.well-known/host-meta", get(ap::well_known::host_meta))
|
||||||
.route("/.well-known/nodeinfo", get(ap::well_known::nodeinfo_discovery))
|
.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))
|
.route("/nodeinfo/:version", get(ap::well_known::nodeinfo))
|
||||||
// actor routes
|
// actor routes
|
||||||
.route("/users/:id", get(ap::user::view))
|
.route("/users/:id", get(ap::user::view))
|
||||||
|
|
|
@ -2,7 +2,7 @@ use axum::{extract::{Path, Query, State}, http::StatusCode, response::{IntoRespo
|
||||||
use jrd::{JsonResourceDescriptor, JsonResourceDescriptorLink};
|
use jrd::{JsonResourceDescriptor, JsonResourceDescriptorLink};
|
||||||
use sea_orm::{EntityTrait, PaginatorTrait};
|
use sea_orm::{EntityTrait, PaginatorTrait};
|
||||||
|
|
||||||
use crate::{model, server::Context, VERSION};
|
use crate::{model, server::Context, url, VERSION};
|
||||||
|
|
||||||
#[derive(serde::Serialize)]
|
#[derive(serde::Serialize)]
|
||||||
pub struct NodeInfoDiscovery {
|
pub struct NodeInfoDiscovery {
|
||||||
|
@ -144,3 +144,38 @@ pub async fn host_meta(State(ctx): State<Context>) -> Response {
|
||||||
ctx.protocol(), ctx.base())
|
ctx.protocol(), ctx.base())
|
||||||
).into_response()
|
).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,
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue