Download the PHP package preflow/auth without Composer
On this page you can find all versions of the php package preflow/auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package auth
Short Description Preflow auth — pluggable guards, session auth, API tokens, password hashing
License MIT
Informations about the package auth
Preflow Auth
Pluggable authentication for Preflow applications. Session-based login, API token guards, password hashing, and PSR-15 middleware.
Installation
Requires preflow/core and preflow/data.
What it does
- Pluggable guard system — session and bearer token guards ship as defaults, implement
GuardInterfacefor custom auth - Session management with CSRF protection (both in
preflow/core) - Password hashing via
password_hash()/password_verify()with transparent rehash support - PSR-15 middleware for route-level auth (
AuthMiddleware) and guest-only pages (GuestMiddleware) - Template functions:
auth_user(),auth_check(),csrf_token(),csrf_field(),flash() - Auto-discovered by
Application::boot()whenconfig/auth.phpexists
Configuration
config/auth.php:
User model
Implement the Authenticatable interface. Use AuthenticatableTrait for the common case:
The trait assumes $uuid, $passwordHash, and $roles properties. Override methods if your schema differs.
API
Guards
SessionGuard
Stores user ID in session key _auth_user_id. Regenerates session on login (session fixation prevention). Invalidates session on logout.
TokenGuard
Reads Authorization: Bearer <token> header. Looks up SHA-256 hashed token in user_tokens table. Stateless — login() and logout() are no-ops.
Password hashing
Middleware
Protect routes with #[Middleware] attributes:
GuestMiddleware redirects authenticated users away (for login/register pages).
Templates
CSRF helpers
Breaking change in v0.11:
csrf_token()now returns the raw token string. Usecsrf_field()for forms.
| Function | Returns |
|---|---|
csrf_token() |
Raw token string — useful for fetch() headers or meta tags |
csrf_field() |
Complete <input type="hidden" name="_token" value="..."> element |
Any template that previously used {{ csrf_token()|raw }} must be updated to {{ csrf_field() }}.
Custom guards
Implement GuardInterface:
Register in config/auth.php under guards.