Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
123 } | 123 } |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 /** | 127 /** |
128 * Detect disallowed authentication methods on access denied exceptions. | |
129 * | |
130 * @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event | |
131 */ | |
132 public function _onExceptionAccessDenied(GetResponseForExceptionEvent $event) { | |
133 if (isset($this->filter) && $event->isMasterRequest()) { | |
134 $request = $event->getRequest(); | |
135 $exception = $event->getException(); | |
136 if ($exception instanceof AccessDeniedHttpException && $this->authenticationProvider->applies($request) && !$this->filter->appliesToRoutedRequest($request, TRUE)) { | |
137 $event->setException(new AccessDeniedHttpException('The used authentication method is not allowed on this route.', $exception)); | |
138 } | |
139 } | |
140 } | |
141 | |
142 /** | |
128 * {@inheritdoc} | 143 * {@inheritdoc} |
129 */ | 144 */ |
130 public static function getSubscribedEvents() { | 145 public static function getSubscribedEvents() { |
131 // The priority for authentication must be higher than the highest event | 146 // The priority for authentication must be higher than the highest event |
132 // subscriber accessing the current user. Especially it must be higher than | 147 // subscriber accessing the current user. Especially it must be higher than |
135 $events[KernelEvents::REQUEST][] = ['onKernelRequestAuthenticate', 300]; | 150 $events[KernelEvents::REQUEST][] = ['onKernelRequestAuthenticate', 300]; |
136 | 151 |
137 // Access check must be performed after routing. | 152 // Access check must be performed after routing. |
138 $events[KernelEvents::REQUEST][] = ['onKernelRequestFilterProvider', 31]; | 153 $events[KernelEvents::REQUEST][] = ['onKernelRequestFilterProvider', 31]; |
139 $events[KernelEvents::EXCEPTION][] = ['onExceptionSendChallenge', 75]; | 154 $events[KernelEvents::EXCEPTION][] = ['onExceptionSendChallenge', 75]; |
155 $events[KernelEvents::EXCEPTION][] = ['_onExceptionAccessDenied', 80]; | |
140 return $events; | 156 return $events; |
141 } | 157 } |
142 | 158 |
143 } | 159 } |