@@ -9,7 +9,6 @@ use rocket::{
9
9
} ;
10
10
use serde_json:: Value ;
11
11
12
- use crate :: api:: core:: two_factor:: webauthn:: Webauthn2FaConfig ;
13
12
use crate :: {
14
13
api:: {
15
14
core:: {
@@ -49,7 +48,6 @@ async fn login(
49
48
data : Form < ConnectData > ,
50
49
client_header : ClientHeaders ,
51
50
client_version : Option < ClientVersion > ,
52
- webauthn : Webauthn2FaConfig < ' _ > ,
53
51
mut conn : DbConn ,
54
52
) -> JsonResult {
55
53
let data: ConnectData = data. into_inner ( ) ;
@@ -72,7 +70,7 @@ async fn login(
72
70
_check_is_some ( & data. device_name , "device_name cannot be blank" ) ?;
73
71
_check_is_some ( & data. device_type , "device_type cannot be blank" ) ?;
74
72
75
- _password_login ( data, & mut user_id, & mut conn, & client_header. ip , & client_version, webauthn ) . await
73
+ _password_login ( data, & mut user_id, & mut conn, & client_header. ip , & client_version) . await
76
74
}
77
75
"client_credentials" => {
78
76
_check_is_some ( & data. client_id , "client_id cannot be blank" ) ?;
@@ -93,7 +91,7 @@ async fn login(
93
91
_check_is_some ( & data. device_name , "device_name cannot be blank" ) ?;
94
92
_check_is_some ( & data. device_type , "device_type cannot be blank" ) ?;
95
93
96
- _sso_login ( data, & mut user_id, & mut conn, & client_header. ip , & client_version, webauthn ) . await
94
+ _sso_login ( data, & mut user_id, & mut conn, & client_header. ip , & client_version) . await
97
95
}
98
96
"authorization_code" => err ! ( "SSO sign-in is not available" ) ,
99
97
t => err ! ( "Invalid type" , t) ,
@@ -171,7 +169,6 @@ async fn _sso_login(
171
169
conn : & mut DbConn ,
172
170
ip : & ClientIp ,
173
171
client_version : & Option < ClientVersion > ,
174
- webauthn : Webauthn2FaConfig < ' _ > ,
175
172
) -> JsonResult {
176
173
AuthMethod :: Sso . check_scope ( data. scope . as_ref ( ) ) ?;
177
174
@@ -270,7 +267,7 @@ async fn _sso_login(
270
267
}
271
268
Some ( ( mut user, sso_user) ) => {
272
269
let mut device = get_device ( & data, conn, & user) . await ?;
273
- let twofactor_token = twofactor_auth ( & user, & data, & mut device, ip, client_version, webauthn , conn) . await ?;
270
+ let twofactor_token = twofactor_auth ( & user, & data, & mut device, ip, client_version, conn) . await ?;
274
271
275
272
if user. private_key . is_none ( ) {
276
273
// User was invited a stub was created
@@ -325,7 +322,6 @@ async fn _password_login(
325
322
conn : & mut DbConn ,
326
323
ip : & ClientIp ,
327
324
client_version : & Option < ClientVersion > ,
328
- webauthn : Webauthn2FaConfig < ' _ > ,
329
325
) -> JsonResult {
330
326
// Validate scope
331
327
AuthMethod :: Password . check_scope ( data. scope . as_ref ( ) ) ?;
@@ -435,7 +431,7 @@ async fn _password_login(
435
431
436
432
let mut device = get_device ( & data, conn, & user) . await ?;
437
433
438
- let twofactor_token = twofactor_auth ( & user, & data, & mut device, ip, client_version, webauthn , conn) . await ?;
434
+ let twofactor_token = twofactor_auth ( & user, & data, & mut device, ip, client_version, conn) . await ?;
439
435
440
436
let auth_tokens = auth:: AuthTokens :: new ( & device, & user, AuthMethod :: Password , data. client_id ) ;
441
437
@@ -667,7 +663,6 @@ async fn twofactor_auth(
667
663
device : & mut Device ,
668
664
ip : & ClientIp ,
669
665
client_version : & Option < ClientVersion > ,
670
- webauthn : Webauthn2FaConfig < ' _ > ,
671
666
conn : & mut DbConn ,
672
667
) -> ApiResult < Option < String > > {
673
668
let twofactors = TwoFactor :: find_by_user ( & user. uuid , conn) . await ;
@@ -687,7 +682,7 @@ async fn twofactor_auth(
687
682
Some ( ref code) => code,
688
683
None => {
689
684
err_json ! (
690
- _json_err_twofactor( & twofactor_ids, & user. uuid, data, client_version, webauthn , conn) . await ?,
685
+ _json_err_twofactor( & twofactor_ids, & user. uuid, data, client_version, conn) . await ?,
691
686
"2FA token not provided"
692
687
)
693
688
}
@@ -704,9 +699,7 @@ async fn twofactor_auth(
704
699
Some ( TwoFactorType :: Authenticator ) => {
705
700
authenticator:: validate_totp_code_str ( & user. uuid , twofactor_code, & selected_data?, ip, conn) . await ?
706
701
}
707
- Some ( TwoFactorType :: Webauthn ) => {
708
- webauthn:: validate_webauthn_login ( & user. uuid , twofactor_code, webauthn, conn) . await ?
709
- }
702
+ Some ( TwoFactorType :: Webauthn ) => webauthn:: validate_webauthn_login ( & user. uuid , twofactor_code, conn) . await ?,
710
703
Some ( TwoFactorType :: YubiKey ) => yubikey:: validate_yubikey_login ( twofactor_code, & selected_data?) . await ?,
711
704
Some ( TwoFactorType :: Duo ) => {
712
705
match CONFIG . duo_use_iframe ( ) {
@@ -738,7 +731,7 @@ async fn twofactor_auth(
738
731
}
739
732
_ => {
740
733
err_json ! (
741
- _json_err_twofactor( & twofactor_ids, & user. uuid, data, client_version, webauthn , conn) . await ?,
734
+ _json_err_twofactor( & twofactor_ids, & user. uuid, data, client_version, conn) . await ?,
742
735
"2FA Remember token not provided"
743
736
)
744
737
}
@@ -772,7 +765,6 @@ async fn _json_err_twofactor(
772
765
user_id : & UserId ,
773
766
data : & ConnectData ,
774
767
client_version : & Option < ClientVersion > ,
775
- webauthn : Webauthn2FaConfig < ' _ > ,
776
768
conn : & mut DbConn ,
777
769
) -> ApiResult < Value > {
778
770
let mut result = json ! ( {
@@ -792,7 +784,7 @@ async fn _json_err_twofactor(
792
784
Some ( TwoFactorType :: Authenticator ) => { /* Nothing to do for TOTP */ }
793
785
794
786
Some ( TwoFactorType :: Webauthn ) if CONFIG . domain_set ( ) => {
795
- let request = webauthn:: generate_webauthn_login ( user_id, webauthn , conn) . await ?;
787
+ let request = webauthn:: generate_webauthn_login ( user_id, conn) . await ?;
796
788
result[ "TwoFactorProviders2" ] [ provider. to_string ( ) ] = request. 0 ;
797
789
}
798
790
0 commit comments