Middleware implements MiddlewareInterface
Routing Middleware that uses nikic/fastroute Based on Middlewares\FastRoute with the addition of routes definition processing and additionl route parameters outside of route patterns
Tags
Interfaces, Classes and Traits
- MiddlewareInterface
Table of Contents
- $authFactory : AuthFactory
- Auth factory instance
- $cookie : VanillaCookieExtended
- $DIContainer : ContainerInterface
- $actions : mixed
- $area : mixed
- $request : ServerRequestInterface
- $signInMethods : mixed
- __construct() : mixed
- Constructor
- process() : ResponseInterface
- Process a server request and return a response.
- getUserData() : object
- Gets user data
- isAuthenticated() : mixed
- Gets authentication status
- loadPermissionsRoles() : mixed
- Loads permissions for roles from permissions - roles map file
- setAuthenticationStatus() : mixed
- Sets authentication status into request
- setAuthFactory() : mixed
- Sets auth factory instance
- setUserData() : mixed
- Sets user data both in session and request
- setUserRole() : mixed
- Sets user role from users - roles map file
- signIn() : int
- Performs sign in
- signInCustom() : int
- Checks sign in by a custom method
- signInWithDb() : int
- Checks sign in by db method
- signInWithHtpasswd() : int
- Checks sign in by htpasswd method
- signOut() : mixed
- Signs out
- verify() : int
- Performs verification
Properties
$authFactory
Auth factory instance
protected
AuthFactory
$authFactory
$cookie
protected
VanillaCookieExtended
$cookie
$DIContainer
protected
ContainerInterface
$DIContainer
$actions
private
mixed
$actions
= ['sign-in', 'verify', 'sign-out']
$area
private
mixed
$area
$request
private
ServerRequestInterface
$request
$signInMethods
private
mixed
$signInMethods
= ['htpasswd', 'db', 'custom']
Methods
__construct()
Constructor
public
__construct(ContainerInterface $DIContainer, VanillaCookieExtended $cookie) : mixed
Parameters
- $DIContainer : ContainerInterface
- $cookie : VanillaCookieExtended
Return values
mixed —process()
Process a server request and return a response.
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface
Return values
ResponseInterface —getUserData()
Gets user data
protected
getUserData() : object
Return values
object —isAuthenticated()
Gets authentication status
protected
isAuthenticated() : mixed
Return values
mixed —loadPermissionsRoles()
Loads permissions for roles from permissions - roles map file
protected
loadPermissionsRoles(object $authenticationParameters) : mixed
Parameters
- $authenticationParameters : object
Return values
mixed —setAuthenticationStatus()
Sets authentication status into request
protected
setAuthenticationStatus(mixed $authenticated[, mixed $returnCode = null ][, mixed $redirectTo = null ]) : mixed
Parameters
- $authenticated : mixed
- $returnCode : mixed = null
- $redirectTo : mixed = null
Return values
mixed —setAuthFactory()
Sets auth factory instance
protected
setAuthFactory() : mixed
Return values
mixed —setUserData()
Sets user data both in session and request
protected
setUserData([mixed $userData = null ]) : mixed
Parameters
- $userData : mixed = null
Return values
mixed —setUserRole()
Sets user role from users - roles map file
protected
setUserRole(object $authenticationParameters) : mixed
Parameters
- $authenticationParameters : object
Return values
mixed —signIn()
Performs sign in
private
signIn(object $authenticationParameters) : int
Parameters
- $authenticationParameters : object
Return values
int —: 1 = missing field 2 = wrong username 3 = wrong password 4 = correct sign in 5 = custom validation failed
signInCustom()
Checks sign in by a custom method
private
signInCustom(string $handlerName, string $handlerMethod) : int
Parameters
- $handlerName : string
- $handlerMethod : string
Return values
int —return code: 4 = sign in correct | 5 = custom validation failed
signInWithDb()
Checks sign in by db method
private
signInWithDb(string $username, string $password, string $pathToDbConfigFile, string $algo, string $table, array<string|int, mixed> $fields[, string $condition = null ]) : int
Parameters
- $username : string
- $password : string
- $pathToDbConfigFile : string
-
path to db configuration file
- $algo : string
-
hashing algorithm for the hash() function, see https://github.com/auraphp/Aura.Auth PDO Adapter
- $table : string
-
table or view to be quieried
- $fields : array<string|int, mixed>
- $condition : string = null
Return values
int —return code: 2 = wrong username, 3 = wrong password, 4 = sign in correct
signInWithHtpasswd()
Checks sign in by htpasswd method
private
signInWithHtpasswd(string $username, string $password, string $pathToHtpasswdFile) : int
Parameters
- $username : string
- $password : string
- $pathToHtpasswdFile : string
-
path to htpassword file
Return values
int —return code: 2 = wrong username, 3 = wrong password, 4 = sign in correct
signOut()
Signs out
private
signOut(object $authenticationParameters) : mixed
Parameters
- $authenticationParameters : object
Return values
mixed —verify()
Performs verification
private
verify(object $authenticationParameters) : int
Parameters
- $authenticationParameters : object
Return values
int —: 1 = missing field 2 = wrong username 3 = wrong password 4 = correct sign in