happyr/api-bundle

Api stuff for most Happyr projects

Installs: 24 336

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 2

Open Issues: 1

Type:symfony-bundle

0.5.1 2018-10-10 13:44 UTC

This package is auto-updated.

Last update: 2024-03-27 05:12:43 UTC


README

Latest Version Software License Build Status Code Coverage Quality Score Total Downloads

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