Created
November 21, 2024 17:27
-
-
Save weiss/0681aa51728ce47e00935490afcf73c5 to your computer and use it in GitHub Desktop.
Example of an ejabberd authentication module written in Gleam
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gleam/list | |
const credentials = [ | |
#("alice", "l0vesBob"), | |
#("bob", "l0vesAlice"), | |
#("eve", "stalksTh3m")] | |
pub type StoreType { | |
Plain | |
External | |
Scram | |
} | |
pub type Caching(result) { | |
Cache(result) | |
Nocache(result) | |
} | |
pub fn user_exists(user: String, | |
_server: String) { | |
case list.key_find(credentials, user) { | |
Ok(_) -> Nocache(True) | |
Error(_) -> Nocache(False) | |
} | |
} | |
pub fn check_password(user: String, | |
_authz_id: String, | |
_host: String, | |
password: String) { | |
Nocache(list.contains(credentials, #(user, password))) | |
} | |
pub fn plain_password_required() { True } | |
pub fn store_type(_server: String) { External } | |
pub fn start(_host: String) { Nil } | |
pub fn stop(_host: String) { Nil } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment