2017 © Pedro Peláez
 

symfony-bundle api-scope-bundle

Simple API query string scope recognizer

image

bartlomiejbeta/api-scope-bundle

Simple API query string scope recognizer

  • Sunday, February 18, 2018
  • by bartlomiejbeta
  • Repository
  • 1 Watchers
  • 0 Stars
  • 315 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 8 % Grown

The README.md

APIScopeBundle

This Symfony bundle aims to provide simple serialization group recognize from query string (with basic security check if you need it)., (*1)

Build Status, (*2)

Installation

1. Install via composer:
composer require bartlomiejbeta/api-scope-bundle
2. Register bundle in AppKernel:
public function registerBundles()
{
    $bundles = array(
        // ...
        new BartB\APIScopeBundle\APIScopeBundle(),
    );
}
3. Configure in config.yml:
api_scope:
    scopes:
        api.get_item: #route name
            always_included: #will be always included to scopes bag
                - 'first_always_included_group'
                - 'second_always_included_group'
            supported_key_map:
                external1: { internal_name: 'scope.internal_name1'} #if `external1` will be in the query string than `scope.internal_name1` will be in the scopes bag
                external2:
                    internal_name: 'scope.internal_name2'
                    security: 'can-add-external2-scope' # security voter (check symfony security voter) attribution name (to check if scope can be applied)

Usage

1. Simple

/**
* @ScopeConverter()
* @Rest\Route("/api/item", name="api.get_item")
*/
public function getCarCollection(Request $request, ScopeCollection $scopeCollection): Response
{
    $view = $this->view($scopeCollection, Response::HTTP_OK);

    $scopesFromQueryString = $scopeCollection->getScopes()

    return $this->handleView($view);
}
example request:
.../api/item?with[]=external1
example response:
{"scopes":["first_always_included_group","second_always_included_group","scope.internal_name1"]}

2. Configured

/**
* @ScopeConverter(value="scopes",queryString="scope")
* @Rest\Route("/api/item", name="api.get_item")
*/
public function getCarCollection(Request $request, ScopeCollection $scopes): Response
{
    $view = $this->view($scope,Response::HTTP_OK);

    scopesFromQueryString = $scopeCollection->getScopes()

    return $this->handleView($view);
}
example request:
.../api/item?scope[]=external1&scope[]=external2
example response:
{"scopes":["first_always_included_group","second_always_included_group","scope.internal_name1","scope.internal_name2"]}

The Versions

18/02 2018

dev-master

9999999-dev

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope

18/02 2018

v2.0.5

2.0.5.0

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope

18/02 2018

v2.0.4

2.0.4.0

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope

18/02 2018

v2.0.3

2.0.3.0

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope

18/02 2018

v2.0.2

2.0.2.0

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope

18/02 2018

v2.0.1

2.0.1.0

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope

18/02 2018

v2.0.0

2.0.0.0

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope

11/09 2017

1.0.1

1.0.1.0

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope

11/09 2017

1.0.0

1.0.0.0

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope

02/09 2017

0.1.0

0.1.0.0

Simple API query string scope recognizer

  Sources   Download

MIT

The Requires

 

The Development Requires

api serialization scope