1

我刚刚更新到 4.0.30 并注意到 /auth?username=xxxx&password=xxxx 无论用户是否成功通过身份验证都会返回 200 状态。甚至尝试使用 PostMan。由于我在最近的任何更改日志中都没有看到任何内容,如果有的话,发生了什么变化?

4

1 回答 1

1

如果您未通过身份验证,则/auth返回 a 401 Not Authenticated,例如:

https://httpbenchmarks.servicestack.net/auth

AuthenticateService 允许您使用Get(Authenticate request)请求进行身份验证,但如果您提供不正确的用户名或密码,它将返回一个401 Invalid UserName or Password,例如:

https://httpbenchmarks.servicestack.net/auth?username=xxx&password=xxx

但是您可以使用正确的用户名和密码登录:

https://httpbenchmarks.servicestack.net/auth?username=test@test.com&password=test

在这种情况下,如果您通过身份验证,/auth将返回 200 和摘要会话信息,例如:

https://httpbenchmarks.servicestack.net/auth

{
  "UserId": "59",
  "SessionId": "Jtp6IYoTnW460xGNTGSE",
  "UserName": "test@test.com",
  "DisplayName": "Test Test",
  "ResponseStatus": { }
}

注意:您应该明确使用哪个身份验证提供程序登录,例如,对于使用用户名/密码进行身份验证,您应该使用显式/auth/credentials路由。

于 2014-08-19T20:57:57.617 回答