mkosiedowski/simple-api-key-bundle

Creates an avenue for using ApiKey app authentication for Symfony2 without user authentication

0.1.0 2019-11-25 15:37 UTC

This package is auto-updated.

Last update: 2024-09-26 08:24:06 UTC


README

Creates a firewall for using ApiKey application authentication for Symfony2.

This bundle is highly based on uecode/api-key-bundle

Installation

Requires composer, install as follows

composer require mkosiedowski/simple-api-key-bundle dev-master

Enable Bundle

Place in your AppKernel.php to enable the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new mkosiedowski\SimpleApiKeyBundle\SimpleApiKeyBundle(),
    );
}

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 apiKey in the query string.

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

Applications repository

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: true

Change security settings

You 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