这个问题一般是关于网络应用程序的登录流程的问题.我最感兴趣的是能够在保持安全性的同时优化可用性和性能的答案.
为了演示该问题,以下是示例应用程序的一些路由和相应的行为:
GET /login -> Display the authentication form
POST /processLogin -> process the username and password,
if unauthentic...re-render the login form;
otherwise...display the default page
GET /secret -> if authenticated...display the secret resource;
otherwise...display a login form
POST /secret -> if authenticated...perform a desirable, but potentially
non-idempotent action on the secret
resource
otherwise...display a login form
Run Code Online (Sandbox Code Playgroud)
分析:希望您的客户端是一个现代浏览器,不符合HTTP,因此它会在302的POST后执行GET.这适用于所有人.我应该担心吗?