Created
February 22, 2019 09:15
-
-
Save ant5/e81f94cea7404ca8e520d0367ef27427 to your computer and use it in GitHub Desktop.
Symfony allow do not autostart session before authentication (implementation of earlySession())
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- security-guard/AbstractGuardAuthenticator.php.old 2019-02-21 00:26:03.833716000 +0300 | |
+++ security-guard/AbstractGuardAuthenticator.php 2019-02-21 00:26:35.599839000 +0300 | |
@@ -38,4 +38,12 @@ | |
$user->getRoles() | |
); | |
} | |
+ | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ public function earlySession() | |
+ { | |
+ return true; | |
+ } | |
} | |
--- security-http/EntryPoint/AuthenticationEntryPointInterface.php.old 2019-02-20 23:34:23.102549000 +0300 | |
+++ security-http/EntryPoint/AuthenticationEntryPointInterface.php 2019-02-20 23:54:02.778390000 +0300 | |
@@ -46,4 +46,18 @@ | |
* @return Response | |
*/ | |
public function start(Request $request, AuthenticationException $authException = null); | |
+ | |
+ /** | |
+ * Returns whether to start session before authentication. | |
+ * | |
+ * The true value means to start session and enable PathTrait feature (ability to | |
+ * redirect/forward user to initially hitted page after authentication). | |
+ * | |
+ * The false value mean no session start (disabling PathTrait feature) | |
+ * before authentication avoiding generating and storing session for anonymous | |
+ * page hit. | |
+ * | |
+ * @return bool | |
+ */ | |
+ public function earlySession(); | |
} | |
--- security-http/EntryPoint/BasicAuthenticationEntryPoint.php.old 2019-02-21 00:01:19.143114000 +0300 | |
+++ security-http/EntryPoint/BasicAuthenticationEntryPoint.php 2019-02-21 00:01:25.764162000 +0300 | |
@@ -40,4 +40,12 @@ | |
return $response; | |
} | |
+ | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ public function earlySession() | |
+ { | |
+ return true; | |
+ } | |
} | |
--- security-http/Firewall/ExceptionListener.php.old 2019-02-21 08:41:43.811223000 +0300 | |
+++ security-http/Firewall/ExceptionListener.php 2019-02-21 08:38:30.617402000 +0300 | |
@@ -179,7 +180,7 @@ | |
$this->logger->debug('Calling Authentication entry point.'); | |
} | |
- if (!$this->stateless) { | |
+ if (!$this->stateless && $this->authenticationEntryPoint->earlySession()) { | |
$this->setTargetPath($request); | |
} | |
--- security-http/EntryPoint/FormAuthenticationEntryPoint.php.old 2019-02-21 00:02:30.708653000 +0300 | |
+++ security-http/EntryPoint/FormAuthenticationEntryPoint.php 2019-02-21 00:17:54.238627000 +0300 | |
@@ -60,4 +60,12 @@ | |
return $this->httpUtils->createRedirectResponse($request, $this->loginPath); | |
} | |
+ | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ public function earlySession() | |
+ { | |
+ return true; | |
+ } | |
} | |
--- security-http/EntryPoint/RetryAuthenticationEntryPoint.php.old 2019-02-21 00:18:48.238740000 +0300 | |
+++ security-http/EntryPoint/RetryAuthenticationEntryPoint.php 2019-02-21 00:18:53.950094000 +0300 | |
@@ -56,4 +56,12 @@ | |
return new RedirectResponse($url, 301); | |
} | |
+ | |
+ /** | |
+ * {@inheritdoc} | |
+ */ | |
+ public function earlySession() | |
+ { | |
+ return true; | |
+ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment