Better 2fa verification support (#6782)

* Better 2fa verification support

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* 2FA login verification, add request filed 'tfa_code'

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* 2fa dialog

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* msgbox, title

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* Feat, oidc login, 2fa

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2024-01-03 16:43:39 +08:00
committed by GitHub
parent 89150317e1
commit 7e3a0c4ded
43 changed files with 176 additions and 54 deletions

View File

@@ -95,6 +95,8 @@ pub struct UserPayload {
pub struct AuthBody {
pub access_token: String,
pub r#type: String,
#[serde(default)]
pub tfa_type: String,
pub user: UserPayload,
}
@@ -238,15 +240,17 @@ impl OidcSession {
while OIDC_SESSION.read().unwrap().keep_querying && begin.elapsed() < query_timeout {
match Self::query(&api_server, &code_url.code, &id, &uuid) {
Ok(HbbHttpResponse::<_>::Data(auth_body)) => {
if remember_me {
LocalConfig::set_option(
"access_token".to_owned(),
auth_body.access_token.clone(),
);
LocalConfig::set_option(
"user_info".to_owned(),
serde_json::json!({ "name": auth_body.user.name, "status": auth_body.user.status }).to_string(),
);
if auth_body.r#type == "access_token" {
if remember_me {
LocalConfig::set_option(
"access_token".to_owned(),
auth_body.access_token.clone(),
);
LocalConfig::set_option(
"user_info".to_owned(),
serde_json::json!({ "name": auth_body.user.name, "status": auth_body.user.status }).to_string(),
);
}
}
OIDC_SESSION
.write()