Skip to main content

headless_lms_server/controllers/
well_known.rs

1//! Handlers for `/.well-known` at the server root, where OAuth clients look for metadata.
2//!
3//! The ingress must route these paths to this server.
4
5use actix_web::{HttpResponse, web};
6use headless_lms_base::config::ApplicationConfiguration;
7use headless_lms_mcp::http::auth::protected_resource_metadata;
8
9use crate::controllers::main_frontend::oauth::authorization_server_metadata;
10
11/**
12GET `/.well-known/oauth-authorization-server/api/v0/main-frontend/oauth` - RFC 8414 authorization
13server metadata for the issuer `{base_url}/api/v0/main-frontend/oauth`.
14*/
15async fn oauth_authorization_server_metadata(
16    app_conf: web::Data<ApplicationConfiguration>,
17) -> HttpResponse {
18    HttpResponse::Ok().json(authorization_server_metadata(&app_conf))
19}
20
21pub fn _add_routes(cfg: &mut web::ServiceConfig) {
22    cfg.route(
23        "/oauth-protected-resource/api/v0/mcp",
24        web::get().to(protected_resource_metadata),
25    )
26    .route(
27        "/oauth-protected-resource",
28        web::get().to(protected_resource_metadata),
29    )
30    .route(
31        "/oauth-authorization-server/api/v0/main-frontend/oauth",
32        web::get().to(oauth_authorization_server_metadata),
33    );
34}