happyr / api-bundle
Api stuff for most Happyr projects
0.5.1
2018-10-10 13:44 UTC
Requires
- php: ^7.0
- league/fractal: ^0.16.0
- psr/cache: ^1.0
- symfony/framework-bundle: ^3.3 || ^4.0
- symfony/http-foundation: ^3.3 || ^4.0
- symfony/security-bundle: ^3.3 || ^4.0
- symfony/validator: ^3.3 || ^4.0
Requires (Dev)
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
To Install
Run the following in your project root, assuming you have composer set up for your project
composer require happyr/api-bundle
Add the bundle to app/AppKernel.php
$bundles = [ // ... new Happyr\ApiBundle\HappyrApiBundle(), ];
Security
Wsse is built in and can be enabled - disabled by default.
To enable and configure it, in config.yml add
happyr_api: wsse: user_provider: "security.user.provider.concrete.in_memory" cache_service: "cache.provider.redis" lifetime: 300 debug: false # Set to true to disable WSSE completely. You will always be authenticated.
And in security.yml configure your provider where you store users to something like this
security: providers: in_memory: memory: users: username: password: password roles: ['ROLE_API_USER']
And under firewalls in security.yml, add a new firewall like so
security: firewalls: main: pattern: ^/api/ stateless: true wsse: true
Exception listener
Exception listener is enabled by default. It will catch uncaught exceptions and return formatted json response.
Here is an example configuration:
happyr_api: exception_listener: enabled: false # disables response listener path_prefix: '/api/' # path prefix to enable listener on. By default its enabled for any path