Documentation
¶
Index ¶
- func EvaluateIssuanceRules(rules []IssuanceRule, ictx *IssuanceContext) error
- func ScopeContains(scopeString, target string) bool
- type Config
- type ErrorResponse
- type Handler
- type IssuanceContext
- type IssuanceDeniedError
- type IssuanceRule
- type IssuanceRuleConfig
- type Server
- type TokenDefaults
- type TokenExchangeRequest
- type TokenExchangeResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateIssuanceRules ¶
func EvaluateIssuanceRules(rules []IssuanceRule, ictx *IssuanceContext) error
EvaluateIssuanceRules evaluates all compiled issuance rules against the given context. Returns nil if all rules pass. Returns an error with the failing rule's message otherwise.
func ScopeContains ¶
ScopeContains checks if a space-delimited scope string contains a specific scope. This is a helper function available for use in application code; CEL rules use string operations directly.
Types ¶
type Config ¶
type Config struct {
// TrustDomain is the trust domain identifier, used as the `aud` claim in TxTokens.
TrustDomain string `yaml:"trustDomain"`
// Issuer is the TTS issuer URI, used as the `iss` claim in TxTokens.
Issuer string `yaml:"issuer"`
// SubjectTokens is an ordered list of JWT authenticators for subject token validation.
SubjectTokens []authn.AuthenticatorConfig `yaml:"subjectTokens"`
// Defaults contains default token settings.
Defaults TokenDefaults `yaml:"defaults"`
}
Config is the TTS server configuration, matching the TxTokenConfig CRD spec.
func LoadConfig ¶
LoadConfig reads and parses a TTS configuration file.
func (*Config) DefaultKeySize ¶
DefaultKeySize returns the RSA key size, defaulting to 2048.
func (*Config) DefaultTokenLifetime ¶
DefaultTokenLifetime returns the parsed token lifetime, defaulting to 15s.
type ErrorResponse ¶
type ErrorResponse struct {
Error string `json:"error"`
ErrorDescription string `json:"error_description,omitempty"`
}
ErrorResponse is the OAuth 2.0 error response.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler processes RFC 8693 token exchange requests and issues TxTokens.
func NewHandler ¶
func NewHandler(router *authn.Router, keyManager *keys.Manager, issuer, trustDomain string, lifetime time.Duration) *Handler
NewHandler creates a new token exchange handler.
func (*Handler) ServeHTTP ¶
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles the token exchange endpoint.
func (*Handler) SetIssuanceRules ¶
func (h *Handler) SetIssuanceRules(rules []IssuanceRule)
SetIssuanceRules updates the compiled issuance rules evaluated before token issuance.
func (*Handler) SetVerifier ¶
SetVerifier sets the TxToken verifier for token replacement support.
type IssuanceContext ¶
type IssuanceContext struct {
Subject string
Scope string
Tctx map[string]any
Rctx map[string]any
Workload string
WorkloadNS string
}
IssuanceContext contains the variables available to CEL issuance rules.
type IssuanceDeniedError ¶
IssuanceDeniedError is returned when an issuance rule evaluates to false.
func (*IssuanceDeniedError) Error ¶
func (e *IssuanceDeniedError) Error() string
type IssuanceRule ¶
type IssuanceRule struct {
Name string
// contains filtered or unexported fields
}
IssuanceRule is a compiled CEL issuance rule evaluated before token issuance.
func CompileIssuanceRules ¶
func CompileIssuanceRules(configs []IssuanceRuleConfig) ([]IssuanceRule, error)
CompileIssuanceRules compiles a list of issuance rule configs into executable programs.
type IssuanceRuleConfig ¶
type IssuanceRuleConfig struct {
Name string `json:"name" yaml:"name"`
CEL string `json:"cel" yaml:"cel"`
Message string `json:"message" yaml:"message"`
}
IssuanceRuleConfig is the configuration for an issuance rule (from TokenPolicy).
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the Transaction Token Service HTTP server.
func (*Server) KeyManager ¶
KeyManager returns the key manager (for testing).
type TokenDefaults ¶
type TokenDefaults struct {
// TokenLifetime is the default TxToken lifetime (e.g., "15s").
TokenLifetime string `yaml:"tokenLifetime"`
// KeySize is the RSA key size in bits (e.g., 2048).
KeySize int `yaml:"keySize"`
}
TokenDefaults contains default token configuration.
type TokenExchangeRequest ¶
type TokenExchangeRequest struct {
GrantType string
SubjectToken string
SubjectTokenType string
RequestedTokenType string
Audience string
Scope string
RequestDetails map[string]any // becomes tctx
RequestContext map[string]any // becomes rctx
}
TokenExchangeRequest represents the parsed RFC 8693 token exchange parameters.