AuthorizationMiddleware
extends BaseAuthorizationMiddleware
in package
Table of Contents
- $accessRepository : IAccessRepository
- $logger : LoggerInterface
- $request : ServerRequestInterface
- HTTP request
- $subject : string
- $subjectId : int|null
- $userAccess : Access
- $reservationRepository : IReservationRepository
- $userRepository : IUserRepository
- __construct() : mixed
- process() : ResponseInterface
- abstracts away logic needed for all other middlewares
- getMethod() : string
- gets method of the request
- getPath() : string
- gets path of the request
- getSession() : object
- returns session object with token data
- processRequest() : ResponseInterface
- Process an incoming server request
- resolveAccess() : bool
- returns false if user doesn't have an access to operation
- getResolver() : callable
- returns access resolver function for the current user
- resolvePremisesAccess() : bool
- validates if user has access to 'premises resources'
- resolveReservationAccess() : bool
- validates if user has access to reservations functionality
- resolveUserAccess() : bool
- Validates if the user has access to edit user
- setRequestSubject() : void
- gets subject and subject id (if exists) from the request path i.e: /users/1 => subject = 'users'; subjectId = 1
Properties
$accessRepository
protected
IAccessRepository
$accessRepository
$logger
protected
LoggerInterface
$logger
$request
HTTP request
protected
ServerRequestInterface
$request
$subject
protected
string
$subject
$subjectId
protected
int|null
$subjectId
= NULL
$userAccess
protected
Access
$userAccess
$reservationRepository
private
IReservationRepository
$reservationRepository
$userRepository
private
IUserRepository
$userRepository
Methods
__construct()
public
__construct(IUserRepository $userRepository, IReservationRepository $reservationRepository, IAccessRepository $accessRepository, LoggerInterface $logger) : mixed
Parameters
- $userRepository : IUserRepository
- $reservationRepository : IReservationRepository
- $accessRepository : IAccessRepository
- $logger : LoggerInterface
Return values
mixed —process()
abstracts away logic needed for all other middlewares
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface
Return values
ResponseInterface —getMethod()
gets method of the request
protected
getMethod() : string
Return values
string —getPath()
gets path of the request
protected
getPath() : string
Return values
string —getSession()
returns session object with token data
protected
getSession() : object
Return values
object —processRequest()
Process an incoming server request
protected
abstract processRequest(RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $handler : RequestHandlerInterface
Return values
ResponseInterface —resolveAccess()
returns false if user doesn't have an access to operation
protected
resolveAccess() : bool
Return values
bool —getResolver()
returns access resolver function for the current user
private
getResolver() : callable
Return values
callable —resolvePremisesAccess()
validates if user has access to 'premises resources'
private
resolvePremisesAccess() : bool
Return values
bool —resolveReservationAccess()
validates if user has access to reservations functionality
private
resolveReservationAccess() : bool
Return values
bool —resolveUserAccess()
Validates if the user has access to edit user
private
resolveUserAccess() : bool
Return values
bool —setRequestSubject()
gets subject and subject id (if exists) from the request path i.e: /users/1 => subject = 'users'; subjectId = 1
private
setRequestSubject() : void