如何通过 HTTPS 登录并仍按记录在 HTTP 上导航?
How can I login via HTTPS and still navigate on HTTP as logged?
在 Symfony 中,如果我使用 HTTPS
模式登录,我总是重定向到 HTTPS
路由。如果我将其从地址栏更改为 HTTP
,它会再次询问我的密码。
我想通过 HTTPS
登录,但在其他页面上停留在 HTTP
模式(除非我访问敏感数据)我该如何实现?
用户通过 HTTPS 登录后,我是否应该在控制器内部为 HTTP 创建另一个 cookie?并检查 cookie 在 http
?
上是否有效
我想这样做:
- David 使用用户名和密码登录网站
https://a.login
- David 重定向到
https://a.admin/
(因为它是 https,因为管理页面)
- David 现在按下一个按钮,管理面板重定向不重要的页面。称为 http://a.somepage(不是 https)
- 但是我的网站(symfony)应该知道这是大卫。而是再次询问密码和用户名。因为它来自 HTTPS 到 HTTP
我正在使用 Symfony 的标准 SecurityBundle
。同时使用两种模式(http/s)进行身份验证的正确方法是什么?
现实世界示例:
Whosebug 做同样的事情。我点击 log in
并重定向到 https
和 成功登录后 我只返回 HTTP
。我错过了什么吗?
内尔米奥
我在 GitHub 上找到了这个捆绑包。它做我想做的,甚至更多。我建议并选择这个作为答案。
Flexible HTTPS/SSL Handling: If you don't want to force all users to
use HTTPS, you should at least use secure session cookies and force
SSL for logged-in users. But then logged-in users appear logged-out
when they access a non-HTTPS resource. This is not really a good
solution. This will make the application detect logged-in users and
redirect them to a secure URL, without making the session cookie
insecure.
参考: https://github.com/nelmio/NelmioSecurityBundle#flexible-httpsssl-handling
在 Symfony 中,如果我使用 HTTPS
模式登录,我总是重定向到 HTTPS
路由。如果我将其从地址栏更改为 HTTP
,它会再次询问我的密码。
我想通过 HTTPS
登录,但在其他页面上停留在 HTTP
模式(除非我访问敏感数据)我该如何实现?
用户通过 HTTPS 登录后,我是否应该在控制器内部为 HTTP 创建另一个 cookie?并检查 cookie 在 http
?
我想这样做:
- David 使用用户名和密码登录网站
https://a.login
- David 重定向到
https://a.admin/
(因为它是 https,因为管理页面) - David 现在按下一个按钮,管理面板重定向不重要的页面。称为 http://a.somepage(不是 https)
- 但是我的网站(symfony)应该知道这是大卫。而是再次询问密码和用户名。因为它来自 HTTPS 到 HTTP
我正在使用 Symfony 的标准 SecurityBundle
。同时使用两种模式(http/s)进行身份验证的正确方法是什么?
现实世界示例:
Whosebug 做同样的事情。我点击 log in
并重定向到 https
和 成功登录后 我只返回 HTTP
。我错过了什么吗?
内尔米奥
我在 GitHub 上找到了这个捆绑包。它做我想做的,甚至更多。我建议并选择这个作为答案。
Flexible HTTPS/SSL Handling: If you don't want to force all users to use HTTPS, you should at least use secure session cookies and force SSL for logged-in users. But then logged-in users appear logged-out when they access a non-HTTPS resource. This is not really a good solution. This will make the application detect logged-in users and redirect them to a secure URL, without making the session cookie insecure.
参考: https://github.com/nelmio/NelmioSecurityBundle#flexible-httpsssl-handling