Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Vaultwarden
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Vaultwarden
Commits
2d98aa30
Unverified
Commit
2d98aa30
authored
11 months ago
by
Daniel García
Committed by
GitHub
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Use async verify for Yubikey (#4448)
parent
93636eb3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/api/core/two_factor/yubikey.rs
+5
-12
5 additions, 12 deletions
src/api/core/two_factor/yubikey.rs
with
5 additions
and
12 deletions
src/api/core/two_factor/yubikey.rs
+
5
−
12
View file @
2d98aa30
use
rocket
::
serde
::
json
::
Json
;
use
rocket
::
Route
;
use
serde_json
::
Value
;
use
yubico
::{
config
::
Config
,
verify
};
use
yubico
::{
config
::
Config
,
verify
_async
};
use
crate
::{
api
::{
...
...
@@ -74,13 +74,10 @@ async fn verify_yubikey_otp(otp: String) -> EmptyResult {
let
config
=
Config
::
default
()
.set_client_id
(
yubico_id
)
.set_key
(
yubico_secret
);
match
CONFIG
.yubico_server
()
{
Some
(
server
)
=>
{
tokio
::
task
::
spawn_blocking
(
move
||
verify
(
otp
,
config
.set_api_hosts
(
vec!
[
server
])))
.await
.unwrap
()
}
None
=>
tokio
::
task
::
spawn_blocking
(
move
||
verify
(
otp
,
config
))
.await
.unwrap
(),
Some
(
server
)
=>
verify_async
(
otp
,
config
.set_api_hosts
(
vec!
[
server
]))
.await
,
None
=>
verify_async
(
otp
,
config
)
.await
,
}
.map_res
(
"Failed to verify OTP"
)
.and
(
Ok
(()))
}
#[post(
"/two-factor/get-yubikey"
,
data
=
"<data>"
)]
...
...
@@ -194,10 +191,6 @@ pub async fn validate_yubikey_login(response: &str, twofactor_data: &str) -> Emp
err!
(
"Given Yubikey is not registered"
);
}
let
result
=
verify_yubikey_otp
(
response
.to_owned
())
.await
;
match
result
{
Ok
(
_answer
)
=>
Ok
(()),
Err
(
_e
)
=>
err!
(
"Failed to verify Yubikey against OTP server"
),
}
verify_yubikey_otp
(
response
.to_owned
())
.await
.map_res
(
"Failed to verify Yubikey against OTP server"
)
?
;
Ok
(())
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment