Brize Auth
A tiny async authentication library.
Summary
A tool for simplifying authentication in the Rust ecosystems. Purposefully built to be agnostic of your specific business/schema logic for managing users. Primarily controls the user credentials and optionally managing sessions. Built asynchronously with the Tokio runtime, and supports MySql.
Credentials
Brize auth credentials has 3 fields, an id for linking to your specific business/schema logic, the user_identity which should be a unique way to identify a user such as an email, and a hashed_password. This will be stored in a user_credentials table on your database.
Sessions
The sessions are optional, in case you want to use some other session solution. If you do enable sessions, Brize auth offers classic table sessions, which have an id field as the token, created_at and expired_at for managing the expiration. The sessions will be stored in a user_sessions table on your database. A CSRF token is also available to use as csrf_token for form validation.
Setup
First install the crate
Next, set up the database tables with this schema, if using a SQL database
-- Credentials table
(
credentials_id CHAR(36) PRIMARY KEY,
user_name VARCHAR(255) NOT NULL,
hashed_password VARCHAR(255) NOT NULL
);
-- Sessions table
(
session_id CHAR(36) PRIMARY KEY,
created_at BIGINT UNSIGNED NOT NULL,
expires_at BIGINT UNSIGNED NOT NULL,
user_id VARCHAR(255) NOT NULL,
csrf_token CHAR(44) NOT NULL
);
Usage
MySql
use ;
use ;
Config
The preferred database and session expirations can be configured
use ;