Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2.1 REST API login to everywhere

I am working on a REST API using Symfony 2.1.

My code works now perfectly, but there is problem that I can login in /api/ but this login can work only under /api/*. But I need to have access to whole page.

api:
    pattern: ^/api
    #anonymous: ~
    form_login: false
    provider: fos_userbundle
    http_basic:
        realm: "REST Service"

main:
    pattern: .*
    provider: fos_userbundle
    form_login:
        check_path: fos_user_security_check
        login_path: fos_user_security_login
        default_target_path: wi_homepage
    logout:
        path: fos_user_security_logout
        target: wi_homepage
    anonymous:    true
    switch_user: true
    remember_me:
        key: "%secret%"
        name: RememberMe
        lifetime: 2592000
        remember_me_parameter: _remember_me

So is there any way to make http login under /api/ directory and have access to anywhere?

like image 467
PayteR Avatar asked Nov 23 '12 03:11

PayteR


1 Answers

solution is really simple, there needs to be same context for both firewalls

context: some_random_context_name_you_can_choose_freely

http://forum.symfony-project.org/viewtopic.php?f=23&t=60654&p=164063#p164063

like image 99
PayteR Avatar answered Oct 13 '22 12:10

PayteR