madrakio / easy-api-authentication-bundle
Easy API Authentication Bundle: An easy way to get your API up and running with key based application authentication
Requires
- php: >=5.3.9
- ramsey/uuid: ^3.4
- symfony/symfony: >=2.8.0
This package is not auto-updated.
Last update: 2023-03-18 10:51:10 UTC
README
#Easy API Authentication Bundle
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require madrakio/easy-api-authentication-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new MadrakIO\Bundle\EasyApiAuthenticationBundle\MadrakIOEasyApiAuthenticationBundle(), ); // ... } // ... }
Step 3: Create your Application entity
<?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use MadrakIO\Bundle\EasyApiAuthenticationBundle\Entity\AbstractApplication; /** * Application * * @ORM\Table(name="application") */ class Application extends AbstractApplication { }
Step 4: Configure the Bundle
config.yml
madrak_io_easy_api_authentication: application_class: AppBundle\Entity\Application
security.yml
security: #... firewalls: api_secured: pattern: /api/.* stateless: true madrak_io_easy_api_authentication: true
Step 5: Sending Requests
To send a request to a Controller behind the MadrakIO Easy API Authentication Bundle you must send the following fields:
key
- A Public Key from the Application table
timestamp
- A timestamp within 300 seconds of the current timestamp
verification
- A verification string created by the requesting application that matches the check in ApiProvider.php