Add /.well-known/change-password endpoint (#3382)

* feat: Add /.well-known/change-password endpoint
* fix: make the https view constants available inside the crate

---------
Co-authored-by: James Hodgkinson <james@terminaloutcomes.com>
This commit is contained in:
James 2025-02-02 19:57:05 -05:00 committed by GitHub
parent 351fdcdef0
commit f93d07b6cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 22 additions and 6 deletions

View file

@ -1,10 +1,11 @@
use axum::extract::State; use axum::extract::State;
use axum::http::header::CONTENT_TYPE; use axum::http::header::CONTENT_TYPE;
use axum::response::IntoResponse; use axum::response::{IntoResponse, Redirect};
use axum::{Extension, Json}; use axum::{Extension, Json};
use kanidmd_lib::status::StatusRequestEvent; use kanidmd_lib::status::StatusRequestEvent;
use super::middleware::KOpId; use super::middleware::KOpId;
use super::views::constants::Urls;
use super::ServerState; use super::ServerState;
#[utoipa::path( #[utoipa::path(
@ -50,3 +51,15 @@ pub async fn robots_txt() -> impl IntoResponse {
), ),
) )
} }
#[utoipa::path(
get,
path = Urls::WellKnownChangePassword.as_ref(),
responses(
(status = 303, description = "See other"),
),
tag = "ui",
)]
pub async fn redirect_to_update_credentials() -> impl IntoResponse {
Redirect::to(Urls::UpdateCredentials.as_ref())
}

View file

@ -251,7 +251,11 @@ pub async fn create_https_server(
.merge(oauth2::route_setup(state.clone())) .merge(oauth2::route_setup(state.clone()))
.merge(v1_scim::route_setup()) .merge(v1_scim::route_setup())
.merge(v1::route_setup(state.clone())) .merge(v1::route_setup(state.clone()))
.route("/robots.txt", get(generic::robots_txt)); .route("/robots.txt", get(generic::robots_txt))
.route(
views::constants::Urls::WellKnownChangePassword.as_ref(),
get(generic::redirect_to_update_credentials),
);
let app = match config.role { let app = match config.role {
ServerRole::WriteReplicaNoUI => app, ServerRole::WriteReplicaNoUI => app,

View file

@ -21,17 +21,16 @@ impl std::fmt::Display for UiMessage {
} }
} }
#[allow(dead_code)]
pub(crate) enum Urls { pub(crate) enum Urls {
Apps, Apps,
CredReset, CredReset,
CredResetError,
EnrolDevice, EnrolDevice,
Profile, Profile,
UpdateCredentials, UpdateCredentials,
Oauth2Resume, Oauth2Resume,
Login, Login,
Ui, Ui,
WellKnownChangePassword,
} }
impl AsRef<str> for Urls { impl AsRef<str> for Urls {
@ -39,13 +38,13 @@ impl AsRef<str> for Urls {
match self { match self {
Self::Apps => "/ui/apps", Self::Apps => "/ui/apps",
Self::CredReset => "/ui/reset", Self::CredReset => "/ui/reset",
Self::CredResetError => "/ui/reset/err",
Self::EnrolDevice => "/ui/enrol", Self::EnrolDevice => "/ui/enrol",
Self::Profile => "/ui/profile", Self::Profile => "/ui/profile",
Self::UpdateCredentials => "/ui/update_credentials", Self::UpdateCredentials => "/ui/update_credentials",
Self::Oauth2Resume => "/ui/oauth2/resume", Self::Oauth2Resume => "/ui/oauth2/resume",
Self::Login => "/ui/login", Self::Login => "/ui/login",
Self::Ui => "/ui", Self::Ui => "/ui",
Self::WellKnownChangePassword => "/.well-known/change-password",
} }
} }
} }

View file

@ -17,7 +17,7 @@ use kanidmd_lib::{
use crate::https::ServerState; use crate::https::ServerState;
mod apps; mod apps;
mod constants; pub(crate) mod constants;
mod cookies; mod cookies;
mod enrol; mod enrol;
mod errors; mod errors;