bogosoft/http-auth

A library for PSR-7 and PSR-15 compliant authentication middleware.

1.0.0 2020-11-29 17:20 UTC

This package is auto-updated.

Last update: 2024-04-29 04:46:49 UTC


README

A PHP library for PSR-7 and PSR-15 compliant authentication middleware.

Requirements

  • PHP >= 7.4

Package Dependencies

Installation

composer require bogosoft/http-auth

Summary

This small library contains a PSR-15 compliant authentication middleware component, AuthenticationMiddleware, with the following responsibilities:

  • Derive a security context (IPrincipal object) from a PSR-7 compliant HTTP request. The IPrincipal contract is from the bogosoft/identity package.
  • Pass the derived security context to a IPrincipalHandler object on a successful authentication attempt.
  • Immediately return an HTTP response with a 401 Unauthorized status code on a failed authentication attempt. this is configurable.

Interfaces

Name Purpose
IAuthenticator Derives a security context (IPrincipal) from an HTTP request.
IPrincipalHandler Handles a derived security context and allows for HTTP request modification.

Implementations

Name Interface Details
CompositeAuthenticator IAuthenticator Allows multiple IAuthenticator objects to behave as one.
DelegatedAuthenticator IAuthenticator Turns a callable object in an IAuthenticator interface.
AuthenticationMiddleware MiddlewareInterface An authenticating middleware component.
AttributePrincipalHandler IPrincipalHandler Stores the derived IPrincipal object into a mutated HTTP request as an attribute.
DelegatedPrincipalHandler IPrincipalHandler Turns a callable object into a IPrincipalHandler.