Git Product home page Git Product logo

Comments (3)

a-menshchikov avatar a-menshchikov commented on May 27, 2024 1

I don't know the way to specify a certain dispatcher when use a subscriber. But I have no idea why you need to use a subsciber in a Symfony 6 application while you can use the #[AsEventListener(dispatcher: 'security.event_dispatcher.main')] attribute. IMO this is the same approach as we've had earlier with event subscribers.

from onelogin-saml-bundle.

a-menshchikov avatar a-menshchikov commented on May 27, 2024

@slejnej hi!
Thank you for your question.

It's important to remember that authentication events are security events. So you need to specify correct value for a dispatcher property of the listener configuration.
For example, if you use this bundle in main firewall, you should specify security.event_dispatcher.main as a dispatcher for your listener.

from onelogin-saml-bundle.

slejnej avatar slejnej commented on May 27, 2024

@a-menshchikov Thank you for your response.

Maybe some updates to the README with an example how to use that because tagging for the event and method is then not sufficient to create a listener, but it also needs dispatcher: security.event_dispatcher.main (or firewall used in) defined when wiring.

Subscriber to Nbgrp\OneloginSamlBundle\Event\UserCreatedEvent is never visible for this event, but same subscriber for CheckPassportEvent::class is listed.

The code:

use Nbgrp\OneloginSamlBundle\Event\UserCreatedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Http\Event\CheckPassportEvent;

...

public static function getSubscribedEvents()
  {
    // return the subscribed events, their methods and priorities
    return [
      UserCreatedEvent::class => 'onUserCreated',
      CheckPassportEvent::class => ['onUserCreated', -1],
    ];
  }

debug output:

"Nbgrp\OneloginSamlBundle\Event\UserCreatedEvent" event
-------------------------------------------------------

 ------- ----------------------------------------------------------------------------- ---------- 
  Order   Callable                                                                      Priority  
 ------- ----------------------------------------------------------------------------- ---------- 
  #1      Nbgrp\OneloginSamlBundle\EventListener\User\UserCreatedListener::__invoke()   0         
 ------- ----------------------------------------------------------------------------- ---------- 

"Nbgrp\OneloginSamlBundle\Event\UserModifiedEvent" event
--------------------------------------------------------


"Symfony\Component\Security\Http\Event\CheckPassportEvent" event
----------------------------------------------------------------

 ------- ------------------------------------------------------------------------------------------- ---------- 
  Order   Callable                                                                                    Priority  
 ------- ------------------------------------------------------------------------------------------- ---------- 
  #1      Symfony\Component\Security\Http\EventListener\UserProviderListener::checkPassport()         2048      
  #2      Symfony\Component\Security\Http\EventListener\UserProviderListener::checkPassport()         1024      
  #3      Symfony\Component\Security\Http\EventListener\CsrfProtectionListener::checkPassport()       512       
  #4      Symfony\Component\Security\Http\EventListener\UserCheckerListener::preCheckCredentials()    256       
  #5      Nbgrp\OneloginSamlBundle\EventListener\User\DeferredUserListener::dispatchDeferredEvent()   0         
  #6      Symfony\Component\Security\Http\EventListener\CheckCredentialsListener::checkPassport()     0         
  #7      App\EventSubscriber\SecurityEventSubscriber::onUserCreated()                                -1        
 ------- ------------------------------------------------------------------------------------------- ---------- 

from onelogin-saml-bundle.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.