api/symfony/Bundle/SecurityBundle/DataCollector/SecurityDataCollector.yaml
2024-09-26 02:03:21 -07:00

258 lines
13 KiB
YAML

name: SecurityDataCollector
class_comment: '# * @author Fabien Potencier <fabien@symfony.com>
# *
# * @final'
dependencies:
- name: TraceableFirewallListener
type: class
source: Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener
- name: FirewallMap
type: class
source: Symfony\Bundle\SecurityBundle\Security\FirewallMap
- name: Cookie
type: class
source: Symfony\Component\HttpFoundation\Cookie
- name: Request
type: class
source: Symfony\Component\HttpFoundation\Request
- name: Response
type: class
source: Symfony\Component\HttpFoundation\Response
- name: DataCollector
type: class
source: Symfony\Component\HttpKernel\DataCollector\DataCollector
- name: LateDataCollectorInterface
type: class
source: Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface
- name: TokenStorageInterface
type: class
source: Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
- name: SwitchUserToken
type: class
source: Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken
- name: AccessDecisionManagerInterface
type: class
source: Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
- name: TraceableAccessDecisionManager
type: class
source: Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager
- name: TraceableVoter
type: class
source: Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter
- name: RoleHierarchyInterface
type: class
source: Symfony\Component\Security\Core\Role\RoleHierarchyInterface
- name: SwitchUserListener
type: class
source: Symfony\Component\Security\Http\Firewall\SwitchUserListener
- name: FirewallMapInterface
type: class
source: Symfony\Component\Security\Http\FirewallMapInterface
- name: LogoutUrlGenerator
type: class
source: Symfony\Component\Security\Http\Logout\LogoutUrlGenerator
- name: ClassStub
type: class
source: Symfony\Component\VarDumper\Caster\ClassStub
- name: Data
type: class
source: Symfony\Component\VarDumper\Cloner\Data
properties: []
methods:
- name: isEnabled
visibility: public
parameters: []
comment: "# * @author Fabien Potencier <fabien@symfony.com>\n# *\n# * @final\n#\
\ */\n# class SecurityDataCollector extends DataCollector implements LateDataCollectorInterface\n\
# {\n# private bool $hasVarDumper;\n# \n# public function __construct(\n# private\
\ ?TokenStorageInterface $tokenStorage = null,\n# private ?RoleHierarchyInterface\
\ $roleHierarchy = null,\n# private ?LogoutUrlGenerator $logoutUrlGenerator =\
\ null,\n# private ?AccessDecisionManagerInterface $accessDecisionManager = null,\n\
# private ?FirewallMapInterface $firewallMap = null,\n# private ?TraceableFirewallListener\
\ $firewall = null,\n# ) {\n# $this->hasVarDumper = class_exists(ClassStub::class);\n\
# }\n# \n# public function collect(Request $request, Response $response, ?\\Throwable\
\ $exception = null): void\n# {\n# if (null === $this->tokenStorage) {\n# $this->data\
\ = [\n# 'enabled' => false,\n# 'authenticated' => false,\n# 'impersonated' =>\
\ false,\n# 'impersonator_user' => null,\n# 'impersonation_exit_path' => null,\n\
# 'token' => null,\n# 'token_class' => null,\n# 'logout_url' => null,\n# 'user'\
\ => '',\n# 'roles' => [],\n# 'inherited_roles' => [],\n# 'supports_role_hierarchy'\
\ => null !== $this->roleHierarchy,\n# ];\n# } elseif (null === $token = $this->tokenStorage->getToken())\
\ {\n# $this->data = [\n# 'enabled' => true,\n# 'authenticated' => false,\n# 'impersonated'\
\ => false,\n# 'impersonator_user' => null,\n# 'impersonation_exit_path' => null,\n\
# 'token' => null,\n# 'token_class' => null,\n# 'logout_url' => null,\n# 'user'\
\ => '',\n# 'roles' => [],\n# 'inherited_roles' => [],\n# 'supports_role_hierarchy'\
\ => null !== $this->roleHierarchy,\n# ];\n# } else {\n# $inheritedRoles = [];\n\
# $assignedRoles = $token->getRoleNames();\n# \n# $impersonatorUser = null;\n\
# if ($token instanceof SwitchUserToken) {\n# $originalToken = $token->getOriginalToken();\n\
# $impersonatorUser = $originalToken->getUserIdentifier();\n# }\n# \n# if (null\
\ !== $this->roleHierarchy) {\n# foreach ($this->roleHierarchy->getReachableRoleNames($assignedRoles)\
\ as $role) {\n# if (!\\in_array($role, $assignedRoles, true)) {\n# $inheritedRoles[]\
\ = $role;\n# }\n# }\n# }\n# \n# $logoutUrl = null;\n# try {\n# $logoutUrl = $this->logoutUrlGenerator?->getLogoutPath();\n\
# } catch (\\Exception) {\n# // fail silently when the logout URL cannot be generated\n\
# }\n# \n# $this->data = [\n# 'enabled' => true,\n# 'authenticated' => (bool)\
\ $token->getUser(),\n# 'impersonated' => null !== $impersonatorUser,\n# 'impersonator_user'\
\ => $impersonatorUser,\n# 'impersonation_exit_path' => null,\n# 'token' => $token,\n\
# 'token_class' => $this->hasVarDumper ? new ClassStub($token::class) : $token::class,\n\
# 'logout_url' => $logoutUrl,\n# 'user' => $token->getUserIdentifier(),\n# 'roles'\
\ => $assignedRoles,\n# 'inherited_roles' => array_unique($inheritedRoles),\n\
# 'supports_role_hierarchy' => null !== $this->roleHierarchy,\n# ];\n# }\n# \n\
# // collect voters and access decision manager information\n# if ($this->accessDecisionManager\
\ instanceof TraceableAccessDecisionManager) {\n# $this->data['voter_strategy']\
\ = $this->accessDecisionManager->getStrategy();\n# $this->data['voters'] = [];\n\
# \n# foreach ($this->accessDecisionManager->getVoters() as $voter) {\n# if ($voter\
\ instanceof TraceableVoter) {\n# $voter = $voter->getDecoratedVoter();\n# }\n\
# \n# $this->data['voters'][] = $this->hasVarDumper ? new ClassStub($voter::class)\
\ : $voter::class;\n# }\n# \n# // collect voter details\n# $decisionLog = $this->accessDecisionManager->getDecisionLog();\n\
# foreach ($decisionLog as $key => $log) {\n# $decisionLog[$key]['voter_details']\
\ = [];\n# foreach ($log['voterDetails'] as $voterDetail) {\n# $voterClass = $voterDetail['voter']::class;\n\
# $classData = $this->hasVarDumper ? new ClassStub($voterClass) : $voterClass;\n\
# $decisionLog[$key]['voter_details'][] = [\n# 'class' => $classData,\n# 'attributes'\
\ => $voterDetail['attributes'], // Only displayed for unanimous strategy\n# 'vote'\
\ => $voterDetail['vote'],\n# ];\n# }\n# unset($decisionLog[$key]['voterDetails']);\n\
# }\n# \n# $this->data['access_decision_log'] = $decisionLog;\n# } else {\n# $this->data['access_decision_log']\
\ = [];\n# $this->data['voter_strategy'] = 'unknown';\n# $this->data['voters']\
\ = [];\n# }\n# \n# // collect firewall context information\n# $this->data['firewall']\
\ = null;\n# if ($this->firewallMap instanceof FirewallMap) {\n# $firewallConfig\
\ = $this->firewallMap->getFirewallConfig($request);\n# if (null !== $firewallConfig)\
\ {\n# $this->data['firewall'] = [\n# 'name' => $firewallConfig->getName(),\n\
# 'request_matcher' => $firewallConfig->getRequestMatcher(),\n# 'security_enabled'\
\ => $firewallConfig->isSecurityEnabled(),\n# 'stateless' => $firewallConfig->isStateless(),\n\
# 'provider' => $firewallConfig->getProvider(),\n# 'context' => $firewallConfig->getContext(),\n\
# 'entry_point' => $firewallConfig->getEntryPoint(),\n# 'access_denied_handler'\
\ => $firewallConfig->getAccessDeniedHandler(),\n# 'access_denied_url' => $firewallConfig->getAccessDeniedUrl(),\n\
# 'user_checker' => $firewallConfig->getUserChecker(),\n# 'authenticators' =>\
\ $firewallConfig->getAuthenticators(),\n# ];\n# \n# // generate exit impersonation\
\ path from current request\n# if ($this->data['impersonated'] && null !== $switchUserConfig\
\ = $firewallConfig->getSwitchUser()) {\n# $exitPath = $request->getRequestUri();\n\
# $exitPath .= null === $request->getQueryString() ? '?' : '&';\n# $exitPath .=\
\ \\sprintf('%s=%s', urlencode($switchUserConfig['parameter']), SwitchUserListener::EXIT_VALUE);\n\
# \n# $this->data['impersonation_exit_path'] = $exitPath;\n# }\n# }\n# }\n# \n\
# // collect firewall listeners information\n# $this->data['listeners'] = [];\n\
# if ($this->firewall) {\n# $this->data['listeners'] = $this->firewall->getWrappedListeners();\n\
# }\n# \n# $this->data['authenticators'] = $this->firewall ? $this->firewall->getAuthenticatorsInfo()\
\ : [];\n# \n# if ($this->data['listeners'] && !($this->data['firewall']['stateless']\
\ ?? true)) {\n# $authCookieName = \"{$this->data['firewall']['name']}_auth_profile_token\"\
;\n# $deauthCookieName = \"{$this->data['firewall']['name']}_deauth_profile_token\"\
;\n# $profileToken = $response->headers->get('X-Debug-Token');\n# \n# $this->data['auth_profile_token']\
\ = $request->cookies->get($authCookieName);\n# $this->data['deauth_profile_token']\
\ = $request->cookies->get($deauthCookieName);\n# \n# if ($this->data['authenticated']\
\ && !$this->data['auth_profile_token']) {\n# $response->headers->setCookie(new\
\ Cookie($authCookieName, $profileToken));\n# \n# $this->data['deauth_profile_token']\
\ = null;\n# $response->headers->clearCookie($deauthCookieName);\n# } elseif (!$this->data['authenticated']\
\ && !$this->data['deauth_profile_token']) {\n# $response->headers->setCookie(new\
\ Cookie($deauthCookieName, $profileToken));\n# \n# $this->data['auth_profile_token']\
\ = null;\n# $response->headers->clearCookie($authCookieName);\n# }\n# }\n# }\n\
# \n# public function reset(): void\n# {\n# $this->data = [];\n# }\n# \n# public\
\ function lateCollect(): void\n# {\n# $this->data = $this->cloneVar($this->data);\n\
# }\n# \n# /**\n# * Checks if security is enabled."
- name: getUser
visibility: public
parameters: []
comment: '# * Gets the user.'
- name: getRoles
visibility: public
parameters: []
comment: '# * Gets the roles of the user.'
- name: getInheritedRoles
visibility: public
parameters: []
comment: '# * Gets the inherited roles of the user.'
- name: supportsRoleHierarchy
visibility: public
parameters: []
comment: '# * Checks if the data contains information about inherited roles. Still
the inherited
# * roles can be an empty array.'
- name: isAuthenticated
visibility: public
parameters: []
comment: '# * Checks if the user is authenticated or not.'
- name: isImpersonated
visibility: public
parameters: []
comment: null
- name: getImpersonatorUser
visibility: public
parameters: []
comment: null
- name: getImpersonationExitPath
visibility: public
parameters: []
comment: null
- name: getTokenClass
visibility: public
parameters: []
comment: '# * Get the class name of the security token.'
- name: getToken
visibility: public
parameters: []
comment: '# * Get the full security token class as Data object.'
- name: getLogoutUrl
visibility: public
parameters: []
comment: '# * Get the logout URL.'
- name: getVoters
visibility: public
parameters: []
comment: '# * Returns the FQCN of the security voters enabled in the application.
# *
# * @return string[]|Data'
- name: getVoterStrategy
visibility: public
parameters: []
comment: '# * Returns the strategy configured for the security voters.'
- name: getAccessDecisionLog
visibility: public
parameters: []
comment: '# * Returns the log of the security decisions made by the access decision
manager.'
- name: getFirewall
visibility: public
parameters: []
comment: '# * Returns the configuration of the current firewall context.'
- name: getListeners
visibility: public
parameters: []
comment: null
- name: getAuthenticators
visibility: public
parameters: []
comment: null
- name: getAuthProfileToken
visibility: public
parameters: []
comment: null
- name: getDeauthProfileToken
visibility: public
parameters: []
comment: null
- name: getName
visibility: public
parameters: []
comment: null
traits:
- Symfony\Bundle\SecurityBundle\Debug\TraceableFirewallListener
- Symfony\Bundle\SecurityBundle\Security\FirewallMap
- Symfony\Component\HttpFoundation\Cookie
- Symfony\Component\HttpFoundation\Request
- Symfony\Component\HttpFoundation\Response
- Symfony\Component\HttpKernel\DataCollector\DataCollector
- Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface
- Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
- Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken
- Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
- Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager
- Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter
- Symfony\Component\Security\Core\Role\RoleHierarchyInterface
- Symfony\Component\Security\Http\Firewall\SwitchUserListener
- Symfony\Component\Security\Http\FirewallMapInterface
- Symfony\Component\Security\Http\Logout\LogoutUrlGenerator
- Symfony\Component\VarDumper\Caster\ClassStub
- Symfony\Component\VarDumper\Cloner\Data
interfaces:
- LateDataCollectorInterface