lightSAML / SpBundle

SAML2 SP Symfony Bundle based on LightSAML
https://www.lightsaml.com/SP-Bundle/
MIT License
66 stars 70 forks source link

URL for the named route "lightsaml.login_check" #56

Closed guiyomh closed 6 years ago

guiyomh commented 6 years ago

hi all,

i go to /saml/login i'm redirect to /saml/discovery, i choose my IDP i'm redirect to /saml/login?idp= and i show

Unable to generate a URL for the named route "lightsaml.login_check" 

please, help me ?

tmilos commented 6 years ago

Have imported routing settings as described in step 3 of getting started with lightsaml guide https://www.lightsaml.com/SP-Bundle/Getting-started/ ?

guiyomh commented 6 years ago

i have following the Getting Started Here my routing.yml:

api:
    resource: '.'
    type:     'api_platform'

lightsaml_sp:
    resource: "@LightSamlSpBundle/Resources/config/routing.yml"
    prefix: saml

logout:
    path: /logout

app:
    resource: '@AppBundle/Action/'
    type:     'annotation'

But i have an exception

Unable to generate a URL for the named route "lightsaml.login_check" as such route does not exist.
500 Internal Server Error - RouteNotFoundException
Stack Trace
in var/cache/dev/appDevDebugProjectContainerUrlGenerator.php at line 54   + 
at appDevDebugProjectContainerUrlGenerator ->generate ('lightsaml.login_check', array(), 0) 
in var/cache/dev/classes.php at line 1906   + 
at Router ->generate ('lightsaml.login_check', array(), 0) 
in vendor/lightsaml/symfony-bridge/src/LightSaml/SymfonyBridgeBundle/Factory/OwnEntityDescriptorProviderFactory.php at line 41   +
at OwnEntityDescriptorProviderFactory ::build ('9d3e17e7-6d53-4929-8304-5d6928ff5f8d', object(Router), 'lightsaml.login_check', null, object(CompositeCredentialStore)) 
in var/cache/dev/appDevDebugProjectContainer.php at line 2313   + 
at appDevDebugProjectContainer ->getLightsaml_Own_EntityDescriptorProviderService () 
in var/cache/dev/classes.php at line 3107   + 
at Container ->get ('lightsaml.own.entity_descriptor_provider') 
in vendor/lightsaml/symfony-bridge/src/LightSaml/SymfonyBridgeBundle/Bridge/Container/OwnContainer.php at line 25   + 
at OwnContainer ->getOwnEntityDescriptorProvider () 
in vendor/lightsaml/lightsaml/src/LightSaml/Builder/Profile/AbstractProfileBuilder.php at line 48   + 
at AbstractProfileBuilder ->buildContext () 
in vendor/lightsaml/lightsaml/src/LightSaml/Builder/Profile/WebBrowserSso/Sp/SsoSpSendAuthnRequestProfileBuilder.php at line 39   +
at SsoSpSendAuthnRequestProfileBuilder ->buildContext () 
in vendor/lightsaml/sp-bundle/src/LightSaml/SpBundle/Controller/DefaultController.php at line 51   + 
at DefaultController ->loginAction (object(Request)) 
at call_user_func_array (array(object(DefaultController), 'loginAction'), array(object(Request))) 
in var/cache/dev/classes.php at line 4245   + 
at HttpKernel ->handleRaw (object(Request), 1) 
in var/cache/dev/classes.php at line 4200   + 
at HttpKernel ->handle (object(Request), 1, true) 
in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php at line 168   + 
at Kernel ->handle (object(Request)) 
in web/app_dev.php at line 33   + 
guiyomh commented 6 years ago

here my route :

