Skip to content

Commit 5ca155b

Browse files
authored
Remove support for captchas (#367)
We no longer use captchas.
1 parent 58a9bf9 commit 5ca155b

File tree

7 files changed

+4
-92
lines changed

7 files changed

+4
-92
lines changed

crates/bitwarden-core/src/auth/api/response/identity_captcha_response.rs

Lines changed: 0 additions & 31 deletions
This file was deleted.

crates/bitwarden-core/src/auth/api/response/identity_token_response.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
44
use crate::{
55
auth::{
66
api::response::{
7-
IdentityCaptchaResponse, IdentityTokenFailResponse, IdentityTokenPayloadResponse,
8-
IdentityTokenRefreshResponse, IdentityTokenSuccessResponse, IdentityTwoFactorResponse,
7+
IdentityTokenFailResponse, IdentityTokenPayloadResponse, IdentityTokenRefreshResponse,
8+
IdentityTokenSuccessResponse, IdentityTwoFactorResponse,
99
},
1010
login::LoginError,
1111
},
@@ -18,7 +18,6 @@ pub enum IdentityTokenResponse {
1818
Payload(IdentityTokenPayloadResponse),
1919
Refreshed(IdentityTokenRefreshResponse),
2020
TwoFactorRequired(Box<IdentityTwoFactorResponse>),
21-
CaptchaRequired(IdentityCaptchaResponse),
2221
}
2322

2423
pub fn parse_identity_response(
@@ -33,8 +32,6 @@ pub fn parse_identity_response(
3332
Ok(IdentityTokenResponse::Refreshed(r))
3433
} else if let Ok(r) = serde_json::from_str::<IdentityTwoFactorResponse>(&response) {
3534
Ok(IdentityTokenResponse::TwoFactorRequired(Box::new(r)))
36-
} else if let Ok(r) = serde_json::from_str::<IdentityCaptchaResponse>(&response) {
37-
Ok(IdentityTokenResponse::CaptchaRequired(r))
3835
} else if let Ok(r) = serde_json::from_str::<IdentityTokenFailResponse>(&response) {
3936
Err(LoginError::IdentityFail(r))
4037
} else {
@@ -67,13 +64,4 @@ mod test {
6764
let actual = parse_identity_response(StatusCode::BAD_REQUEST, two_factor).unwrap();
6865
assert_eq!(expected, actual);
6966
}
70-
71-
#[test]
72-
fn captcha() {
73-
let expected = IdentityCaptchaResponse::default();
74-
let captcha = serde_json::to_string(&expected).unwrap();
75-
let expected = IdentityTokenResponse::CaptchaRequired(expected);
76-
let actual = parse_identity_response(StatusCode::BAD_REQUEST, captcha).unwrap();
77-
assert_eq!(expected, actual);
78-
}
7967
}

crates/bitwarden-core/src/auth/api/response/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
mod identity_captcha_response;
21
mod identity_payload_response;
32
mod identity_refresh_response;
43
mod identity_success_response;
@@ -8,7 +7,6 @@ mod identity_two_factor_response;
87
pub(crate) mod two_factor_provider_data;
98
mod two_factor_providers;
109

11-
pub(crate) use identity_captcha_response::*;
1210
pub(crate) use identity_payload_response::*;
1311
pub(crate) use identity_refresh_response::*;
1412
pub(crate) use identity_success_response::*;

crates/bitwarden-core/src/auth/login/password.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use schemars::JsonSchema;
66
use serde::{Deserialize, Serialize};
77

88
use crate::auth::{
9-
api::response::IdentityTokenResponse,
10-
login::response::{captcha_response::CaptchaResponse, two_factor::TwoFactorProviders},
9+
api::response::IdentityTokenResponse, login::response::two_factor::TwoFactorProviders,
1110
};
1211
#[cfg(feature = "internal")]
1312
use crate::{
@@ -114,9 +113,6 @@ pub struct PasswordLoginResponse {
114113
/// The available two factor authentication options. Present only when authentication fails due
115114
/// to requiring a second authentication factor.
116115
pub two_factor: Option<TwoFactorProviders>,
117-
/// The information required to present the user with a captcha challenge. Only present when
118-
/// authentication fails due to requiring validation of a captcha challenge.
119-
pub captcha: Option<CaptchaResponse>,
120116
}
121117

122118
impl PasswordLoginResponse {
@@ -127,28 +123,18 @@ impl PasswordLoginResponse {
127123
reset_master_password: success.reset_master_password,
128124
force_password_reset: success.force_password_reset,
129125
two_factor: None,
130-
captcha: None,
131126
},
132127
IdentityTokenResponse::Payload(_) => PasswordLoginResponse {
133128
authenticated: true,
134129
reset_master_password: false,
135130
force_password_reset: false,
136131
two_factor: None,
137-
captcha: None,
138132
},
139133
IdentityTokenResponse::TwoFactorRequired(two_factor) => PasswordLoginResponse {
140134
authenticated: false,
141135
reset_master_password: false,
142136
force_password_reset: false,
143137
two_factor: Some(two_factor.two_factor_providers.into()),
144-
captcha: two_factor.captcha_token.map(Into::into),
145-
},
146-
IdentityTokenResponse::CaptchaRequired(captcha) => PasswordLoginResponse {
147-
authenticated: false,
148-
reset_master_password: false,
149-
force_password_reset: false,
150-
two_factor: None,
151-
captcha: Some(captcha.site_key.into()),
152138
},
153139
IdentityTokenResponse::Refreshed(_) => {
154140
unreachable!("Got a `refresh_token` answer to a login request")

crates/bitwarden-core/src/auth/login/response/captcha_response.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
#[allow(missing_docs)]
2-
pub mod captcha_response;
3-
#[allow(missing_docs)]
42
pub mod two_factor;

crates/bw/src/auth/login.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ pub(crate) async fn login_password(client: Client, email: Option<String>) -> Res
2828
})
2929
.await?;
3030

31-
if result.captcha.is_some() {
32-
// TODO: We should build a web captcha solution
33-
error!("Captcha required");
34-
} else if let Some(two_factor) = result.two_factor {
31+
if let Some(two_factor) = result.two_factor {
3532
error!("{two_factor:?}");
3633

3734
let two_factor = if let Some(tf) = two_factor.authenticator {

0 commit comments

Comments
 (0)