Skip to content

Commit

Permalink
prevent auth if banned
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Dec 19, 2024
1 parent 3ef9c7c commit 4b7097a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn get_banned_users() -> Vec<String> {
banned_users
}

fn is_banned(email: &String) -> bool {
pub fn is_banned(email: &String) -> bool {
let domains = banned_domains();
let user_host = email.split('@').last().unwrap_or("");
if domains.contains(&user_host.to_lowercase()) {
Expand Down
5 changes: 5 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ async fn github_callback(
.find(|email| email.primary && email.verified)
.ok_or(StatusCode::INTERNAL_SERVER_ERROR)?;

// Check if user is banned
if auth::is_banned(&primary_email.email) {
return Err(StatusCode::INTERNAL_SERVER_ERROR);
}

// Create JWT
let claims = auth::TokenClaims {
sub: primary_email.email,
Expand Down

0 comments on commit 4b7097a

Please sign in to comment.