2017 © Pedro Peláez
 

library api-key-bundle

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

image

uecode/api-key-bundle

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  • Thursday, November 24, 2016
  • by aequasi
  • Repository
  • 9 Watchers
  • 63 Stars
  • 35,733 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 32 Forks
  • 3 Open issues
  • 14 Versions
  • 6 % Grown

The README.md

ApiKey Bundle

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle., (*1)

Installation

Requires composer, install as follows, (*2)

composer require uecode/api-key-bundle dev-master

Enable Bundle

Place in your AppKernel.php to enable the bundle, (*3)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Uecode\Bundle\ApiKeyBundle\UecodeApiKeyBundle(),
    );
}

Configuration

You can change how the API key should be delivered and the name of the parameter its sent as. By default, this bundle looks for api_key in the query string., (*4)

uecode_api_key:
    delivery: query #or header
    parameter_name: some_value # defaults to `api_key`

Update user provider

This bundle provides two ways to work with User model:, (*5)

  1. use model and user provider provided by this bundle
  2. use custom user provider

Use model provided by this bundle

Entities

Assuming you already have a User class that extends the FOSUserBundle's base user model, change that extend, so its extending Uecode\Bundle\ApiKeyBundle\Model\ApiKeyUser, (*6)

Then update your schema., (*7)

Change used user provider

In your security, change your provider to the service uecode.api_key.provider.user_provider, (*8)

security:
    providers:
        db:
            id: uecode.api_key.provider.user_provider

    # Or

    providers:
        chain_provider:
            chain:
                providers: [db, memory]
        memory: # .....
        db:
            id: uecode.api_key.provider.user_provider

Use custom user provider

To work with this bundle your user provider should implement ApiKeyUserProviderInterface. It consist of one method for loading user by their apiKey. You should implement this interface for user provider which used in your api firewall:, (*9)

use Uecode\Bundle\ApiKeyBundle\Security\Authentication\Provider\ApiKeyUserProviderInterface;

class MyCustomUserProvider implements ApiKeyUserProviderInterface {
// ...

public function loadUserByApiKey($apiKey)
{
    return $this->userManager->findUserBy(array('apiKey' => $apiKey));
}

}

Change security settings

You can now add api_key: true, and stateless: true to any of your firewalls., (*10)

For Example:, (*11)

security:
    firewalls:
        auth:
            pattern: ^/api/*
            api_key: true
            stateless: true
            provider: db # Required if you have multiple providers and firewalls

The Versions

24/11 2016

dev-master

9999999-dev

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

Apache 2.0

The Requires

 

14/01 2016

3.0.0

3.0.0.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

Apache 2.0

The Requires

 

13/06 2015

2.1.0

2.1.0.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

Apache 2.0

The Requires

 

17/12 2014

2.0.1

2.0.1.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

Apache 2.0

The Requires

 

16/12 2014

2.0.0

2.0.0.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

Apache 2.0

The Requires

 

23/07 2014

1.0.2

1.0.2.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

Apache 2.0

The Requires

 

03/01 2014

1.0.1

1.0.1.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

The Requires

 

03/01 2014

1.0.0

1.0.0.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

The Requires

 

03/01 2014

0.0.7

0.0.7.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

The Requires

 

03/01 2014

0.0.6

0.0.6.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

The Requires

 

03/01 2014

0.0.5

0.0.5.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

The Requires

 

03/01 2014

0.0.4

0.0.4.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

The Requires

 

03/01 2014

0.0.3

0.0.3.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

The Requires

 

03/01 2014

0.0.2

0.0.2.0

Creates an avenue for using ApiKey authentication for Symfony2. Requires FOSUserBundle.

  Sources   Download

The Requires