admin

package
v2.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package admin holds shared helpers for the /admin/v1 HTTP surface: RFC 7807 problem+json marshalling and keyset cursor encoding.

Index

Constants

View Source
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"
	CodeUnauthorized      = "auth.unauthorized"
	CodeUnsupportedAction = "admin.unsupported_action"
)

Reserved problem codes. Listed here so the admin handlers and the middleware both pull from the same source of truth.

View Source
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

func DecodeAuditCursor(s, order string) (recordedAtUs int64, id ulid.ULID, err error)

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

func DecodeCursor(s string) (time.Time, ulid.ULID, error)

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

func EncodeAuditCursor(recordedAtUs int64, id ulid.ULID, order string) string

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

func EncodeCursor(ts time.Time, id ulid.ULID) string

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.

func Write

func Write(w http.ResponseWriter, status int, code, detail, instance string)

Write emits a single problem+json response. status drives both the HTTP status code and the body's "status" field so the two cannot drift.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL