kafkiansky / symfony-basic-auth-middleware
Basic Auth PSR-15 middleware for Symfony framework.
1.0.2
2021-08-25 08:35 UTC
Requires
- php: ^8.0
- nyholm/psr7: ^1.4
- psr/http-server-middleware: ^1.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-25 16:14:37 UTC
README
Contents
Installation
composer require kafkiansky/symfony-basic-auth-middleware
This package works with kafkiansky/symfony-middleware
, install it too, if didn't before:
composer require kafkiansky/symfony-middleware
Configuration
You can configure user, password, realm and excluded paths, if you want:
## services.yaml services: ... Kafkiansky\SymfonyMiddleware\AuthenticateBasic: arguments: $user: '%env(BASIC_HTTP_AUTH_USER)%' $password: '%env(BASIC_HTTP_AUTH_PASSWD)%' $realm: 'my-app' $excludedPaths: ## this is optional - '/test' $excludedPatterns: ## and this is optional - '/posts\/\\d+\\/edit/'
Usage
Use as single middleware
use Kafkiansky\SymfonyMiddleware\Attribute\Middleware; final class SomeController { #[Middleware([Kafkiansky\SymfonyMiddleware\AuthenticateBasic::class])] public function index() {} }
Use as global middleware
## symmidleware.yaml symiddleware: global: - Kafkiansky\SymfonyMiddleware\AuthenticateBasic
Use as group middleware
## symmidleware.yaml symiddleware: groups: web: - Kafkiansky\SymfonyMiddleware\AuthenticateBasic
use Kafkiansky\SymfonyMiddleware\Attribute\Middleware; final class SomeController { #[Middleware(['web'])] public function index() {} }
use Kafkiansky\SymfonyMiddleware\Attribute\Middleware; #[Middleware(['web'])] final class SomeController { public function index() {} }
Testing
$ composer test
License
The MIT License (MIT). See License File for more information.