Documentation ¶
Overview ¶
Package buildtoken provide related functions for dealing with build tokens.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.