sunxyw/spiral-auth0-bridge

This is my package spiral-auth0-bridge

v0.6.0 2023-08-05 12:54 UTC

This package is auto-updated.

Last update: 2024-04-05 14:21:42 UTC


README

PHP Version Require Latest Stable Version phpunit psalm Codecov Total Downloads

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Requirements

Make sure that your server is configured with following PHP version and extensions:

  • PHP 8.1+
  • Spiral framework 3.0+

Installation

You can install the package via composer:

composer require sunxyw/spiral-auth0-bridge

After package install you need to register bootloader from the package.

protected const LOAD = [
    // ...
    \Sunxyw\SpiralAuth0Bridge\Bootloader\Auth0BridgeBootloader::class,
];

Note: if you are using spiral-packages/discoverer, you don't need to register bootloader by yourself.

Usage

Register the \Sunxyw\SpiralAuth0Bridge\Security\Auth0TokenStorage token storage via config or bootloader, you may find documentation here.

Then, register the actor provider \Sunxyw\SpiralAuth0Bridge\Security\Auth0ActorProvider via bootloader too, documentation may find here.

You may want to scroll down the documentation page to find the registration steps.

Please remember to configure your AuthTransportMiddleware too, otherwise, Auth0 bridge will not able to retrieve the token. Docs.

After that, you can obtain the actor using AuthContextInterface.

public function index(\Spiral\Auth\AuthContextInterface $auth)
{
    if ($auth->getActor() === null) {
        throw new ForbiddenException();
    }

    dump($auth->getActor());
}

The actor will be an instance of \Sunxyw\SpiralAuth0Bridge\Security\Auth0Actor.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.