PHP code example of brace / mod-auth-basic

1. Go to this page and download the library: Download brace/mod-auth-basic 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/ */

    

brace / mod-auth-basic example snippets


$app->pipe->addMiddleWare(
    new AuthBasicMiddleware(new \Brace\Auth\Basic\Validator\LambdaAuthValidator(
        function (\Brace\Auth\Basic\BasicAuthToken $basicAuthToken) {
            return $basicAuthToken->user === "client1" && $basicAuthToken->passwd === "test";
        }
    ))
);

$app->pipe->addMiddleWare(
    new AuthBasicMiddleware(new ClientIdFileAuthValidator(CONFIG_PATH . "/clients.yml"))
);

$basicAuthToken->validate();