quillphp / key-auth
API Key authentication middleware for the Quill PHP framework
dev-main
2026-04-06 10:03 UTC
Requires
- php: ^8.3
- quillphp/quill: ^0.0.2
Requires (Dev)
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2026-04-06 11:57:04 UTC
README
High-speed API Key authentication middleware for the Quill PHP Framework.
Installation
composer require quillphp/key-auth
Usage
use Quill\KeyAuth\KeyAuth; $app->use(KeyAuth::new([ 'keys' => ['secret-api-key-1', 'secret-api-key-2'], 'header' => 'X-API-Key', ]));
Configuration
| Option | Default | Description |
|---|---|---|
| `query` | `'api_key'` | The URL query parameter to check. |
| `keys` | `[]` | An array of valid API keys. |
| `validator` | `null` | Custom validator closure: `fn(string $key) => bool`. |
| `error_code` | `401` | The error code to return for unauthorized requests. |
| `error_message` | `'Unauthorized: Invalid or missing API Key'` | The error message to return. |
License
MIT