rest - 访问被拒绝 : 403 or 404?

标签 rest http http-status-code-404 http-status-code-403

如果有人请求访问不允许他查看的实体,应该返回什么状态代码?您可能会说它是 403:禁止访问。但是返回 404 是常见的做法吗?我不希望有人知道这个实体存在,如果他不被允许看到的话。你怎么看?

最佳答案

使用 404 未找到。

The 404 status code can also be used in 403 scenarios, when the server does not want to send back the reason why it is refusing to serve the request. A good example is when the server senses some kind of an attack, which might be a brute force attack. In this case, the server responds with a 404 Not found instead of a 403 Forbidden and an explanation.

来源:Pro ASP.NET Web API Security

关于rest - 访问被拒绝 : 403 or 404?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28582830/

相关文章:

java - 从两个 post 方法接收字符串 - Java Rest

java - 输入流上的 JAX-RS 自定义范围

http - HTTP 重定向代码之间的区别

java - Java HTTP 推送(消息传递)的最佳解决方案

java - 请求处理程序已执行,但响应状态始终为 404

linux - HTTP 请求未响应 404 未找到

javascript - 从后端获取枚举并将其用作 javascript 中的字符串

iOS - 使用 RestKit 发布 : callback functions not called - (mapping data used)

Angular 4 基于 cookie 的身份验证

json - 错误 404.3 未找到 JSON 文件