AuthManager

Back-end authentication manager.

 class Backend\Classes\AuthManager
extends Winter\Storm\Auth\Manager
implements 
    Illuminate\Contracts\Auth\StatefulGuard

Extends

Class Description
Manager

Authentication manager

Traits

Trait Description
Singleton

Singleton trait.

Properties

protected $aliases : array

List of owner aliases. ['Aliased.Owner' => 'Real.Owner']

protected $callbacks : array

Cache of registration callbacks.

protected $groupModel : mixed

protected static $instance : mixed

protected $permissionCache : array

Cache of registered permissions.

protected static $permissionDefaults : mixed

protected $permissionRoles : array

List of registered permission roles.

protected $permissions : array

List of registered permissions.

protected $requireActivation : mixed

protected $sessionKey : mixed

protected $throttleModel : mixed

protected $userModel : mixed

inherited public $ipAddress : string

Inherited from Manager

The IP address of this request

inherited protected $impersonator : Models\User | null

Inherited from Manager

The user that is impersonating the currently logged in user when applicable

inherited protected $sessionManager : Illuminate\Session\SessionManager

Inherited from Manager

Session manager instance.

inherited protected $throttle : array

Inherited from Manager

In memory throttle cache [md5($userId.$ipAddress) => $this->throttleModel]

inherited protected $useSession : bool

Inherited from Manager

Internal flag to toggle using the session for the current authentication request

inherited protected $useThrottle : bool

Inherited from Manager

Flag to enable login throttling

inherited protected $user : Models\User | null

Inherited from Manager

The currently logged in user

inherited protected $viaRemember : bool

Inherited from Manager

Indicates if the user was authenticated via a recaller cookie.

Methods

public hasPermissionsForRole ($role)

Parameters
Property Description
$role
mixed
Returns
mixed

public listPermissions () : array

Returns a list of the registered permissions items.

Returns
array

public listPermissionsForRole (string $role, boolean $includeOrphans = true) : array

Returns an array of registered permissions belonging to a given role code

Parameters
Property Description
$role
string
$includeOrphans
boolean

Include any permissons that do not have a default role specified

Returns
array

public listTabbedPermissions () : array

Returns an array of registered permissions, grouped by tabs.

Returns
array

public registerCallback (callable $callback)

Registers a callback function that defines authentication permissions.

The callback function should register permissions by calling the manager's registerPermissions() function. The manager instance is passed to the callback function as an argument. Usage:

BackendAuth::registerCallback(function ($manager) {
    $manager->registerPermissions([...]);
});
Parameters
Property Description
$callback
callable

A callable function.

Returns
mixed

public registerPermissionOwnerAlias (string $owner, string $alias) : void

Register a permission owner alias

Parameters
Property Description
$owner
string

The owner to register an alias for. Example: Real.Owner

$alias
string

The alias to register. Example: Aliased.Owner

Returns
void

public registerPermissions (string $owner, array $definitions)

Registers the back-end permission items.

The argument is an array of the permissions. The array keys represent the permission codes, specific for the plugin/module. Each element in the array should be an associative array with the following keys:

  • label - specifies the menu label localization string key, required.
  • order - a position of the item in the menu, optional.
  • comment - a brief comment that describes the permission, optional.
  • tab - assign this permission to a tabbed group, optional.
Parameters
Property Description
$owner
string

Specifies the permissions' owner plugin or module in the format Author.Plugin

$definitions
array

An array of the menu item definitions.

Returns
mixed

public removePermission (string $owner, string $code) : void

Removes a single back-end permission

Parameters
Property Description
$owner
string

Specifies the permissions' owner plugin or module in the format Author.Plugin

$code
string

The code of the permission to remove

Returns
void

protected createUserModelQuery ()

{@inheritdoc}

Returns
mixed

protected init ()

Returns
mixed

protected validateUserModel ($user)

{@inheritdoc}

Parameters
Property Description
$user
mixed
Returns
mixed

inherited public __clone ()

Inherited from Singleton
Returns
mixed

inherited public __wakeup ()

Inherited from Singleton
Returns
mixed

inherited public attempt (array $credentials = [], boolean $remember = false) : bool

Inherited from Manager

Attempt to authenticate a user using the given credentials.

Parameters
Property Description
$credentials
array

The user login details

$remember
boolean

Store a non-expire cookie for the user

Returns
bool

If authentication was successful

inherited public authenticate (array $credentials, boolean $remember = true)

Inherited from Manager

Attempts to authenticate the given user according to the passed credentials.

Parameters
Property Description
$credentials
array

The user login details

$remember
boolean

Store a non-expire cookie for the user

Returns
mixed

inherited public check () : bool

Inherited from Manager

Check to see if the user is logged in and activated, and hasn't been banned or suspended.

Returns
bool

inherited public createThrottleModel () : Models\Throttle

Inherited from Manager

Creates an instance of the throttle model

Returns
Models\Throttle

inherited public createUserModel () : Models\User

Inherited from Manager

Creates a new instance of the user model

Returns
Models\User

inherited public extendUserQuery (Winter\Storm\Database\Builder $query) : void

Inherited from Manager

Extend the query used for finding the user.

Parameters
Returns
void

inherited public findThrottleByLogin (string $loginName, string $ipAddress) : Models\Throttle

Inherited from Manager

Find a throttle record by login and ip address

Parameters
Property Description
$loginName
string
$ipAddress
string
Returns
Models\Throttle

