registrytokenhttp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package registrytokenhttp — thin HTTP transport for the IAM Docker Registry v2 auth-server: the `/iam/token` endpoint.

Transport only: parse the Docker token-auth request, delegate to the registry_token use-case (which verifies the presented BASIC ACCESS TOKEN — the only credential kind this lane accepts, задача #1143 — and issues the registry token), format the Docker-compatible JSON. No business logic.

───────────────────────────────────────────────────────────────────────────── КТО ЧЕКАНИТ ТОКЕН ЭТОЙ ПОЛОСЫ — ЗАВИСИТ ОТ ПОСАДКИ, И ЭТО НАДО ЗНАТЬ ПЕРВЫМ

Здесь стояло «Hydra remains the token issuer/signer; kaname mints NOTHING». Утверждение ПЕРЕЖИЛО СВОЙ ПРЕДМЕТ:

своя чеканка объявлена   → чеканит НАШ подписант
                           (internal/registrytokenwire.LocalMintAdapter
                           поверх internal/tokensigner)
не объявлена             → полоса брокерит токен у провайдера, как прежде

Различать обязательно: при разборе «почему плоскость данных отвергла токен» первый вопрос — ЧЕЙ это токен, и по ответу выбирается сторона, на которой чинить.

───────────────────────────────────────────────────────────────────────────── КЛЮЧИ ПРОВЕРКИ ЖИВУТ НЕ ЗДЕСЬ

Своего эндпоинта набора ключей у этого mux нет: плоскость данных берёт ключи у внутреннего публикатора (:9097, package internal/handler/jwksproxyhttp), и записей у него ДВЕ — зеркало провайдера на каноническом well-known и НАША по пути `authn.token-signing.key-set-path`. Потребитель выбирает запись по объявленному издателю токена, а не перебором.

Endpoint:

GET|POST /iam/token — Docker Registry v2 token endpoint.

Index

Constants

View Source
const TokenPath = "/iam/token"

TokenPath — the token endpoint path. MUST equal the data-plane's Bearer realm path (the WWW-Authenticate realm), so verifiers and docker clients resolve the same URL.

Variables

This section is empty.

Functions

func NewMux

func NewMux(token http.Handler) *http.ServeMux

NewMux mounts the token handler on its canonical path. The caller exposes the returned mux on an EXTERNAL-reachable HTTP listener (docker clients hit /iam/token through the edge) — unlike the cluster-internal hooks mux.

Types

type Config

type Config struct {
	// Realm — the token-endpoint URL advertised in WWW-Authenticate (must match
	// the data-plane's Bearer realm, e.g. https://api.kacho.local/iam/token).
	Realm string
	// DefaultService — the service name used in WWW-Authenticate when the request
	// omits ?service= (e.g. registry.kacho.local).
	DefaultService string
}

Config — handler config (the WWW-Authenticate realm + default service name).

type TokenHandler

type TokenHandler struct {
	// contains filtered or unexported fields
}

TokenHandler — the `/iam/token` endpoint.

func NewTokenHandler

func NewTokenHandler(cfg Config, issuer TokenIssuer) *TokenHandler

NewTokenHandler — builder.

func (*TokenHandler) ServeHTTP

func (h *TokenHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*TokenHandler) WithLogger

func (h *TokenHandler) WithLogger(l *slog.Logger) *TokenHandler

WithLogger провязывает журнал причин отказа. Отдельным методом, а не полем Config: Config описывает то, что видит КЛИЕНТ (realm, имя службы), а журнал — то, что видим мы.

type TokenIssuer

type TokenIssuer interface {
	Execute(ctx context.Context, in registrytokenuc.IssueInput) (registrytokenuc.IssueOutput, error)
	ExecuteAnonymous(ctx context.Context, service string) (registrytokenuc.IssueOutput, error)
	AnonymousEnabled() bool
}

TokenIssuer — the registry_token use-case port the handler delegates to. Execute serves the presented-credential (Basic) path; ExecuteAnonymous brokers the public `user:*` anonymous-pull path (no Basic creds); AnonymousEnabled reports whether that path is configured (else the handler fails closed to a challenge).

Jump to

Keyboard shortcuts

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