Utoipa auth endpoint
This commit is contained in:
parent
2e2ddf017b
commit
364710ef79
2 changed files with 11 additions and 3 deletions
|
@ -28,7 +28,7 @@ pub fn router() -> OpenApiRouter<App> {
|
||||||
// Basic
|
// Basic
|
||||||
.routes(routes!(get_version))
|
.routes(routes!(get_version))
|
||||||
.routes(routes!(get_initial_setup))
|
.routes(routes!(get_initial_setup))
|
||||||
.route("/auth", post(post_auth))
|
.routes(routes!(post_auth))
|
||||||
// Configuration
|
// Configuration
|
||||||
.route("/settings", get(get_settings))
|
.route("/settings", get(get_settings))
|
||||||
.route("/settings", put(put_settings))
|
.route("/settings", put(put_settings))
|
||||||
|
@ -178,6 +178,14 @@ async fn put_mount_dirs(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[utoipa::path(
|
||||||
|
post,
|
||||||
|
path = "/auth",
|
||||||
|
responses(
|
||||||
|
(status = 200, body = dto::Authorization),
|
||||||
|
(status = 401),
|
||||||
|
),
|
||||||
|
)]
|
||||||
async fn post_auth(
|
async fn post_auth(
|
||||||
State(config_manager): State<config::Manager>,
|
State(config_manager): State<config::Manager>,
|
||||||
credentials: Json<dto::Credentials>,
|
credentials: Json<dto::Credentials>,
|
||||||
|
|
|
@ -15,13 +15,13 @@ pub struct InitialSetup {
|
||||||
pub has_any_users: bool,
|
pub has_any_users: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize, ToSchema)]
|
||||||
pub struct Credentials {
|
pub struct Credentials {
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub password: String,
|
pub password: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize, ToSchema)]
|
||||||
pub struct Authorization {
|
pub struct Authorization {
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub token: String,
|
pub token: String,
|
||||||
|
|
Loading…
Add table
Reference in a new issue