Creates a firewall for using ApiKey application authentication for Symfony2.
This bundle is highly based on uecode/api-key-bundle
Requires composer, install as follows
composer require mkosiedowski/simple-api-key-bundle dev-masterPlace in your AppKernel.php to enable the bundle
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new mkosiedowski\SimpleApiKeyBundle\SimpleApiKeyBundle(),
);
}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 apiKey in the query string.
simple_api_key:
delivery: query #or header
parameter_name: some_value # defaults to `api_key`Applications are stored in applicationKeys table by default.
You should register Doctrine Entities mapping with your doctrine configuration:
doctrine:
orm:
entity_managers:
default:
mappings:
SimpleApiKeyBundle:
type: annotation
dir: Entity
is_bundle: trueYou can now add simple_api_key: true to any of your firewalls.
For Example:
security:
firewalls:
auth:
pattern: ^/api/*
simple_api_key: true
stateless: true