registrytoken

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

func (c *Claims) GetRepoScope(repo string) string

GetRepoScope returns the scope for a specific repository. Returns empty string if the repository is not allowed.

func (*Claims) IsPullAllowed

func (c *Claims) IsPullAllowed() bool

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

func (c *Claims) IsPullAllowedForRepo(repo string) bool

IsPullAllowedForRepo returns true if the token grants pull (read) access to the given repo. Push scope also implicitly grants pull access.

func (*Claims) IsPushAllowed

func (c *Claims) IsPushAllowed() bool

IsPushAllowed returns true if the token grants push (write) access to any repo. Deprecated: Use IsPushAllowedForRepo for per-repo scope checking.

func (*Claims) IsPushAllowedForRepo

func (c *Claims) IsPushAllowedForRepo(repo string) bool

IsPushAllowedForRepo returns true if the token grants push (write) access to the given repo.

func (*Claims) IsRepositoryAllowed

func (c *Claims) IsRepositoryAllowed(repo string) bool

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

func NewGenerator(secret string) *Generator

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}

func (*Generator) ValidateToken

func (g *Generator) ValidateToken(tokenString string) (*Claims, error)

ValidateToken parses and validates a registry token, returning the claims if valid.

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.

Jump to

Keyboard shortcuts

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