class BasicAuthenticationMiddleware (View source)

HTTP Basic Authentication Middleware

This middleware processes HTTP Basic Authentication credentials and authenticates the user

Methods

__construct(PDO $db, ConfigurationManager $config)

Constructor

int
getAuthenticatedUserId(Request $request)

Get authenticated user ID from Basic Auth credentials (stateless)

JsonResponse
handleUnauthenticated()

Handle unauthenticated request by sending a 401 response with WWW-Authenticate header

Details

__construct(PDO $db, ConfigurationManager $config)

Constructor

Parameters

PDO $db

Database connection

ConfigurationManager $config

Configuration manager

int getAuthenticatedUserId(Request $request)

Get authenticated user ID from Basic Auth credentials (stateless)

Parameters

Request $request

The HTTP request

Return Value

int

User ID if authenticated, 0 otherwise

JsonResponse handleUnauthenticated()

Handle unauthenticated request by sending a 401 response with WWW-Authenticate header

Return Value

JsonResponse