Skip to content

Commit c83cc41

Browse files
authored
fix(webserver): Prevent disabled accounts from authenticating (#1311)
1 parent 04f6d4e commit c83cc41

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

ee/tabby-webserver/src/schema/auth.rs

+9
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ pub enum TokenAuthError {
136136
#[error("Password is not valid")]
137137
InvalidPassword,
138138

139+
#[error("User is disabled")]
140+
UserDisabled,
141+
139142
#[error(transparent)]
140143
Other(#[from] anyhow::Error),
141144

@@ -160,6 +163,9 @@ pub enum OAuthError {
160163
#[error("The user is not invited to access the system")]
161164
UserNotInvited,
162165

166+
#[error("User is disabled")]
167+
UserDisabled,
168+
163169
#[error(transparent)]
164170
Other(#[from] anyhow::Error),
165171

@@ -187,6 +193,9 @@ pub enum RefreshTokenError {
187193
#[error("User not found")]
188194
UserNotFound,
189195

196+
#[error("User is disabled")]
197+
UserDisabled,
198+
190199
#[error(transparent)]
191200
Other(#[from] anyhow::Error),
192201

ee/tabby-webserver/src/service/auth.rs

+11
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ impl AuthenticationService for DbConn {
220220
return Err(TokenAuthError::UserNotFound);
221221
};
222222

223+
if !user.active {
224+
return Err(TokenAuthError::UserDisabled);
225+
}
226+
223227
if !password_verify(&input.password, &user.password_encrypted) {
224228
return Err(TokenAuthError::InvalidPassword);
225229
}
@@ -250,6 +254,10 @@ impl AuthenticationService for DbConn {
250254
return Err(RefreshTokenError::UserNotFound);
251255
};
252256

257+
if !user.active {
258+
return Err(RefreshTokenError::UserDisabled);
259+
}
260+
253261
let new_token = generate_refresh_token();
254262
self.replace_refresh_token(&token, &new_token).await?;
255263

@@ -353,6 +361,9 @@ impl AuthenticationService for DbConn {
353361
};
354362

355363
let user = if let Some(user) = self.get_user_by_email(&email).await? {
364+
if !user.active {
365+
return Err(OAuthError::UserDisabled);
366+
}
356367
user
357368
} else {
358369
let Some(invitation) = self.get_invitation_by_email(&email).await? else {

0 commit comments

Comments
 (0)