inherited public findThrottleByUserId (int $userId, string $ipAddress = null) : Models\Throttle

Inherited from Manager

Find a throttle record by user id and ip address

Parameters
Property Description
$userId
int
$ipAddress
string
Returns
Models\Throttle

inherited public findUserByCredentials (array $credentials) : Models\User

Inherited from Manager

Finds a user by the given credentials.

Parameters
Property Description
$credentials
array

The credentials to find a user by

Returns
Models\User

The requested user

inherited public findUserById (string $id) : mixed

Inherited from Manager

Finds a user by the login value.

Parameters
Property Description
$id
string
Returns
mixed

(Models\User || null)

inherited public findUserByLogin (string $login) : mixed

Inherited from Manager

Finds a user by the login value.

Parameters
Property Description
$login
string
Returns
mixed

(Models\User || null)

inherited public static final forgetInstance ($container = null) : void

Inherited from Singleton

Forget this singleton's instance if it exists

Parameters
Property Description
$container
mixed
Returns
void

inherited public getImpersonator () : Models\User | false

Inherited from Manager

Get the original user doing the impersonation

Returns
Models\User | false

Returns the User model for the impersonator if able, false if not

inherited public getRealUser () : mixed

Inherited from Manager

Gets the user for the request, taking into account impersonation

Returns
mixed

(Models\User || null)

inherited public getUser () : mixed

Inherited from Manager

Returns the current user, if any.

Returns
mixed

(Models\User || null)

inherited public guest () : bool

Inherited from Manager

Determine if the current user is a guest.

Returns
bool

inherited public hasUser () : bool

Inherited from Manager

Determine if the guard has a user instance.

Returns
bool

inherited public id () : int | null

Inherited from Manager

Get the ID for the currently authenticated user.

Returns
int | null

inherited public impersonate (Models\User $impersonatee) : void

Inherited from Manager

Impersonates the given user and sets properties in the session but not the cookie.

Parameters
Property Description
$impersonatee
Models\User
Returns
void

inherited public static final instance ($container = null) : static

Inherited from Singleton

Create a new instance of this singleton.

Parameters
Property Description
$container
mixed
Returns
static

inherited public isImpersonator () : bool

Inherited from Manager

Check to see if the current session is being impersonated

Returns
bool

inherited public login (Illuminate\Contracts\Auth\Authenticatable $user, boolean $remember = true)

Inherited from Manager

Logs in the given user and sets properties in the session.

Parameters
Property Description
$user
Illuminate\Contracts\Auth\Authenticatable
$remember
boolean
Returns
mixed

inherited public loginUsingId (mixed $id, boolean $remember = false) : Illuminate\Contracts\Auth\Authenticatable | false

Inherited from Manager

Log the given user ID into the application.

Parameters
Property Description
$id
mixed
$remember
boolean
Returns
Illuminate\Contracts\Auth\Authenticatable | false

inherited public logout ()

Inherited from Manager

Logs the current user out.

Returns
mixed

inherited public once (array $credentials = []) : bool

Inherited from Manager

Log a user into the application without sessions or cookies.

Parameters
Property Description
$credentials
array
Returns
bool

inherited public onceUsingId (mixed $id) : Illuminate\Contracts\Auth\Authenticatable | false

Inherited from Manager

Log the given user ID into the application without sessions or cookies.

Parameters
Property Description
$id
mixed
Returns
Illuminate\Contracts\Auth\Authenticatable | false

inherited public register (array $credentials, boolean $activate = false, boolean $autoLogin = true) : Models\User

Inherited from Manager

Registers a user with the provided credentials with optional flags for activating the newly created user and automatically logging them in

Parameters
Property Description
$credentials
array
$activate
boolean
$autoLogin
boolean
Returns
Models\User

inherited public setUser (Illuminate\Contracts\Auth\Authenticatable $user)

Inherited from Manager

Sets the user

Parameters
Property Description
$user
Illuminate\Contracts\Auth\Authenticatable
Returns
mixed

inherited public stopImpersonate ()

Inherited from Manager

Stop the current session being impersonated and authenticate as the impersonator again

Returns
mixed

inherited public user () : Illuminate\Contracts\Auth\Authenticatable | null

Inherited from Manager

Get the currently authenticated user.

Returns
Illuminate\Contracts\Auth\Authenticatable | null

inherited public validate (array $credentials = []) : bool

Inherited from Manager

Validate a user's credentials.

Parameters
Property Description
$credentials
array
Returns
bool

inherited public viaRemember () : bool

Inherited from Manager

Determine if the user was authenticated via "remember me" cookie.

Returns
bool

inherited protected final __construct ()

Inherited from Singleton

Constructor.

Returns
mixed

inherited protected getPersistCodeFromSession (boolean $logRemember = false) : array | null

Inherited from Manager

Returns the user ID and peristence code from the session or remember cookie

Parameters
Property Description
$logRemember
boolean

Flag to set $this->viaRemember if the persist code was pulled from the cookie

Returns
array | null

[user_id, persist_code]

inherited protected setPersistCodeInSession (Models\User $user, boolean $remember = true) : void

Inherited from Manager

Stores the user persistence information in the session (and cookie when $remember = true)

Parameters
Property Description
$user
Models\User
$remember
boolean
Returns
void

inherited protected validateInternal (array $credentials = []) : Models\User | null

Inherited from Manager

Validate a user's credentials, method used internally.

Parameters
Property Description
$credentials
array
Returns
Models\User | null
Copyright © 2024 Winter CMS