PHP Class EasyCorp\Bundle\EasySecurityBundle\Security\Security

ファイルを表示 Open project: easycorp/easy-security-bundle

Public Methods

Method Description
__construct ( Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokenStorage, Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $authorizationChecker, Symfony\Component\Security\Core\Encoder\UserPasswordEncoder $passwordEncoder, Symfony\Component\Security\Http\Authentication\AuthenticationUtils $authenticationUtils, Symfony\Component\HttpFoundation\Session\Session $session, Symfony\Component\Security\Core\Role\RoleHierarchy $roleHierarchy )
encodePassword ( string $plainPassword, null $user = null ) : string Returns the given plain password encoded/hashed using the encoder of the current application user or the optionally given user.
getImpersonatingUser ( ) : mixed When impersonating a user, it returns the original user who started the impersonation.
getLoginError ( ) : Symfony\Component\Security\Core\Exception\AuthenticationException | null Returns the error of the last failed login attempt, if any.
getLoginUsername ( ) : string | null Returns the username of the last failed login attempt, if any.
getUser ( ) : mixed Returns the current application user.
hasRole ( $role, null $user = null ) : boolean Returns true if the current application user (or the optionally given user) has the given role. It takes into account the full role hierarchy.
isAnonymous ( null $user = null ) : boolean Returns true if the current application user (or the optionally given user) is anonymous. This behaves differently than Symfony built-in methods and it returns true only when the user is really anonymous.
isAuthenticated ( null $user = null ) : boolean Returns true if the current application user (or the optionally given user) is authenticated in any way (because they have introduced their credentials (username and password) or they have been remembered).
isFullyAuthenticated ( null $user = null ) : boolean Returns true if the current application user (or the optionally given user) is authenticated because they have introduced their credentials (username and password).
isGranted ( mixed $attributes, mixed $object = null ) : boolean Checks if the attributes (usually security roles) are granted for the current application user and the optional given object.
isPasswordValid ( string $plainPassword, null $user = null ) : boolean Returns true if the given plain password is valid for the current application user or the optionally given user.
isRemembered ( null $user = null ) : boolean Returns true if the current application user (or the optionally given user) is remembered. This behaves differently than Symfony built-in methods and it returns true only when the user is really remembered and they haven't introduced their credentials (username and password).
login ( Symfony\Component\Security\Core\User\UserInterface $user, string $firewallName = 'main' ) : Symfony\Component\Security\Core\User\UserInterface It logs in the given user in the 'main' application firewall (or the optionally given firewall name).

Private Methods

Method Description
getUserRolesAsObjects ( Symfony\Component\Security\Core\User\UserInterface $user ) : Symfony\Component\Security\Core\Role\RoleInterface[] Returns an array with the roles of the given user turned into Role objects, which are needed by methods such as getReachableRoles().

Method Details

__construct() public method

public __construct ( Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokenStorage, Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $authorizationChecker, Symfony\Component\Security\Core\Encoder\UserPasswordEncoder $passwordEncoder, Symfony\Component\Security\Http\Authentication\AuthenticationUtils $authenticationUtils, Symfony\Component\HttpFoundation\Session\Session $session, Symfony\Component\Security\Core\Role\RoleHierarchy $roleHierarchy )
$tokenStorage Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
$authorizationChecker Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface
$passwordEncoder Symfony\Component\Security\Core\Encoder\UserPasswordEncoder
$authenticationUtils Symfony\Component\Security\Http\Authentication\AuthenticationUtils
$session Symfony\Component\HttpFoundation\Session\Session
$roleHierarchy Symfony\Component\Security\Core\Role\RoleHierarchy

encodePassword() public method

Returns the given plain password encoded/hashed using the encoder of the current application user or the optionally given user.
public encodePassword ( string $plainPassword, null $user = null ) : string
$plainPassword string
$user null
return string

getImpersonatingUser() public method

When impersonating a user, it returns the original user who started the impersonation.
public getImpersonatingUser ( ) : mixed
return mixed

getLoginError() public method

Returns the error of the last failed login attempt, if any.
public getLoginError ( ) : Symfony\Component\Security\Core\Exception\AuthenticationException | null
return Symfony\Component\Security\Core\Exception\AuthenticationException | null

getLoginUsername() public method

Returns the username of the last failed login attempt, if any.
public getLoginUsername ( ) : string | null
return string | null

getUser() public method

Returns the current application user.
public getUser ( ) : mixed
return mixed

hasRole() public method

Returns true if the current application user (or the optionally given user) has the given role. It takes into account the full role hierarchy.
public hasRole ( $role, null $user = null ) : boolean
$role
$user null
return boolean

isAnonymous() public method

Returns true if the current application user (or the optionally given user) is anonymous. This behaves differently than Symfony built-in methods and it returns true only when the user is really anonymous.
public isAnonymous ( null $user = null ) : boolean
$user null
return boolean

isAuthenticated() public method

Returns true if the current application user (or the optionally given user) is authenticated in any way (because they have introduced their credentials (username and password) or they have been remembered).
public isAuthenticated ( null $user = null ) : boolean
$user null
return boolean

isFullyAuthenticated() public method

Returns true if the current application user (or the optionally given user) is authenticated because they have introduced their credentials (username and password).
public isFullyAuthenticated ( null $user = null ) : boolean
$user null
return boolean

isGranted() public method

Checks if the attributes (usually security roles) are granted for the current application user and the optional given object.
public isGranted ( mixed $attributes, mixed $object = null ) : boolean
$attributes mixed
$object mixed
return boolean

isPasswordValid() public method

Returns true if the given plain password is valid for the current application user or the optionally given user.
public isPasswordValid ( string $plainPassword, null $user = null ) : boolean
$plainPassword string
$user null
return boolean

isRemembered() public method

Returns true if the current application user (or the optionally given user) is remembered. This behaves differently than Symfony built-in methods and it returns true only when the user is really remembered and they haven't introduced their credentials (username and password).
public isRemembered ( null $user = null ) : boolean
$user null
return boolean

login() public method

It logs in the given user in the 'main' application firewall (or the optionally given firewall name).
public login ( Symfony\Component\Security\Core\User\UserInterface $user, string $firewallName = 'main' ) : Symfony\Component\Security\Core\User\UserInterface
$user Symfony\Component\Security\Core\User\UserInterface
$firewallName string
return Symfony\Component\Security\Core\User\UserInterface