PHP code example of fenrir-soft / authentication

1. Go to this page and download the library: Download fenrir-soft/authentication 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/ */

    

fenrir-soft / authentication example snippets




use Fenrir\Framework\MiddlewareCollection;
use Rocca\Cdn\Middlewares\AuthMiddleware;
use Rocca\Cdn\Services\JwtService;

return [
    ...
    JwtService::class => function () {
        return new JwtService(
            key: $_ENV['JWT_SECRET'],
            alg: $_ENV['JWT_ALG']
        );
    },
    MiddlewareCollection::class => function () {
        return new MiddlewareCollection(
            AuthMiddleware::class
        );
    },
    ...
]



class MyController {

    #[Route(path: '/admin')]
    #[Auth(roles: ["admin"], permissions: ["admin:access"], redirect_url: "admin/login")]
    public function index() {}
}