Brize Auth
A tiny async authentication library.
Still a Work In Progress. Is now in a usable state, but not for production. Roadmap at bottom.
Setup
First install the crate
Next, set up the database tables with this schema, if using a SQL database
-- Credentials table
(
id CHAR(36) PRIMARY KEY,
user_identity VARCHAR(255) NOT NULL,
hashed_password VARCHAR(255) NOT NULL
);
-- Sessions table
(
id CHAR(36) PRIMARY KEY,
created_at BIGINT UNSIGNED NOT NULL,
expires_at BIGINT UNSIGNED NOT NULL
);
Usage
use ;
Config
The preferred database and session type can be configured to your use case.
use ;
let config = new
// Set your preferred database tech for the credentials table
.set_credentials_gateway
// Set your session type, TableSession, JWT, or None to disable and the duration
.set_session_type;
// Override the default session GatewayType from above
.set_session_gateway
let auth = new.await;
Supported Databases
- MySql (credentials + sessions)
- SurrealDB (credentials + sessions)
- Redis (sessions only)
Testing
Setup
Install docker and run make sure the daemon is running
Fork this repo
gh repo fork xbrize/brize_auth
Running Tests
All test scripts are in ./scripts but feel free to make your own. You will need to chmod +x to the script files.
After giving permission to execute, simply run them. Each is designed to spin up docker containers that are hosting generic databases. These are then used to run the tests against.
Roadmap
Prototype phase
- User Registration
- Create user credentials if none exist
- Deny if user credentials does exist
- Return credentials foreign key
- Login
- Match user credentials
- Return session token if matched (if sessions enabled)
- Deny user if no match
- Hash password
- Session Management
- Create session
- Validate session
- Delete sessions based on age and logout
- Logout
- Delete users session
- Change Credentials
- Update user_identity
- Update user_password
- Delete User
- Remove credentials and session from database
Alpha testing phase
- Code refactoring
- Domain module
- Application module
- Infrastructure module
- Library
- Live testing
- Penetration testing
- Benchmarking
- Code Reviews