Skip to content
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

Unclear how to implement 'login_check' route #5

Closed
jasperweyne opened this issue Jun 7, 2021 · 3 comments
Closed

Unclear how to implement 'login_check' route #5

jasperweyne opened this issue Jun 7, 2021 · 3 comments

Comments

@jasperweyne
Copy link

Currently, I'm trying to implement an OIDC client flow using this bundle. After following the steps provided in the readme, I've received an "Unable to generate a URL for the named route "login_check" as such route does not exist." error. After checking out the source code, it has become clear that the login_check route is used to verify the returned authorization code. However, this is step is currently undocumented.

@bobvandevijver
Copy link
Member

/login_check is actually based on the default endpoint from the Symfony framework.

This is the route or path that your login form must submit to. The firewall will intercept any requests (POST requests only, by default) to this URL and process the submitted login credentials.

However, this bundle uses the login_check route name in order to generate the return route for the OIDC response. That's why the route must exists, but it can be any route if you override the default parameter of the OidcClient service (just add $redirectRoute with your route name to the Drenso\OidcBundle\OidcClient service definition).

I usually add something like this in order to be able to generate the route and have a fallback implementation for when the provider can't handle the request.

/**
   * This route handles every login request
   * Only this route is listened to by the security services, so another route is not possible
   *
   * @Route("/login_check", name="login_check")
   * @IsGranted("IS_AUTHENTICATED_ANONYMOUSLY")
   */
  public function checkLogin(): RedirectResponse
  {
    if ($this->isGranted('IS_AUTHENTICATED_FULLY')) {
      return $this->redirect($this->generateUrl('homepage'));
    } else {
      return $this->redirect($this->generateUrl('login'));
    }
  }

I'll see if I can add this to the docs after you've confirmed this works for you 👍🏻

@jasperweyne
Copy link
Author

Thanks for your swift response, this fixes the issue. I'm not explicitely using or providing the login_check parameter in my security config, this is probably related to the fact that I'm using a Guard authenticator instead of a form_login, which is structured not to use it.

@bobvandevijver
Copy link
Member

Nah, that is because its the default value in the OidcClient constructor:

?string $redirectRoute = 'login_check')

Even if you weren't using Guard but the more outdated methods this bundle uses, the route name wouldn't exist by default.

Anyways, somewhere in the (near) future we need to update this bundle to be able to work with Symfony 6 and the new authentication implementation anyways. For now, I will add a link to this issue in the documentation for when anyone else encounters this particular issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants