Return "correct" error code or protect privacy?

OK, perhaps the best example is what I mean.

Imagine a forum web system where user authentication is performed using some external method that the system knows about.

Now, say, for example, the user enters a URL for a stream that they don’t have access to. To do this, I must return 403 (Forbidden) so that the user knows that they should try a different authentication method or 404, not letting them know that there is something there to access.

Assuming I return 403, should I also return 403 when they access the URL for a topic that does not yet exist?

Edit: The above example was rather an example of something that is IRL.

Another example, let's say I'm showing something like

/adminnotes/user

if there are administrator notes about the user. Now, returning 403, the user finds out that he is talking about something. 404 would not say anything.

But, if I were to return 403 - I could return it for adminnotes / * - which would solve this problem.

Edit 2: Another example. Soft deleted questions here return 404. However, with proper authentication and access you can still see them (I suppose)

+3
source share
9 answers

, HTTP. 403 404 . 404 403, , ( ), . , . -, , .

+5

307 NoSuchPageOrNoPermissions.html, , URL-, .

.

, , .

, , ,

1.

, ISP, - : www.isp.example/home/USERNAME USERNAME@isp.example. , www.isp.example/home/[Random] , , .

2.

, , . , , : www.example.com/Bob www.example.com/Bob/IceCream , 403. www.example.com/Bob/Cake 404 .

Bobs,

  • www.example.com/Bob/Cake - 404
  • www.example.com/Bob/Donuts - 404
  • www.example.com/Bob/Lollies - 404
  • www.example.com/Bob/IceCream - 403

.

+4

, 307 ( ) "/adminnotes/user" "/adminnotes/". , "/adminnotes/", 403, .

, HTTP-, .

+3

"" , ?

, 403 404 , , . 403 , , - .

+2

- , , , 404, , 403, .

+1

, URL. stackoverflow QuestionID. , Return "correct" ? .

+1

, 404 . , , . , , .

-, . 404, , .

, , . . , . /adminnotes/.

, , , , rfc http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html:

10.4.4 403 , . , . HEAD, , , . , 404 (Not Found).

10.4.5 404 , Request-URI. , . 410 (Gone) , - , , , . , , , .

, , , " ", . "", , , , - , .

+1

, " ", , . , .

, URL- .., , , , TAC .. ?

, , , , , .

0

:

  • Exists_Thread, 404
  • User_Can_Access_to_this_Thread, 403
0

Source: https://habr.com/ru/post/1697651/


All Articles