Secure session management, user registration, credential verification, and terminal access gating for axil. Canonical header is <ttypt/auth.h>.
git clone https://github.com/tty-pt/axil-authDocumentation
Manual Pages
axil-auth
Secure session management, user registration, credential verification, and terminal access gating for axil. Canonical header is<ttypt/auth.h>.
1. Quickstart: Run and Verify
Start Axil with axil-auth loaded:
axil -d -p 8080 -m libaxil-auth
Verified curl Walkthrough
# 1. Register an account
curl -s -X POST http://localhost:8080/auth/register \
-H "Content-Type: application/json" \
-d '{"username": "alice", "password": "CorrectHorseBatteryStaple!"}'
# 2. Log in and save session cookie
curl -s -i -X POST http://localhost:8080/auth/login \
-c cookies.txt \
-H "Content-Type: application/json" \
-d '{"username": "alice", "password": "CorrectHorseBatteryStaple!"}'
# 3. Verify session
curl -s http://localhost:8080/auth/api/session -b cookies.txt
# 4. Log out
curl -s -X POST http://localhost:8080/auth/logout -b cookies.txt
2. HTTP Endpoints
| Method | Endpoint | Auth | Description |
|---|---|---|---|
POST | /auth/register | Public | Register a new user account |
POST | /auth/login | Public | Authenticate credentials and issue session cookie |
GET | /auth/api/session | Public | Return current authentication status and username |
POST / GET | /auth/logout | Session | Invalidate current session token and clear cookie |
POST / GET | /auth/confirm | Token | Confirm email or invitation token |
3. Configuration & Multi-Instance Isolation
| Variable | Default | Description |
|---|---|---|
AXIL_AUTH_COOKIE | QSESSION (or QSESSION_<port>) | Name of the HTTP session cookie |
AXIL_AUTH_GID | 67 | POSIX Group ID assigned to newly created users |
AXIL_AUTH_GROUP | www | POSIX Group name assigned to newly created users |
AXIL_AUTH_DB | NULL | Optional path to persistent corm session database |
AXIL_AUTH_SHELL | /bin/false | Default login shell for newly registered accounts |
AUTH_SENDMAIL | /bin/femail / /usr/sbin/sendmail | Sendmail-compatible binary for registration confirmation emails (supports chrooted femail) |
AUTH_MAIL_FROM | (config default) | From: address for outgoing confirmation emails |
AUTH_MAIL_REQUIRED | 0 | Require successful mail delivery before completing registration |
AUTH_SKIP_CONFIRM | 0 | Skip email confirmation step (e.g. local dev/testing) |
When running multiple Axil instances simultaneously on the same host (e.g. :8080 and :4242), cookies automatically scope to QSESSION_<port> to prevent session collisions.
4. C API Integration
Consume authentication checks directly from other Axil modules or C daemons:
#include <stdio.h>
#include <ttypt/auth.h>
void check_user(const char *user, const char *pass) {
if (auth_password_matches(user, pass)) {
printf("User %s authenticated successfully.\n", user);
} else {
printf("Invalid credentials for %s.\n", user);
}
}
Compile and link:
cc my_module.c $(pkg-config --cflags --libs axil-auth) -o my_module
Privilege Separation & Signed TTY Tickets (POSIX)
When hosted inside a privilege-separated axil -u USER instance, axil-auth forks a jailed credential worker (auth_privsep_start_with_key(), auth_privsep_stop(), auth_privsep_register(), auth_privsep_confirm()) before setuid() drops privileges and mints HMAC-signed terminal tickets (auth_get_tty_ticket(), auth_ticket_verify()) for axil-tty.
5. Installation & Build
Prebuilt Packages
Prebuilt packages are distributed on tty.pt across all 9 platforms: Linux (APT / Alpine / Arch / Fedora-RHEL), macOS (Homebrew), Windows (winget / Scoop / MSYS2, using OpenSSL PBKDF2 + RAND_bytes), OpenBSD, and mobile static sysroots for Android (https://tty.pt/android/ โ arm64-v8a, x86_64) and iOS (https://tty.pt/ios/ โ libaxil-auth.xcframework + SwiftPM). Follow the installation instructions and use axil-auth as the package name.
NPM Package (@tty-pt/axil-auth)
npm config set @tty-pt:registry https://tty.pt/npm/
npm install @tty-pt/axil-auth
Build from Source
Builds use shared libstele rules (include ttypt/include.mk):
make # builds lib/libaxil-auth.so
make test # run unit and authentication test suite
sudo make install # install lib, headers, and axil-auth.pc to system
License
BSD 2-Clause License. Copyright (c) 2026, tty-pt. See LICENSE.