Skip to content

Commit

Permalink
Merge pull request #482 from sebadob/userinfo-post-handler
Browse files Browse the repository at this point in the history
add a `POST` handler for the `/userinfo`
  • Loading branch information
sebadob committed Jun 18, 2024
2 parents e9a4ad1 + 9e26ddc commit 05a8793
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/api/src/oidc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,31 @@ pub async fn get_userinfo(
.map(|u| HttpResponse::Ok().json(u))
}

/// The userinfo endpoint for the OIDC standard.
///
/// Depending on the JWT token from the *Authorization* header, it will return information about
/// the requesting user / token.
#[utoipa::path(
post,
path = "/oidc/userinfo",
tag = "oidc",
responses(
(status = 200, description = "Ok", body = Userinfo),
(status = 400, description = "BadRequest", body = ErrorResponse),
(status = 401, description = "Unauthorized", body = ErrorResponse),
(status = 404, description = "NotFound", body = ErrorResponse),
),
)]
#[post("/oidc/userinfo")]
pub async fn post_userinfo(
data: web::Data<AppState>,
req: HttpRequest,
) -> Result<HttpResponse, ErrorResponse> {
auth::get_userinfo(&data, req)
.await
.map(|u| HttpResponse::Ok().json(u))
}

/// GET forward authentication
///
/// This endpoint is very similar to the `/userinfo`, but instead of returning information about
Expand Down
1 change: 1 addition & 0 deletions src/bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ async fn actix_main(app_state: web::Data<AppState>) -> std::io::Result<()> {
.service(oidc::post_token)
.service(oidc::post_token_info)
.service(oidc::get_userinfo)
.service(oidc::post_userinfo)
.service(oidc::get_forward_auth)
.service(generic::get_enc_keys)
.service(generic::post_migrate_enc_key)
Expand Down

0 comments on commit 05a8793

Please sign in to comment.