Help us shape the future of Go! Take the 2026 Go Developer Survey

apitoken

package
v1.108.4 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const Audience = "api-token-auth.chainloop"

Variables

View Source
var SigningMethod = jwt.SigningMethodHS256

Functions

This section is empty.

Types

type Builder

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

func NewBuilder

func NewBuilder(opts ...NewOpt) (*Builder, error)

NewBuilder creates a new APIToken JWT builder It supports expiration and revocation Currently we use a simple hmac encryption method meant to be continuously rotated TODO: additional/alternative encryption method, i.e DSE asymmetric, see CAS robot account for reference

func (*Builder) GenerateJWT

func (ra *Builder) GenerateJWT(opts *GenerateJWTOptions) (string, error)

GenerateJWT creates a new JWT token for the given organization and keyID

type CustomClaims

type CustomClaims struct {
	OrgID        string `json:"org_id"`
	OrgName      string `json:"org_name"`
	KeyName      string `json:"token_name"`
	ProjectID    string `json:"project_id,omitempty"`
	ProjectName  string `json:"project_name,omitempty"`
	WorkflowID   string `json:"workflow_id,omitempty"`
	WorkflowName string `json:"workflow_name,omitempty"`
	Scope        string `json:"scope,omitempty"`
	jwt.RegisteredClaims
}

type GenerateJWTOptions added in v1.12.0

type GenerateJWTOptions struct {
	OrgID        *uuid.UUID
	OrgName      *string
	KeyID        uuid.UUID
	KeyName      string
	ProjectID    *uuid.UUID
	ProjectName  *string
	WorkflowID   *uuid.UUID
	WorkflowName *string
	ExpiresAt    *time.Time
	Scope        *string
}

type NewOpt

type NewOpt func(b *Builder)

func WithIssuer

func WithIssuer(issuer string) NewOpt

func WithKeySecret

func WithKeySecret(hmacSecret string) NewOpt

Jump to

Keyboard shortcuts

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