Download the PHP package devinci-it/shadow-auth without Composer
On this page you can find all versions of the php package devinci-it/shadow-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devinci-it/shadow-auth
More information about devinci-it/shadow-auth
Files in devinci-it/shadow-auth
Package shadow-auth
Short Description Lightweight file-based PHP authentication library with optional TOTP.
License MIT
Informations about the package shadow-auth
Devinci Shadow Auth
A lightweight, file-based PHP authentication library with optional TOTP 2FA, CSRF protection, and simple processor/form helpers for classic server-rendered apps.
Table of Contents
- Requirements
- Installation
- Quick Start
- Architecture
- Configuration
- Auth Flows
- Facade API
- Publishing Demo, Endpoints, and Wiki
- Serve Demo Locally
- Class Wiki
- Security Notes
- Release and Tagging
- License
Requirements
- PHP
>=8.1 - Composer (for package install and autoload)
Installation
Install through Composer:
If you are developing this package locally in another app, use a Composer path repository:
Then update dependencies:
Quick Start
1. Bootstrap
2. Register
3. Login
4. Route Guard
Architecture
Namespace root: DevinciIT\ShadowAuth\
Main components:
Core: business logic managers and config.Facade: static API for app code.Providers: persistence layer (FileUserProvider).Processors: request handlers for login/register/reset/TOTP forms.Services: reusable services (TwoFactorService).Utils: utility helpers (CSRF).View: form builders with CSRF injection.Publisher: file publishing utilities for demo/endpoints/wiki.Shadow\Facade\Auth: compatibility alias facade.
Configuration
Configure with DevinciIT\ShadowAuth\Core\Config::set([...]).
Supported keys:
storage_path(string, required): path to PHP array storage file.session_key(string, optional): auth session key. Default:shadow_auth_user.totp_enabled(bool, optional): global TOTP toggle. Default:true.registration_constraints(array, optional): unique/case-insensitive field rules.
Example:
Auth Flows
Username/password only
Auth::beginLogin($username, $password)- Returns
authenticatedand session is established.
Username/password + TOTP
Auth::beginLogin(...)- Returns
totp_requiredand writes pending state in session. Auth::verifyPendingTotp($code)finalizes login.
Password reset
Auth::requestPasswordResetToken($identifier)returns token (demo mode usage).- Validate before submit with
Auth::hasValidPasswordResetToken($token). - Complete with
Auth::resetPasswordWithToken($token, $newPassword).
Facade API
Available methods in DevinciIT\ShadowAuth\Facade\Auth:
boot(): voidregister(string $username, string $password): boolregisterWithData(string $username, string $password, array $attributes): boolregistrationError(): ?stringattempt(string $username, string $password, ?string $totp = null): boolbeginLogin(string $username, string $password): stringverifyPendingTotp(string $code): boolisTotpPending(): boolpendingUsername(): ?stringcheck(): boolrequireAuth(string $redirectTo = '/views/login.php'): voiduser(): ?arraylogout(): voidsetupTotpSecret(string $username): ?stringconfirmTotp(string $username, string $code): booldisableTotp(string $username): boolenableTotp(): voiddisableTotpGlobally(): voidrequestPasswordResetToken(string $identifier): ?stringhasValidPasswordResetToken(string $token): boolresetPasswordWithToken(string $token, string $newPassword): bool
Publishing Demo, Endpoints, and Wiki
This package includes bin/shadow-auth-publish-demo with multiple modes.
Composer script aliases:
Serve Demo Locally
Use the dedicated helper to create an isolated demo in /tmp, generate a proper composer.json, install dependencies, and run PHP's local server.
Default behavior:
- Creates target directory under
/tmp/shadow-auth-demo-* - Copies
bootstrap.php,src/,public/, andviews/ - Writes
composer.jsonfrom the demo template with local PSR-4 autoload - Runs
composer install(nodevinci-it/shadow-authself-dependency required) - Serves
http://127.0.0.1:8500withphp -S 127.0.0.1:8500 -t public
Useful flags:
Composer alias:
Class Wiki
Detailed per-class documentation is under docs/wiki/.
- Wiki index:
docs/wiki/README.md - Class pages:
docs/wiki/classes/
Security Notes
- Keep storage files outside the public web root where possible.
- Apply restrictive permissions (
0700for directory,0600for file). - Always use HTTPS in production.
- Regenerate session IDs after successful authentication.
- Validate CSRF tokens on all state-changing requests.
- Treat demo password reset tokens as sensitive and short-lived.
Release and Tagging
Create an annotated tag with helper script:
Composer aliases:
License
MIT