dongyun65343 2013-10-16 19:28
浏览 50
已采纳

Symfony Security Forces HTTPS尽管require_channel http

I'm working on configuring a new symfony install for security, but my login form won't behave. Whenever i'm redirected to the login page, symfony redirects to https and adds :80 to the domain.

Here's my security.yml

# app/config/security.yml
security:
    firewalls:
        login:
            pattern: ^/login
            anonymous: true
        main:
            pattern:    ^/
            anonymous:  false
            form_login:
                login_path: /login
                check_path: /login_check
            logout:
                path:   /logout
                target: /home

    access_control:
        - { path: ^/login$,    roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: http  }
        - { path: ^/secure, roles: IS_AUTHENTICATED_FULLY }
        - { path: ^/secure/max, roles: ROLE_ADMIN }

    providers:
        in_memory:
            memory:
                users:
                    ryan:  { password: ryanpass, roles: 'ROLE_USER' }
                    admin: { password: kitten, roles: 'ROLE_ADMIN' }

    encoders:
        Symfony\Component\Security\Core\User\User: plaintext

The Routing file for my login path controller:

login:
    pattern: /login
    defaults: { _controller: RGCoreBundle:Default:login }

login_check:
    pattern: /login_check

When I visit the home page, i'm redirected to:

https://myserver.com:80/login

...which obviously doesnt work because I dont have SSL configured...

I've tried changing the login route's path and it will update to point at the new path, so it's definately reading the config file...

Where else should I look? This is a fresh install and I wiped out the ACME bundle already.

Update:

I'm diving my way through the Kernel with the debugger and print statements.

So far i can determine it's doing this because, when authentication fails (as it should), a redirect response is generated for "login_path". The call to generateUri calls the original Request objects 'geturi" function.

Tracing this, the cause so far is that the Request object's ServerBag has HTTPS => on.

I haven't figured out where that get's set though.

  • 写回答

2条回答 默认 最新

  • dsxz84851 2013-10-16 20:15
    关注

    Based on your security file it doesnt appear to be a symfony issue. Likely there is some configuration with your web server that is redirecting to https and to port 80. If you cant find that i would do a file text search in your project for "80" and see if there is anything redirecting you to that port and likely the https will be in the same spot

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试