Developed with love by KnpLabs Hire us for your project!
22

security-api-bundle

by OsLab

Security API bundle

OsLab security API bundle

A bundle for securing ReST api calls.

Build Status
Scrutinizer Code Quality
Code Coverage
Total Downloads
Latest Stable Version
License

Introduction

This bundle allows you to add an authentication mechanism with a token easily to your APIs.

Once you've configured everything, you'll be able to authenticate by adding an key parameter to the query string, like http://example.com/api/users?key=1x4c40nwh96080gk70f7k5awz9k6tczqs3jr01z94849n
or add through a header your token.

Installation

Step 1: Download OsLabSecurityApiBundle using Composer

Require the bundle with composer:

$ composer require oslab/security-api-bundle:"~1.0"

Or you can add it in the composer.json. Just check Packagist for the version you want to install (in the following example, we used "1.0") and add it to your composer.json:

    {
        "require": {
            "oslab/security-api-bundle": "~1.0"
        }
    }

Step 2: Enable the bundle

Finally, enable the bundle in the kernel:

    // app/AppKernel.php

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new OsLab\SecurityApiBundle\OsLabSecurityApiBundle(),
        );
    }

Step 3: Configure your application's security.yml

    role_hierarchy:
        ROLE_API: ROLE_API

    ...

    providers:
        chain_provider:
            chain:
                providers: [api_provider]

        ...

        api_provider:
            memory_api:
                users:
                    micro_service_asset:
                        password: '1x4c40nwh96080gk70f7k5awz9k6tczqs3jr01z94849n'
                        roles: 'ROLE_API'
                    external_api_customer:
                        password: 'j6eef2w0689a6if50c365v2zq0c855ywgyt106j2b6q5h'
                        roles: 'ROLE_API'
        ...

    firewalls:
        ...

        api_secured:
            pattern: ^/api/*
            stateless: true
            simple_preauth:
                authenticator: oslab_security_api.security.authentication.authenticator
            provider: api_provider

        main:
            anonymous: ~

        ...

    access_control:
        ...
        - { path: ^/api/*, roles: [ROLE_API]}
        ...

Credits

License

Security API bundle is released under the MIT License, you agree to license your code under the MIT license

Copyright (c) 2015-2017 OsLab

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OFCONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
oslab_security_api:
authentication:
method: query # Required
key_name: key # Required
  • Merge pull request #23 from 20uf/fix/cs
    By web-flow, 7 months ago
  • Add newline at end of file
    By , 7 months ago
  • Remove idea
    By 20uf, 7 months ago
  • Fix cs
    By , 7 months ago
  • Merge pull request #22 from 20uf/fix/readme
    By web-flow, 9 months ago
  • Fix badges
    By 20uf, 9 months ago
  • Merge pull request #21 from 20uf/fix/phpcs
    By web-flow, 9 months ago
  • Fix phpcs header comment
    By 20uf, 9 months ago
  • Merge pull request #20 from 20uf/feat/add-php-css
    By web-flow, 1 year ago
  • [Fix] Remove 5.5 tests on travis
    By 20uf, 1 year ago
  • [feat] Ignore php cs cache
    By 20uf, 1 year ago
  • [feat] Fix & improve QA
    By 20uf, 1 year ago
  • [feat] Add php cs
    By 20uf, 1 year ago
  • Update README.md
    By web-flow, 1 year ago
  • Merge pull request #19 from 20uf/fix/version-3.0
    By web-flow, 1 year ago
  • Remove dev stability & rollback DefinitionDecorator =< 3.2 security component
    By 20uf, 1 year ago
  • Merge pull request #18 from 20uf/composer/allow-3.0
    By web-flow, 1 year ago
  • Fix deprecated class
    By 20uf, 1 year ago
  • Update composer to allow symfony components 2.7 || 3.0
    By 20uf, 1 year ago
  • Merge pull request #17 from 20uf/fix/qa
    By web-flow, 1 year ago
  • [Fix] Spacing
    By 20uf, 1 year ago
  • Merge pull request #16 from 20uf/fix/qa
    By web-flow, 1 year ago
  • [Fix] remove not used assignment.
    By 20uf, 1 year ago
  • Merge pull request #14 from 20uf/fix/travis
    By web-flow, 1 year ago
  • [Fix] command phpunit
    By 20uf, 1 year ago
  • [Fix] Coverage travis
    By 20uf, 1 year ago
  • Update README.md
    By web-flow, 1 year ago
  • Update README.md
    By web-flow, 1 year ago
  • Merge pull request #13 from OsLab/Add-coveralls
    By web-flow, 1 year ago
  • Create .coveralls.yml
    By web-flow, 1 year ago