Documentation
¶
Overview ¶
Package demokit provides an interactive step-through framework for OneAuth examples. Each example defines a sequence of steps (with mermaid diagram arrows) and optional sections (explanatory text). The same definitions drive both the interactive CLI and the generated README.
Single source of truth: step titles, arrows, and notes are defined in Go code. The README's mermaid diagram and step documentation are generated from these definitions — never maintained by hand.
Usage:
demo := demokit.New("01: Client Credentials Flow").
Description("Non-UI | No infrastructure needed").
Actors(
demokit.Actor("App", "Client App"),
demokit.Actor("AS", "Auth Server"),
)
demo.Step("Register a client").
Arrow("App", "AS", "POST /apps/register").
Arrow("AS", "App", "{client_id, client_secret}").
Note("The client gets credentials for later use.").
Run(func() { fmt.Println("registered!") })
demo.Execute()
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( RFC6749 = Ref{"RFC 6749 — OAuth 2.0", "https://www.rfc-editor.org/rfc/rfc6749"} RFC6749_ClientCredentials = Ref{"RFC 6749 §4.4 — Client Credentials Grant", "https://www.rfc-editor.org/rfc/rfc6749#section-4.4"} RFC6749_AuthorizationCode = Ref{"RFC 6749 §4.1 — Authorization Code Grant", "https://www.rfc-editor.org/rfc/rfc6749#section-4.1"} RFC6750 = Ref{"RFC 6750 — Bearer Token Usage", "https://www.rfc-editor.org/rfc/rfc6750"} )
OAuth 2.0
var ( RFC7515 = Ref{"RFC 7515 — JSON Web Signature (JWS)", "https://www.rfc-editor.org/rfc/rfc7515"} RFC7517 = Ref{"RFC 7517 — JSON Web Key (JWK)", "https://www.rfc-editor.org/rfc/rfc7517"} RFC7519 = Ref{"RFC 7519 — JSON Web Token (JWT)", "https://www.rfc-editor.org/rfc/rfc7519"} RFC7638 = Ref{"RFC 7638 — JWK Thumbprint (kid)", "https://www.rfc-editor.org/rfc/rfc7638"} )
JWT / JWS / JWK
var ( RFC7591 = Ref{"RFC 7591 — Dynamic Client Registration", "https://www.rfc-editor.org/rfc/rfc7591"} RFC7636 = Ref{"RFC 7636 — PKCE", "https://www.rfc-editor.org/rfc/rfc7636"} RFC7662 = Ref{"RFC 7662 — Token Introspection", "https://www.rfc-editor.org/rfc/rfc7662"} RFC8414 = Ref{"RFC 8414 — AS Metadata Discovery", "https://www.rfc-editor.org/rfc/rfc8414"} )
Token management
var ( RFC9728 = Ref{"RFC 9728 — Protected Resource Metadata", "https://www.rfc-editor.org/rfc/rfc9728"} CVE_2015_9235 = Ref{"CVE-2015-9235 — JWT Algorithm Confusion", "https://nvd.nist.gov/vuln/detail/CVE-2015-9235"} )
Security
var (
RFC9396 = Ref{"RFC 9396 — Rich Authorization Requests", "https://www.rfc-editor.org/rfc/rfc9396"}
)
Rich Authorization Requests
Functions ¶
This section is empty.
Types ¶
type ActorDef ¶
type ActorDef struct {
ID string // Short identifier used in arrows (e.g., "AS")
Label string // Display label (e.g., "Auth Server")
}
ActorDef defines a participant in the sequence diagram.
type Demo ¶
type Demo struct {
// contains filtered or unexported fields
}
Demo is the top-level container for an interactive example.
func (*Demo) Description ¶
Description sets the one-line description shown in the CLI header.
func (*Demo) Dir ¶
Dir sets the directory name used in generated README run commands. e.g., Dir("01-client-credentials") produces "go run ./examples/01-client-credentials/"
func (*Demo) Execute ¶
func (d *Demo) Execute()
Execute runs the demo interactively — pausing between steps for Enter. If --non-interactive is passed (or stdin is not a terminal), runs without pausing.
func (*Demo) Markdown ¶
Markdown generates the full README content from the demo definition. This is the single source of truth — run with --readme to regenerate.
type Ref ¶
type Ref struct {
Name string // e.g., "RFC 7519 (JWT)" or "CVE-2015-9235"
URL string // e.g., "https://www.rfc-editor.org/rfc/rfc7519"
}
Ref is a named reference (RFC, CVE, blog post, spec section, etc.).
type SectionDef ¶
type SectionDef struct {
// contains filtered or unexported fields
}
SectionDef is a non-executable block of explanatory content.
type StepDef ¶
type StepDef struct {
// contains filtered or unexported fields
}
StepDef defines one executable step in the demo.
func (*StepDef) DashedArrow ¶
DashedArrow adds a dashed arrow (response) to the step's sequence diagram.