PHP code example of los / api-auth
1. Go to this page and download the library: Download los/api-auth library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
los / api-auth example snippets
return [
\Los\ApiAuth\ApiAuth::class => \Los\ApiAuth\ApiAuthFactory::class,
\Los\ApiAuth\Strategy\Strategy::class => \Los\ApiAuth\Strategy\XApiKeyHeader::class,
\Los\ApiAuth\Authenticator\Authenticator::class => \Los\ApiAuth\Authenticator\ArrayAuthenticatorFactory::class,
\Los\ApiAuth\Output\Output::class => \Los\ApiAuth\Output\ProblemDetailsOutputFactory::class,
];
$app->pipe(\Los\ApiAuth\ApiAuth::class);
declare(strict_types=1);
use Los\ApiAuth\ApiAuth;
use Los\ApiAuth\ApiAuthFactory;
use Los\ApiAuth\Authenticator\ArrayAuthenticatorFactory;
use Los\ApiAuth\Authenticator\Authenticator;
use Los\ApiAuth\Output\Output;
use Los\ApiAuth\Output\ProblemDetailsOutputFactory;
use Los\ApiAuth\Strategy\BasicAuthorizationHeader;
use Los\ApiAuth\Strategy\Strategy;
return [
'dependencies' => [
'invokables' => [
Strategy::class => BasicAuthorizationHeader::class,
],
'factories' => [
ApiAuth::class => ApiAuthFactory::class,
Authenticator::class => ArrayAuthenticatorFactory::class,
Output::class => ProblemDetailsOutputFactory::class,
],
],
'api-auth' => [
'ignorePaths' => ['/health'],
'identities' => ['707cd425-0a60-4d36-b2e8-c9fd7fc0f194' => '208bfbc5-e705-46b1-aec0-2b0e1b4156ad'],
],
];