tokenexchange

package
v19.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package tokenexchange verifies token-exchange JWTs against the issuer's published keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsKeysUnavailable

func IsKeysUnavailable(err error) bool

IsKeysUnavailable reports whether Verify failed because the signing keys have not been fetched yet, so the token itself may be valid.

Types

type Verifier

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

Verifier checks token-exchange JWTs against one issuer's published keys.

func NewVerifier

func NewVerifier(ctx context.Context, log *slog.Logger, meter metric.Meter, rt http.RoundTripper, gitLabAddress, issuerURL string, audiences []string) (*Verifier, error)

NewVerifier verifies JWTs whose iss claim is issuerURL, signed with a key from the set the GitLab at gitLabAddress serves. It fetches that set in the background and keeps refetching it until ctx is done; until the first fetch succeeds Ready is false and every token is rejected with IsKeysUnavailable. The fetch goes over rt, so rt decides which certificate authorities are trusted.

func (*Verifier) Ready

func (v *Verifier) Ready() bool

Ready reports whether the key set has been fetched, so Verify can judge a token.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, token string) (*userauth.Token, error)

Verify returns the claims of token if it is a valid token-exchange JWT from the issuer for one of the audiences.

Jump to

Keyboard shortcuts

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