Download the PHP package fyre/auth without Composer
On this page you can find all versions of the php package fyre/auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package auth
FyreAuth
FyreAuth is a free, open-source authentication/authorization library for PHP.
Table Of Contents
- Installation
- Auth
- Identity
- Access
- Policy Registry
- Policies
- Authenticators
- Cookie
- Session
- Token
- Middleware
Installation
Using Composer
In PHP:
Auth
The Auth class provides the basis for authentication.
Instance
Load a shared Auth instance.
Set Instance
Set a shared Auth instance.
$instance
is an Auth, or a Closure that returns an Auth.
Auth Methods
Add Authenticator
$authenticator
is an Authenticator.$key
is a string representing the authenticator key, and will default to the Authenticator class name.
Attempt
Attempt to login as a user.
$identifier
is a string representing the user identifier.$password
is a string representing the user password.$rememberMe
is a boolean indicating whether the user should be remembered, and will default to false.
Authenticator
Get an authenticator by key.
$key
is a string representing the authenticator key.
Authenticators
Get the authenticators.
Is Logged In
Determine if the current user is logged in.
Login
Login as a user.
$user
is an Entity representing the user.$rememberMe
is a boolean indicating whether the user should be remembered, and will default to false.
Logout
Logout the current user.
User
Get the current user.
Identity
The Identity class provides the basis for user identification.
Attempt
Attempt to identify a user.
$identifier
is a string representing the user identifier.$password
is a string representing the user password.
Get Identifier Fields
Get the user identifier fields.
Get Model
Get the identity Model.
Get Password Field
Get the user password field.
Identify
Find an identity by identifier.
$identifier
is a string representing the user identifier.
Set Identifier Fields
Get the user identifier fields.
$identifierFields
is an array containing the user identifier fields.
Set Model
Set the identity Model.
$model
is a Model.
Set Password Field
Get the user password field.
$passwordField
is an string representing the user password field.
Access
The Access class provides the basis for authorization.
After
Execute a callback after checking rules.
$afterCallback
is a Closure that accepts the current user, access rule name, current result and any additional arguments.
Allows
Check whether an access rule is allowed.
$rule
is a string representing the access rule name or Policy method.
Any additional arguments supplied will be passed to the access rule callback or Policy method.
Any
Check whether any access rule is allowed.
$rules
is an array containing access rule names or Policy methods.
Any additional arguments supplied will be passed to the access rule callbacks or Policy methods.
Authorize
Authorize an access rule.
$rule
is a string representing the access rule name or Policy method.
Any additional arguments supplied will be passed to the access rule callback or Policy method.
Before
Execute a callback before checking rules.
$beforeCallback
is a Closure that accepts the current user, access rule name and any additional arguments.
Clear
Clear all rules and callbacks.
Define
Define an access rule.
$rule
is a string representing the access rule name.$callback
is a Closure that accepts the current user and any additional arguments.
Denies
Check whether an access rule is not allowed.
$rule
is a string representing the access rule name or Policy method.
Any additional arguments supplied will be passed to the access rule callback or Policy method.
None
Check whether no access rule is allowed.
$rules
is an array containing access rule names or Policy methods.
Any additional arguments supplied will be passed to the access rule callbacks or Policy methods.
Policy Registry
Add Namespace
Add a namespace for loading policies.
$namespace
is a string representing the namespace.
Clear
Clear all namespaces and policies.
Get Namespaces
Get the namespaces.
Has Namespace
Determine if a namespace exists.
$namespace
is a string representing the namespace.
Load
Load a Policy.
$alias
is a string representing the Model alias or class name.
Map
Map an alias to a Policy class name.
$alias
is a string representing the Model alias or class name.$className
is a string representing the Policy class name.
Remove Namespace
Remove a namespace.
$namespace
is a string representing the namespace.
Unload
Unload a policy.
$alias
is a string representing the Model alias or class name.
Use
Load a shared Policy instance.
$alias
is a string representing the Model alias or class name.
Policies
Custom policies can be created by extending the \Fyre\Auth\Policy
class, suffixing the singular alias with "Policy".
Policy rules should be represented as methods on the class, that accept the current user and resolved Entity as arguments.
Get Model
Get the Model.
Resolve Entity
Resolve an Entity from access rule arguments.
$args
is an array containing the access rule arguments.
Authenticators
Custom authenticators can be created by extending the \Fyre\Auth\Authenticator
class, and overwriting the below methods as required.
Authenticate
Authenticate a ServerRequest.
$request
is a ServerRequest.
Before Response
Update the ClientResponse before sending to client.
$response
is a ClientResponse.
Login
Login as a user.
$user
is an Entity representing the user.$rememberMe
is a boolean indicating whether the user should be remembered, and will default to false.
Logout
Logout the current user.
Cookie
The cookie authenticator can be loaded using custom configuration.
$options
is an array containing configuration options.cookieName
is a string representing the cookie name, and will default to "auth".cookieOptions
is an array containing additional options for setting the cookie.expires
is a number representing the cookie lifetime, and will default to null.domain
is a string representing the cookie domain, and will default to "".path
is a string representing the cookie path, and will default to "/".secure
is a boolean indicating whether to set a secure cookie, and will default to false.httpOnly
is a boolean indicating whether to the cookie should be HTTP only, and will default to true.sameSite
is a string representing the cookie same site, and will default to "Lax".
identifierField
is a string representing the identifier field of the user, and will default to "email".passwordfield
is a string representing the password field of the user, and will default to "password".salt
is a string representing the salt to use when generating the token, and will default to null.
This authenticator is only active when the $rememberMe
argument is set to true in the Auth::attempt
and Auth::login
methods.
Session
The session authenticator can be loaded using custom configuration.
$options
is an array containing configuration options.sessionKey
is a string representing the session key, and will default to "auth".sessionField
is a string representing the session field of the user, and will default to "id".
Token
The token authenticator can be loaded using custom configuration.
$options
is an array containing configuration options.tokenHeader
is a string representing the token header name, and will default to "Authorization".tokenHeaderPrefix
is a string representing the token header prefix, and will default to "Bearer".tokenQuery
is a string representing the query parameter, and will default to null.tokenField
is a string representing the token field of the user, and will default to "token".
Middleware
Auth Middleware
This middleware will authenticate using the loaded authenticators, and add any authentication headers to the response.
Process
$request
is a ServerRequest.$handler
is a RequestHandler.
Authenticated Middleware
This middleware will throw an UnauthorizedException if the user is not authenticated.
Process
$request
is a ServerRequest.$handler
is a RequestHandler.
Authorized Middleware
This middleware will throw a ForbiddenException if the user is not authorized.
Process
$request
is a ServerRequest.$handler
is a RequestHandler.
Unauthenticated Middleware
This middleware will return a RedirectResponse if the user is authenticated.
$redirect
is a Uri or string representing the URI to redirect to, and will default to "/".
Process
$request
is a ServerRequest.$handler
is a RequestHandler.
All versions of auth with dependencies
fyre/inflector Version ^2.0
fyre/middleware Version ^2.1
fyre/orm Version ^8.0
fyre/server Version ^3.1
fyre/session Version ^4.0