Add logout url
This commit is contained in:
parent
eb54665596
commit
7d59cbde11
4 changed files with 17 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1739,6 +1739,7 @@ dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-oidc",
|
"axum-oidc",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"http 1.1.0",
|
||||||
"http-body 1.0.0",
|
"http-body 1.0.0",
|
||||||
"rest-types",
|
"rest-types",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ impl SalesPersonDao for SalesPersonDaoImpl {
|
||||||
let id = entity.id.as_bytes().to_vec();
|
let id = entity.id.as_bytes().to_vec();
|
||||||
let version = entity.version.as_bytes().to_vec();
|
let version = entity.version.as_bytes().to_vec();
|
||||||
let name = entity.name.as_ref();
|
let name = entity.name.as_ref();
|
||||||
let background_color = entity.name.as_ref();
|
let background_color = entity.background_color.as_ref();
|
||||||
let inactive = entity.inactive;
|
let inactive = entity.inactive;
|
||||||
let deleted = entity.deleted.as_ref().map(|deleted| deleted.to_string());
|
let deleted = entity.deleted.as_ref().map(|deleted| deleted.to_string());
|
||||||
query!("UPDATE sales_person SET name = ?, background_color = ?, inactive = ?, deleted = ?, update_version = ?, update_process = ? WHERE id = ?", name, background_color, inactive, deleted, version, process, id)
|
query!("UPDATE sales_person SET name = ?, background_color = ?, inactive = ?, deleted = ?, update_version = ?, update_process = ? WHERE id = ?", name, background_color, inactive, deleted, version, process, id)
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ mock_auth = []
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = "0.7.5"
|
axum = "0.7.5"
|
||||||
bytes = "1.6.0"
|
bytes = "1.6.0"
|
||||||
|
http = "1.1.0"
|
||||||
http-body = "1.0.0"
|
http-body = "1.0.0"
|
||||||
serde_json = "1.0.116"
|
serde_json = "1.0.116"
|
||||||
time = { version = "0.3.36", features = ["serde-human-readable"] }
|
time = { version = "0.3.36", features = ["serde-human-readable"] }
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,19 @@ pub async fn login() -> Redirect {
|
||||||
Redirect::to("/")
|
Redirect::to("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "oidc")]
|
||||||
|
use axum_oidc::OidcRpInitiatedLogout;
|
||||||
|
#[cfg(feature = "oidc")]
|
||||||
|
use http::StatusCode;
|
||||||
|
#[cfg(feature = "oidc")]
|
||||||
|
pub async fn logout(logout_extractor: OidcRpInitiatedLogout) -> Result<Redirect, StatusCode> {
|
||||||
|
if let Ok(logout_uri) = logout_extractor.uri() {
|
||||||
|
Ok(Redirect::to(logout_uri.path()))
|
||||||
|
} else {
|
||||||
|
Err(StatusCode::BAD_REQUEST)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
pub struct AuthInfoTO {
|
pub struct AuthInfoTO {
|
||||||
pub user: Arc<str>,
|
pub user: Arc<str>,
|
||||||
|
|
@ -302,6 +315,7 @@ pub async fn start_server<RestState: RestStateDef>(rest_state: RestState) {
|
||||||
.layer(OidcLoginLayer::<EmptyAdditionalClaims>::new());
|
.layer(OidcLoginLayer::<EmptyAdditionalClaims>::new());
|
||||||
|
|
||||||
app.route("/authenticate", get(login))
|
app.route("/authenticate", get(login))
|
||||||
|
.route("/logout", get(logout))
|
||||||
.layer(oidc_login_service)
|
.layer(oidc_login_service)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue