fix(OIDC): redirect to frontend after OIDC credentials
This commit is contained in:
parent
a5edcfdd1d
commit
a23edca938
|
|
@ -189,7 +189,7 @@ async fn oidc_login(State(state): State<Arc<AppState>>) -> Result<Redirect, Stat
|
||||||
async fn oidc_callback(
|
async fn oidc_callback(
|
||||||
State(state): State<Arc<AppState>>,
|
State(state): State<Arc<AppState>>,
|
||||||
Query(params): Query<OidcCallbackQuery>,
|
Query(params): Query<OidcCallbackQuery>,
|
||||||
) -> Result<Json<LoginResponse>, StatusCode> {
|
) -> Result<Redirect, StatusCode> {
|
||||||
tracing::info!("OIDC callback called with params: code={:?}, state={:?}, error={:?}",
|
tracing::info!("OIDC callback called with params: code={:?}, state={:?}, error={:?}",
|
||||||
params.code, params.state, params.error);
|
params.code, params.state, params.error);
|
||||||
|
|
||||||
|
|
@ -324,10 +324,12 @@ async fn oidc_callback(
|
||||||
StatusCode::INTERNAL_SERVER_ERROR
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
Ok(Json(LoginResponse {
|
// Redirect to frontend with token in URL fragment
|
||||||
token,
|
// The frontend should extract the token and store it
|
||||||
user: user.into(),
|
let redirect_url = format!("/#/auth/callback?token={}", urlencoding::encode(&token));
|
||||||
}))
|
tracing::info!("OIDC authentication successful for user: {}, redirecting to: {}", user.username, redirect_url);
|
||||||
|
|
||||||
|
Ok(Redirect::to(&redirect_url))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to create a new OIDC user
|
// Helper function to create a new OIDC user
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue