Documentation
¶
Index ¶
- Constants
- func ExpiredTokenError(e echo.Context) error
- func ForbiddenError(e echo.Context, suffix *string) error
- func InputError(e echo.Context, custom *string) error
- func InsufficientScopeError(e echo.Context, requiredScope string) error
- func InvalidTokenError(e echo.Context) error
- func NewSafeFetchClient() *http.Client
- func OauthNormalizeHtu(u *url.URL) string
- func OauthParseHtu(htu string) (string, error)
- func ParseJWKFromBytes(b []byte) (jwk.Key, error)
- func RandomBytes(n int) []byte
- func RandomHex(n int) (string, error)
- func RandomVarchar(length int) string
- func ServerError(e echo.Context, suffix *string) error
- func UnauthorizedError(e echo.Context, suffix *string) error
Constants ¶
const SafeFetchClientMaxBodyBytes = 2 << 20
SafeFetchClientMaxBodyBytes caps response bodies for request-controlled fetches (OAuth client metadata / JWKS documents). 2 MiB is orders of magnitude beyond any legitimate OAuth metadata document while bounding memory use on hostile servers.
Variables ¶
This section is empty.
Functions ¶
func ExpiredTokenError ¶
func InsufficientScopeError ¶ added in v0.11.0
InsufficientScopeError responds 403 per RFC 6750 §3.1 when the session's granted scopes do not cover the requested operation. requiredScope is the scope that would have permitted it (e.g. "repo:app.bsky.feed.post?action=create").
func InvalidTokenError ¶
func NewSafeFetchClient ¶ added in v0.11.2
NewSafeFetchClient returns the HTTP client used for fetches where the URL (or the host it resolves to) is influenced by an external party — notably OAuth client_id / jwks_uri lookups, whose targets are chosen by the registering client.
It uses gttp with strict SSRF protection: the IP policy (loopback, private, link-local, CGNAT, NAT64, IMDS ranges) applies to the initial request URL and to every redirect, validation is bound to the actual dial (a hostname resolving to a blocked address cannot be fetched), https->http downgrades are refused, and response bodies are size-capped.
Note for local development: strict SSRF protection intentionally blocks loopback targets. The OAuth "http://localhost" client_id is exempt because its metadata is built virtually and never fetched; a loopback-hosted client instance must be registered through a non-loopback origin.
func OauthNormalizeHtu ¶
func OauthParseHtu ¶
func RandomBytes ¶
func RandomVarchar ¶
Types ¶
This section is empty.