adachsoft / auth-symfony-bundle
Symfony bundle with login, logout and current-account endpoints, bearer-token authentication of API requests and permission checks backed by adachsoft/auth-contracts and adachsoft/access-control-contracts.
Package info
gitlab.com/a.adach/auth-symfony-bundle
Type:symfony-bundle
pkg:composer/adachsoft/auth-symfony-bundle
Requires
- php: ^8.3
- adachsoft/access-control-contracts: ^0.1
- adachsoft/access-control-json-file: ^0.1
- adachsoft/auth-contracts: ^0.2
- adachsoft/auth-json-file: ^0.2
- adachsoft/rule-evaluator-expression-language: ^0.1
- symfony/config: ^7.0 || ^8.0
- symfony/console: ^7.0 || ^8.0
- symfony/dependency-injection: ^7.0 || ^8.0
- symfony/framework-bundle: ^7.0 || ^8.0
- symfony/http-foundation: ^7.0 || ^8.0
- symfony/http-kernel: ^7.0 || ^8.0
- symfony/routing: ^7.0 || ^8.0
- symfony/yaml: ^7.0 || ^8.0
Requires (Dev)
- adachsoft/php-code-style: ^0.7.2
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.4
- rector/rector: ^2.8
- symfony/browser-kit: ^7.0 || ^8.0
- symplify/phpstan-rules: ^14.19
- zircote/swagger-php: ^5.3
Suggests
- zircote/swagger-php: The controllers carry OpenAPI attributes; install it to include the auth endpoints in generated API documentation.
Provides
None
Conflicts
None
Replaces
None
README
adachsoft/auth-symfony-bundle adds authentication and permission-checking endpoints to a Symfony application. It provides password-based login and logout, current-account information, bearer-token authentication for API requests, and role-based permission checks backed by AdachSoft contracts.
Features
- Login, logout, current-account, password-change, and permission-check endpoints.
- Bearer-token authentication with sessions, long-lived API keys, and an optional bootstrap token.
- API-key management endpoints and console commands, with role-based permissions and configurable protected/public routes.
- Route-level permission checks and an access-checking service for application code.
- User administration endpoints (list, create, change, remove) guarded by
user.*permissions. - Console commands for managing accounts.
- Replaceable storage and authentication collaborators.
Installation
composer require adachsoft/auth-symfony-bundle
Register the bundle in config/bundles.php:
return [
// ...
AdachSoft\AuthSymfonyBundle\AdachSoftAuthBundle::class => ['all' => true],
];
Import its routes in config/routes.yaml:
adachsoft_auth:
resource: '@AdachSoftAuthBundle/Resources/config/routes.yaml'
The bundle uses JSON files for credentials, sessions, API-key metadata, accounts, and access-control definitions by default. Configure their locations, API-key policy, optional bootstrap token, and authentication policy in config/packages/adachsoft_auth.yaml. Keep authentication data outside the web root and out of version control.
Create an access-control definitions file and an initial user with the auth:user:create console command. The auth:api-key:create command displays a service key once; auth:api-key:list and auth:api-key:revoke provide recovery and key lifecycle management. See the reference and usage examples for configuration and protecting application routes.
Documentation
- Reference: configuration, API, formats and commands in full
- Authentication and permission examples
The bundle does not require symfony/security-bundle; it can be added without replacing an application's existing Symfony security configuration. API keys inherit their account's role permissions; use api_key.manage only for keys belonging to other accounts. Keep bootstrap tokens temporary and rotate or unset them after recovery.