Skip to content

Latest commit

 

History

History
36 lines (26 loc) · 867 Bytes

README.md

File metadata and controls

36 lines (26 loc) · 867 Bytes

marko/authentication

Session and token-based authentication---guards protect routes, remember-me keeps users signed in, events track activity, middleware controls access.

Installation

composer require marko/authentication

Quick Example

use Marko\Authentication\AuthManager;
use Marko\Routing\Http\Response;

class LoginController
{
    public function __construct(
        private AuthManager $authManager,
    ) {}

    public function login(array $credentials): Response
    {
        if ($this->authManager->attempt($credentials)) {
            return Response::redirect('/dashboard');
        }

        return new Response('Invalid credentials', 401);
    }
}

Documentation

Full usage, configuration, remember-me setup, events, and API reference: marko/authentication