Skip to content

Commit

Permalink
Add whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Jan 8, 2025
1 parent 0c6254d commit 653d9b7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,26 @@ fn get_banned_users() -> Vec<String> {
banned_users
}


fn get_whitelisted_users() -> Vec<String> {
let mut whitelisted_users = vec![];
let file = std::fs::read_to_string("faucet_config/whitelisted_users.txt");
if let Ok(file) = file {
for line in file.lines() {
let line = line.trim();
if !line.is_empty() {
whitelisted_users.push(line.to_string());
}
}
}
whitelisted_users
}

pub fn is_banned(email: &String) -> bool {
let whitelisted_users = get_whitelisted_users();
if whitelisted_users.contains(email) {
return false;
}
let domains = banned_domains();
let user_host = email.split('@').last().unwrap_or("");
if domains.contains(&user_host.to_lowercase()) {
Expand Down

0 comments on commit 653d9b7

Please sign in to comment.