How can I authenticate a user from a dynamic path?

Is there a way in symfony2 to authenticate a user for a dynamic path?

For example, if I have a firewall like this:

main: pattern: ^/ 

and after the user's user path looks like /someSlug/... , is there an authentication method for this template only? so many users can be registered? Normally, if I knew bullets, I would set up a few firewalls

  main1: pattern: ^/slug1/ main2: pattern: ^/slug2/ 

and it was done, but I need it dynamically, because I do not know how many slugs exist and what they are.

Any ideas?

+5
source share
1 answer

Because of the box, I suspect probably not.

Idea number 1:

If this is administrative work, you should use Use Impersanation.

http://symfony.com/doc/current/cookbook/security/impersonating_user.html

Idea number 2:

If this is a universal use for this (other than administrative), perhaps you can probably install a kernel request listener that will listen for each request, parse the given slug and set the set User object in the session. This object must be used by controllers and templates.

What do you think?

+1
source

Source: https://habr.com/ru/post/1201629/


All Articles