php bin/console debug:router
 -------------------------- -------- -------- ------ -----------------------------------
  Name                       Method   Scheme   Host   Path
 -------------------------- -------- -------- ------ -----------------------------------
  _wdt                       ANY      ANY      ANY    /_wdt/{token}
  _profiler_home             ANY      ANY      ANY    /_profiler/
  _profiler_search           ANY      ANY      ANY    /_profiler/search
  _profiler_search_bar       ANY      ANY      ANY    /_profiler/search_bar
  _profiler_phpinfo          ANY      ANY      ANY    /_profiler/phpinfo
  _profiler_search_results   ANY      ANY      ANY    /_profiler/{token}/search/results
  _profiler_open_file        ANY      ANY      ANY    /_profiler/open
  _profiler                  ANY      ANY      ANY    /_profiler/{token}
  _profiler_router           ANY      ANY      ANY    /_profiler/{token}/router
  _profiler_exception        ANY      ANY      ANY    /_profiler/{token}/exception
  _profiler_exception_css    ANY      ANY      ANY    /_profiler/{token}/exception.css
  _twig_error_test           ANY      ANY      ANY    /_error/{code}.{_format}
  api_entrypoint             ANY      ANY      ANY    /{index}.{_format}
  api_doc                    ANY      ANY      ANY    /docs.{_format}
  api_jsonld_context         ANY      ANY      ANY    /contexts/{shortName}.{_format}
  lightsaml_sp.metadata      ANY      ANY      ANY    /saml/metadata.xml
  lightsaml_sp.discovery     ANY      ANY      ANY    /saml/discovery
  lightsaml_sp.login         ANY      ANY      ANY    /saml/login
  lightsaml_sp.login_check   ANY      ANY      ANY    /saml/login_check
  lightsaml_sp.sessions      ANY      ANY      ANY    /saml/sessions
  logout                     ANY      ANY      ANY    /logout
 -------------------------- -------- -------- ------ -----------------------------------
guiyomh commented 6 years ago

I have found a diff between Bridge and Bundle on the parameter lightsaml.route.login_check

On file app/vendor/lightsaml/symfony-bridge/src/LightSaml/SymfonyBridgeBundle/Resources/config/own.yml

lightsaml.route.login_check: lightsaml.login_check

on file app/vendor/lightsaml/sp-bundle/src/LightSaml/SpBundle/Resources/config/services.yml

lightsaml.route.login_check: lightsaml_sp.login_check

Or in the /app/vendor/lightsaml/sp-bundle/src/LightSaml/SpBundle/Resources/config/routing.yml we have

lightsaml_sp.login_check:
    path: /login_check

i think there are a error on own.yml on the Bridge we need replace lightsaml.route.login_check: lightsaml.login_check by => lightsaml.route.login_check: lightsaml_sp.login_check

what do you think ?

guiyomh commented 6 years ago

to test, i have add lightsaml.route.login_check: lightsaml_sp.login_check on my app/config/parameters.yml and now i'm redirect to the login form 😃

guiyomh commented 6 years ago

Arghh, so i have an other pb.

  1. i go to /saml/login
  2. i'm redirect to /saml/discovery, i choose my IDP
  3. i'm redirect to /saml/login?idp=
  4. now i'm rediret to (https://login.microsoftonline.com/xxxxxxxxxx/saml2 in POST with an SAMLRequest=XXXX)
  5. i fill the login form with my credential and i submit it in POST to /login (status 200)
  6. i'm redirect to my-app / in POST with an SAMLResponse=xxxxBig chainxxx
  7. And my app redirect me to /login

In the profiler i'm anonym but in my Azure AD console i show a succesfull login 🤕 as if, I did not go into login_check

guiyomh commented 6 years ago

Ok, i have found i confugure my AzureAD to redirect on /saml/check_login and now i'm login

HamidiMehdi commented 4 years ago

Hi, I'am actualy try to login with lightsaml in AzureAD with symfony 4.3 but it's doesn't work for me, I have the same error Unable to generate a URL for the named route "lightsaml_sp.login_check"

You can help me please ? I have following the Getting Started !

HamidiMehdi commented 4 years ago

With symfony 4.3 we don't have parameters.yml :/