Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I authenticate user against dynamic path?

Tags:

symfony

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

For example if i have a firewall like this:

    main:
        pattern: ^/

and after login user path looks like this /someSlug/... is there a way to authenticate them only for that pattern? so multiple users can be loggedin ? Normally if i would know the slugs i would set up multiple firewalls

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

and it's done, but i need it dynamically because i don't know how much slugs there is gona be and what they are.

Any ideas ?

like image 525
vardius Avatar asked Nov 10 '22 02:11

vardius


1 Answers

Out-of-box, I suspect probably not.

Idea #1:

If this is administrative work you should be use to use Use impersanation.

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

Idea #2:

If this is a general purpose use for this (other than administrative) you should be probably able to set kernel request listener that will listen for each request, parse out the given slug and set set User object in session. That object is to be used by controllers and templates.

What do you think?

like image 149
Jovan Perovic Avatar answered Nov 15 '22 09:11

Jovan Perovic