brace/mod-auth-basic

Http Basic authentication

v1.0.0 2024-05-12 08:12 UTC

This package is auto-updated.

Last update: 2024-10-13 12:57:59 UTC


README

HTTP Basic Authentication

Example

Validate against closure function

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

Validate against File

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

Dont't forget to call

$basicAuthToken->validate();

To verify the Token is valid