ezidam: oauth: redirect to redirect uri with code and state

This commit is contained in:
Philippe Loctaux 2023-03-17 22:17:56 +01:00
parent ae71a6a512
commit 8c8caa905d

View file

@ -161,12 +161,25 @@ async fn authorize(
AuthorizationCodes::insert(&mut transaction, code.as_ref(), app.id(), user.id()).await?;
transaction.commit().await?;
// TODO: put code, state (if present)
// Construct uri to redirect to
let uri = {
let uri_mode = match auth_request.response_mode {
ResponseMode::Query => "?",
ResponseMode::Fragment => "#",
};
// TODO: handle query, fragment, and form post
Ok(Either::Left(Redirect::found(
app.redirect_uri().to_string(),
)))
// Redirect + authorization code
let uri = format!("{}{}code={}", app.redirect_uri(), uri_mode, code.as_ref());
// Add state if present
if auth_request.state.is_empty() {
uri
} else {
format!("{}&state={}", uri, auth_request.state)
}
};
Ok(Either::Left(Redirect::found(uri)))
}
// TODO: oauth redirect route for ezidam