Documentation
¶
Overview ¶
Package registrytoken mints and checks the JWTs that scope access to hypeman's registry, for builder VMs and image publication.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims struct {
jwt.RegisteredClaims
// BuildID is the build job identifier for audit purposes
BuildID string `json:"build_id"`
// RepoAccess defines per-repository access permissions (new two-tier format)
// If present, this takes precedence over the legacy Repositories/Scope fields
RepoAccess []RepoPermission `json:"repo_access,omitempty"`
// Repositories is the list of allowed repository paths (legacy format, kept for backward compat)
// Deprecated: Use RepoAccess for new tokens
Repositories []string `json:"repos,omitempty"`
// Scope is the access scope (legacy format, kept for backward compat)
// Deprecated: Use RepoAccess for new tokens
Scope string `json:"scope,omitempty"`
}
Claims contains the claims for a scoped registry access token. These tokens are issued to builder VMs to grant limited access to specific repositories.
func (*Claims) GetRepoScope ¶
GetRepoScope returns the scope for a specific repository. Returns empty string if the repository is not allowed.
func (*Claims) IsPullAllowed ¶
IsPullAllowed returns true if the token grants pull (read) access. Push tokens also implicitly grant pull access. Deprecated: Use IsPullAllowedForRepo for per-repo scope checking.
func (*Claims) IsPullAllowedForRepo ¶
IsPullAllowedForRepo returns true if the token grants pull (read) access to the given repo. Push scope also implicitly grants pull access.
func (*Claims) IsPushAllowed ¶
IsPushAllowed returns true if the token grants push (write) access to any repo. Deprecated: Use IsPushAllowedForRepo for per-repo scope checking.
func (*Claims) IsPushAllowedForRepo ¶
IsPushAllowedForRepo returns true if the token grants push (write) access to the given repo.
func (*Claims) IsRepositoryAllowed ¶
IsRepositoryAllowed checks if the given repository path is allowed by the token claims.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator creates scoped registry access tokens
func NewGenerator ¶
NewGenerator creates a new token generator with the given secret
func (*Generator) GeneratePushToken ¶
func (g *Generator) GeneratePushToken(buildID string, repos []string, ttl time.Duration) (string, error)
GeneratePushToken creates a short-lived token granting push access to specific repositories. The token expires after the specified duration (typically matching the build timeout). Deprecated: Use GenerateToken for new code that needs per-repo scopes.
func (*Generator) GenerateToken ¶
func (g *Generator) GenerateToken(buildID string, repoAccess []RepoPermission, ttl time.Duration) (string, error)
GenerateToken creates a short-lived token with per-repository access permissions. This supports the two-tier cache model where different repos can have different scopes. For example: pull on cache/global/*, push on cache/{tenant}
type RepoPermission ¶
type RepoPermission struct {
// Repo is the repository path (e.g., "builds/abc123", "cache/tenant-x", "cache/global/node")
Repo string `json:"repo"`
// Scope is the access scope for this repo: "pull" for read-only, "push" for read+write
Scope string `json:"scope"`
}
RepoPermission defines access permissions for a specific repository. This enables fine-grained control where different repos can have different scopes.