1. Go to this page and download the library: Download bemit/auth-middleware 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/ */
bemit / auth-middleware example snippets
use function DI\autowire;
use function DI\get;
$dependencies = [
// the middleware uses `AuthService and psr/http-factory implementation for responses
Bemit\AuthMiddleware\AuthMiddleware::class => autowire(),
Bemit\AuthMiddleware\AuthService::class => autowire()
->constructorParameter('issuer', $_ENV['AUTH_CLIENT_ISSUER'])
->constructorParameter('audience', $_ENV['AUTH_CLIENT_AUDIENCE'])
// use either frontend client id for e.g. APIs or otherwise same as for Auth0Service
->constructorParameter('client_id', $_ENV['AUTH0_CLIENT_ID_FRONTEND'])
->constructorParameter('namespace_user_data', 'https://userdata')
->constructorParameter('namespace_projects', 'https://id.namespace')
->constructorParameter('allowed_audiences', [
$_ENV['AUTH_CLIENT_AUDIENCE'],
])
// optional, for jwks caching:
->constructorParameter('cache', get(Psr\Cache\CacheItemPoolInterface::class))
->constructorParameter('cache_ttl', 360),
Bemit\AuthMiddleware\Auth0Service::class => autowire()
->constructorParameter('issuer', $_ENV['AUTH_CLIENT_ISSUER'])
->constructorParameter('client_id', $_ENV['AUTH0_CLIENT_ID'])
->constructorParameter('client_secret', $_ENV['AUTH0_CLIENT_SECRET'])
->constructorParameter('http_client', get(Psr\Http\Client\ClientInterface::class))
->constructorParameter('logger', get(Psr\Log\LoggerInterface::class)),
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.