-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] getDefaultSuccessRedirectUrl should have access to the token #18027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@billsworld Hmm, yes I see! The whole point of implementing public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)
{
$targetPath = $this->getTargetPath($request->getSession(), $providerKey);
if (!$targetPath) {
$targetPath = $this->container->get('router')
->generate('app_user_index', ['username' => $token->getUsername()]);
}
return new RedirectResponse($targetPath);
} |
@weaverryan I actually implemented onAuthenticationSuccess more to have access to the TokenInterface. I agree onAuthenticationSuccess could be deprecated but it definitely should not be required by making it abstract in the base class |
I opened a PR to deprecate the function (would also makes the |
Using the new Guard component I am redirecting the user to a page like /user/{username}. The problem is I cannot access the user token in
getDefaultSuccessRedirectUrl
. I am proposing that the$request
and$token
get passed togetDefaultSuccessRedirectUrl
Without the token I have to adjust my authenticator like this
This is not so good b/c I have to define getDefaultSuccessRedirectUrl which will never be used. Perhaps it would be better if the definition was more like this
protected function getDefaultSuccessRedirectUrl(Request $request, TokenInterface $token)
Or maybegetDefaultSuccessRedirectUrl
should not be defined as an abstract method.The text was updated successfully, but these errors were encountered: