Should phx.gen.auth return 401s

No, it does not confer that either. I suppose you could say it confers “this website has a 404 template”, if you wanted to.

But the problem, as discussed with the git example, is that some routes are public unless you don’t have access. So if you try to load up a public repo you can see it, but if you load a private repo it has to 404. If you 401 for the private route then you admit that it exists.

You could instead return 401 for repos that actually don’t exist, but that is even more confusing!

The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

Should read RFC updates at breakfast. Settles it: 404 is okey. Also “current representation” :sweat_smile:

4 Likes

Huh, the more you know. Did they add that at some point or was it there the whole time?

It’s added at some point.

the explicit acknowledgment that a server might intentionally hide the existence of a resource by returning a 404 status code was first documented in RFC 7231.​

2014 it issss. Guess it is not known to many. Look at this thread and even my eating RFC’s for breakfast colleague missed it.

1 Like

Answer to the question: no, 404 is fine.

Case closed.

4 Likes