Download the PHP package amreljako/secure-sanctum without Composer
On this page you can find all versions of the php package amreljako/secure-sanctum. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amreljako/secure-sanctum
More information about amreljako/secure-sanctum
Files in amreljako/secure-sanctum
Package secure-sanctum
Short Description Extended Laravel Sanctum authentication with advanced token security and management.
License MIT
Informations about the package secure-sanctum
SecureSanctum
SecureSanctum is a Laravel package that extends the capabilities of Laravel Sanctum by providing enhanced token management, device control, expiration handling, and advanced authentication flow.
Features
- Secure personal access token generation
- Token expiration (configurable)
- Device name storage
- Token abilities (scopes)
- Token revocation & cleanup
- Limit maximum devices per user
- Optional support for refresh tokens (configurable)
- Fully integrated with Laravel out of the box
Installation
Make sure you already have Laravel Sanctum installed.
Configuration
-
Publish the configuration file:
- The published config file:
config/secure_sanctum.php
Migration
Run the built-in migration to create the user_tokens table:
Routes
The package registers these routes automatically (under /api/secure-auth):
| Method | Endpoint | Description |
|---|---|---|
| POST | /login |
Issue a new token |
| POST | /logout |
Revoke current token |
| GET | /tokens |
List all user tokens |
Login Example
Request
Response
Token Usage
Add the token to your API requests using the Authorization header:
Token Schema
Table: user_tokens
| Column | Type | Description |
|---|---|---|
| user_id | foreign key | Linked user |
| token | string(64) | Hashed token |
| device_name | string | Device/browser identifier |
| abilities | JSON | Token permissions |
| expires_at | timestamp | Expiry date |
| last_used_at | timestamp | Last used time |
| created_at | timestamp | Created time |
| updated_at | timestamp | Updated time |
Programmatic Usage
You can create and validate tokens using the TokenManager service:
Validate a token manually:
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
This package is open-sourced software licensed under the MIT license.