buildtoken

package
v0.0.0-...-c36c937 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package buildtoken provide related functions for dealing with build tokens.

Index

Constants

This section is empty.

Variables

View Source
var ErrBadToken = errors.New("invalid token", grpcutil.UnauthenticatedTag)

ErrBadToken is the only error returned by ParseToTokenBody.

This includes a codes.Unauthenticated tag.

Functions

func GenerateToken

func GenerateToken(ctx context.Context, buildID int64, purpose pb.TokenBody_Purpose) (string, error)

GenerateToken generates base64 encoded byte string token for a build.

func ParseToTokenBody

func ParseToTokenBody(ctx context.Context, bldTok string, buildID int64, purposes ...pb.TokenBody_Purpose) (*pb.TokenBody, error)

ParseToTokenBody deserializes the build token and returns the token body.

buildID will be asserted to match the token's contents. If buildID is 0, this will skip the buildID check.

Additionally, the token contents must match one of the values provided in `purposes`. If `purposes` is empty, a token of any purpose will be returned without error.

All parsing errors are logged and this function returns ErrBadToken which is tagged with codes.Unauthenticated.

Types

This section is empty.

Jump to

Keyboard shortcuts

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