Documentation
¶
Overview ¶
Package admin holds shared helpers for the /admin/v1 HTTP surface: RFC 7807 problem+json marshalling and keyset cursor encoding.
Index ¶
- Constants
- func DecodeAuditCursor(s, order string) (recordedAtUs int64, id ulid.ULID, err error)
- func DecodeCursor(s string) (time.Time, ulid.ULID, error)
- func EncodeAuditCursor(recordedAtUs int64, id ulid.ULID, order string) string
- func EncodeCursor(ts time.Time, id ulid.ULID) string
- func Write(w http.ResponseWriter, status int, code, detail, instance string)
- type Problem
Constants ¶
const ( CodeForbidden = "rbac.forbidden" CodeOrgMismatch = "rbac.org_mismatch" CodeNoActiveOrg = "rbac.no_active_org" CodeRoleInUse = "rbac.role_in_use" CodeUnknownPermission = "rbac.unknown_permission" CodeBadCursor = "pagination.bad_cursor" CodeUserNotInOrg = "admin.user_not_in_org" CodeValidationInvalid = "validation.invalid" CodeNotFound = "admin.not_found" CodeInternal = "admin.internal" CodeUnsupportedAction = "admin.unsupported_action" )
Reserved problem codes. Listed here so the admin handlers and the middleware both pull from the same source of truth.
const ProblemTypeBase = "https://theauth.dev/problems/"
ProblemTypeBase is the URI prefix for problem types per RFC 7807. Each problem code is appended to form the canonical type URI. Consumers may host their own equivalent page; the URI is informational only.
Variables ¶
This section is empty.
Functions ¶
func DecodeAuditCursor ¶ added in v2.12.0
DecodeAuditCursor reverses EncodeAuditCursor and requires the cursor to belong to order. Every failure wraps theauth.ErrBadCursor, which handlers map to a 400 with code "pagination.bad_cursor".
func DecodeCursor ¶
DecodeCursor reverses EncodeCursor. Returns an error on any malformed input; handlers map the error to a 400 problem+json with code "pagination.bad_cursor".
func EncodeAuditCursor ¶ added in v2.12.0
EncodeAuditCursor returns the write-order keyset cursor for the audit endpoint: the opaque "c1." string for the last row of a page, bound to order ("asc" or "desc"). Clients treat it as opaque and send it back as the cursor query parameter.
func EncodeCursor ¶
EncodeCursor returns a URL-safe base64 string of "<unix_micros>:<ulid>". Decoding is symmetric and tolerant of any input that round-trips back to a parsable (int64, ULID) pair; everything else returns an error.
Types ¶
type Problem ¶
type Problem struct {
Type string `json:"type"`
Title string `json:"title"`
Status int `json:"status"`
Detail string `json:"detail,omitempty"`
Instance string `json:"instance,omitempty"`
Code string `json:"code"`
}
Problem is the RFC 7807 application/problem+json document shape, plus the "code" extension this library uses for machine-readable error matching.