Documentation
¶
Index ¶
- Constants
- type ClientKey
- type Config
- type Handler
- type JWK
- type JWKS
- type K8sStore
- func (s *K8sStore) DeleteKey(_ context.Context, issuer string) error
- func (s *K8sStore) GetKey(_ context.Context, issuer string) (ed25519.PublicKey, error)
- func (s *K8sStore) ListKeys(_ context.Context) ([]ClientKey, error)
- func (s *K8sStore) PutKey(_ context.Context, issuer string, pubKey ed25519.PublicKey) error
- type MemoryStore
- func (s *MemoryStore) DeleteKey(_ context.Context, issuer string) error
- func (s *MemoryStore) GetKey(_ context.Context, issuer string) (ed25519.PublicKey, error)
- func (s *MemoryStore) ListKeys(_ context.Context) ([]ClientKey, error)
- func (s *MemoryStore) PutKey(_ context.Context, issuer string, pubKey ed25519.PublicKey) error
- type ServerConfig
- type ServerEntry
- type StorageConfig
- type Store
- type TLSConfig
Constants ¶
const ( // DefaultNamespace is the Kubernetes namespace for registry secrets. DefaultNamespace = "bridge-system" // SecretPrefix is the prefix for secret file names. SecretPrefix = "bridge-client-" // PublicKeyField is the key name within the secret data. PublicKeyField = "jwt-public-key.pem" )
const (
// MaxKeyUploadBytes limits the size of a public key upload body.
MaxKeyUploadBytes = 4096
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Listen string `yaml:"listen"`
TLS TLSConfig `yaml:"tls"`
Storage StorageConfig `yaml:"storage"`
Servers []ServerEntry `yaml:"servers"`
}
Config holds the registry service configuration.
func LoadConfig ¶
LoadConfig reads and parses a registry config YAML file.
func (*Config) BuildServerConfig ¶
func (c *Config) BuildServerConfig() ServerConfig
BuildServerConfig converts the config's server entries to a ServerConfig.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements the HTTP handlers for the key registry.
func NewHandler ¶
func NewHandler(store Store, cfg ServerConfig, logger *slog.Logger) *Handler
NewHandler creates a new Handler with the given store and config.
func (*Handler) GetJWKS ¶
func (h *Handler) GetJWKS(w http.ResponseWriter, r *http.Request)
GetJWKS handles GET /v1/servers/{server_id}/jwks.json. Returns only the keys for issuers allowed on the given server.
func (*Handler) Health ¶
func (h *Handler) Health(w http.ResponseWriter, _ *http.Request)
Health returns a simple health check response.
func (*Handler) RegisterRoutes ¶
RegisterRoutes registers all handler routes on the given mux.
type JWK ¶
type JWK struct {
Kty string `json:"kty"`
Crv string `json:"crv"`
X string `json:"x"`
Kid string `json:"kid"`
Use string `json:"use"`
}
JWK represents a single JSON Web Key (RFC 7517).
type JWKS ¶
type JWKS struct {
Keys []JWK `json:"keys"`
}
JWKS represents a JSON Web Key Set (RFC 7517).
func ClientKeysToJWKS ¶
ClientKeysToJWKS converts a slice of ClientKey to a JWKS.
type K8sStore ¶
type K8sStore struct {
// contains filtered or unexported fields
}
K8sStore implements Store by reading and writing files in a directory structured as one subdirectory per issuer. In a Kubernetes deployment, a persistent volume or emptyDir backs the directory. Outside Kubernetes, it operates as a plain file-backed store.
func NewK8sStore ¶
NewK8sStore creates a file-backed store at the given directory.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory implementation of Store for testing and non-Kubernetes environments.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore creates a new in-memory store.
func (*MemoryStore) DeleteKey ¶
func (s *MemoryStore) DeleteKey(_ context.Context, issuer string) error
DeleteKey removes the key for the given issuer.
type ServerConfig ¶
ServerConfig maps server IDs to their allowed issuers.
type ServerEntry ¶
ServerEntry maps a server ID to its allowed issuers.
type StorageConfig ¶
type StorageConfig struct {
Type string `yaml:"type"` // "memory" or "file"
BaseDir string `yaml:"base_dir"` // required when type=file
}
StorageConfig selects and configures the storage backend.
type Store ¶
type Store interface {
// PutKey stores or replaces the public key for the given issuer.
PutKey(ctx context.Context, issuer string, pubKey ed25519.PublicKey) error
// GetKey retrieves the public key for the given issuer.
// Returns nil, nil if the issuer is not found.
GetKey(ctx context.Context, issuer string) (ed25519.PublicKey, error)
// ListKeys returns all registered client keys.
ListKeys(ctx context.Context) ([]ClientKey, error)
// DeleteKey removes the key for the given issuer.
DeleteKey(ctx context.Context, issuer string) error
}
Store defines the interface for persisting and retrieving client public keys.