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

credential

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Names lists every credential, in the order a resolution tries and reports them.

Functions

func WithCacheOf

func WithCacheOf(credential Credential, action func(cache reflect.Value))

Types

type ApiKey

type ApiKey struct {
	Endpoint     xurl.URL
	ClientId     uuid.UUID `json:"client_id"`
	ClientSecret string    `json:"client_secret"`

	Cache *struct {
		Token jwt.JWT `json:"token,omitzero"`
	} `json:"-"`
}

func (*ApiKey) CachedToken

func (apiKey *ApiKey) CachedToken(_ context.Context, _ getWorkspaceFunc) (token jwt.JWT, found bool)

func (*ApiKey) Identity

func (apiKey *ApiKey) Identity() Identity

func (*ApiKey) Name added in v0.2.0

func (apiKey *ApiKey) Name() Name

func (*ApiKey) RefreshCachedToken

func (apiKey *ApiKey) RefreshCachedToken(ctx context.Context, client http.Client, _ getWorkspaceFunc) error

type Credential

type Credential interface {
	Name() Name
	// Identity identifies the credential, so that a cache minted for another one is not used.
	Identity() Identity
	// CachedToken does not check the expiry. The caller does, and calls RefreshCachedToken for an
	// expired token.
	CachedToken(ctx context.Context, getWorkspace getWorkspaceFunc) (token jwt.JWT, found bool)
	// RefreshCachedToken re-mints the token, so a CachedToken call after it finds one.
	RefreshCachedToken(ctx context.Context, client http.Client, getWorkspace getWorkspaceFunc) error
}

type Credentials

type Credentials struct {
	ApiKey    *ApiKey    `json:"apiKey,omitempty"`
	Manual    *Manual    `json:"manual,omitempty"`
	OidcLogin *OidcLogin `json:"oidcLogin,omitempty"`
}

func (*Credentials) ByName

func (cs *Credentials) ByName(name Name) Credential

func (*Credentials) Set added in v0.2.0

func (cs *Credentials) Set(cred Credential)

type Identity

type Identity struct {
	Hash string
}

type Manual

type Manual struct {
	Endpoint xurl.URL `json:"endpoint"`
	Cache    *struct {
		Token jwt.JWT `json:"token"`
	} `json:"-"`
}

func NewManual added in v0.2.0

func NewManual(endpoint xurl.URL, token jwt.JWT) *Manual

func (*Manual) CachedToken

func (manual *Manual) CachedToken(_ context.Context, _ getWorkspaceFunc) (jwt.JWT, bool)

func (*Manual) Identity

func (manual *Manual) Identity() Identity

func (*Manual) Name added in v0.2.0

func (manual *Manual) Name() Name

func (*Manual) RefreshCachedToken

func (manual *Manual) RefreshCachedToken(_ context.Context, _ http.Client, _ getWorkspaceFunc) error

type Name

type Name string
const (
	ApiKeyName    Name = "apiKey"
	ManualName    Name = "manual"
	OidcLoginName Name = "oidcLogin"
)

func (Name) Label added in v0.3.0

func (n Name) Label() string

func (Name) String

func (n Name) String() string

type OidcLogin

type OidcLogin struct {
	Endpoint xurl.URL `json:"endpoint"`
	Issuer   xurl.URL `json:"issuer"`
	ClientId string   `json:"clientId"`
	// AccessLevel is empty for a login of an older CLI, or on a meshStack without access levels.
	AccessLevel meshstack.AccessLevel `json:"accessLevel,omitzero"`
	Cache       *struct {
		RefreshToken     string                  `json:"refreshToken"`
		RefreshExpiresAt time.Time               `json:"refreshExpiresAt,omitzero"`
		ScopedTokens     map[scope.Scope]jwt.JWT `json:"tokens,omitzero"`
	} `json:"-"`
}

func (*OidcLogin) CachedToken

func (oidcLogin *OidcLogin) CachedToken(ctx context.Context, getWorkspace getWorkspaceFunc) (token jwt.JWT, found bool)

func (*OidcLogin) Identity

func (oidcLogin *OidcLogin) Identity() Identity

func (*OidcLogin) Name added in v0.2.0

func (oidcLogin *OidcLogin) Name() Name

func (*OidcLogin) RefreshCachedToken

func (oidcLogin *OidcLogin) RefreshCachedToken(ctx context.Context, client http.Client, getWorkspace getWorkspaceFunc) error

func (*OidcLogin) StoreLogin

func (oidcLogin *OidcLogin) StoreLogin(oidcToken oidc.Token)

Jump to

Keyboard shortcuts

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