Documentation
¶
Overview ¶
Package utils holds the HTTP response writers the OAuth endpoints share: JSON bodies that must not be cached, and RFC 6749 §5.2 error bodies.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteBearerEndpointError ¶
func WriteBearerEndpointError(w http.ResponseWriter, r *http.Request, err error)
WriteBearerEndpointError is WriteRFC6749Error for an endpoint that accepts a bearer token. A 401 matches the scheme the client used, as RFC 6749 §5.2 requires, and every 400 also gets a Bearer challenge without an error code. RFC 6750 §3 requires one when the request has no credentials and allows it otherwise, which avoids inspecting the request.
func WriteNoStoreJSON ¶
func WriteNoStoreJSON(w http.ResponseWriter, status int, body any)
WriteNoStoreJSON writes body with the no-store headers token endpoints require (RFC 6749 §5.1, RFC 7662 §4). Encoding happens before the status is committed, so an unencodable body becomes a 500 instead of a success status over a truncated body; the headers are set first so the fallback carries them too.
func WriteRFC6749Error ¶
func WriteRFC6749Error(w http.ResponseWriter, r *http.Request, err error)
WriteRFC6749Error writes err as an RFC 6749 §5.2 error without its debug field, with a Basic WWW-Authenticate challenge on a 401. Client authentication is the only 401 source on these endpoints, so the challenge is Basic whatever credentials the request carried.
Types ¶
This section is empty.