Hi everyone,
I’ve just published kemal-auth, a comprehensive authentication library for Kemal web applications.
The existing Kemal auth shards (kemal-auth-token, kemal-basic-auth, kemal-jwt-auth) have all been abandoned for 4-7 years. kemal-auth aims to provide a maintained, full-featured alternative.
Features
| Module | Description |
|---|---|
KemalAuth::Password |
BCrypt password hashing with CNIL-compliant rules (12+ chars, uppercase, lowercase, digit, special char) |
KemalAuth::Token |
JWT token generation and verification |
KemalAuth::Session |
Session management via HTTP cookies |
KemalAuth::SmtpConfig |
Configurable SMTP settings (constructor, Hash, or environment variables) |
KemalAuth::PasswordReset |
Password recovery via email with JWT-based reset links |
KemalAuth::UserManager |
User validation, invitations, and temporary password generation |
Quick example
require "kemal_auth"
# Hash and verify passwords
hash = KemalAuth::Password.hash("MyStr0ng!Pass")
KemalAuth::Password.verify("MyStr0ng!Pass", hash) # => true
# Generate JWT tokens
token = KemalAuth::Token.generate(
secret: ENV["SESSION_SECRET"],
sub: "1",
email: "user@example.com",
role: "admin"
)
# Send password reset emails
smtp = KemalAuth::SmtpConfig.new(host: "smtp.example.com", port: 587, ...)
KemalAuth::PasswordReset.send_reset_email(
email: "user@example.com",
reset_url: "https://myapp.com/reset-password",
secret: ENV["SESSION_SECRET"],
smtp: smtp
)
Installation
dependencies:
kemal-auth:
github: aloli-crystal/kemal-auth
version: "~> 0.1"
- 52 tests, 0 failures
- Documentation in English and French
- GitHub
Feedback and contributions welcome !