News for hackers. Stuff that matters.
Re:API Shouldn't Redirect HTTP to HTTPS by ants_everywhere on Tuesday May 28, 2024 @09:06PM (#40507209)
400 is usually for a malformed request. It seems like in this case the request is well formed, it's just not allowed. 403 seems reasonable if the user isn't authorized to make a request to the URL, which they aren't. Some APIs return redirects which also seems pretty reasonable.
Re:API Shouldn't Redirect HTTP to HTTPS by mbreese on Tuesday May 28, 2024 @11:08PM (#40508032)
But that also implies that some user would be authorized to make a request to the HTTP port (or that the resource does exist, which in this case it doesn’t).

IMO, 400 is more accurate, but really either could be acceptable, so long as the client is notified of the error. But, I wouldn’t automatically redirect the client. That’s what we are trying to avoid.

Re:API Shouldn't Redirect HTTP to HTTPS by ants_everywhere on Wednesday May 29, 2024 @10:43AM (#40512504)
Good point.

I guess this might depend a little on the implementation. In some cases the http endpoint may exist but may only be accessible to a sidecar container via localhost. For example, if the sidecar terminates https.

Re:API Shouldn't Redirect HTTP to HTTPS by endofreach on Tuesday May 28, 2024 @09:35PM (#40507383)
Well in that case really anything is a 403.
Re:API Shouldn't Redirect HTTP to HTTPS by kijin on Tuesday May 28, 2024 @09:42PM (#40507437)
404 would also work, since the resource does not exist at the http: address.
Re:API Shouldn't Redirect HTTP to HTTPS by bruce511 on Wednesday May 29, 2024 @12:31AM (#40508485)
True, but 404 has trained us to look hard at the URL part, not the protocol part.

Whereas 403 or 400 are less likely to have so automated built-in handling on the client side.