tokencache

package
v3.0.0-rc46 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(contextName string) error

Delete forgets the tokens of a context. The tokens an openid context shares with others are kept for them, and forgotten with the last of them.

func Exists

func Exists(contextName string) bool

func FmtFilename

func FmtFilename(contextName string) string

func GetAll

func GetAll() map[string]Entry

func ModTime

func ModTime(contextName string) (time.Time, error)

func OpenStore

func OpenStore(backend tokenstore.Backend) (tokenstore.Store, error)

OpenStore returns the store of a backend, or the first usable one when backend is empty.

func ReconnectError

func ReconnectError(srcErr error, contextName string) error

ReconnectError says a cached token could not be used, and names the command that renews it.

That command is always ox, whichever program is reporting: only ox manages the client contexts, so an om reading a context whose token expired is fixed with ox too.

func Save

func Save(contextName string, token Entry) error

func SaveShared

func SaveShared(token Entry) error

SaveShared saves the tokens of an openid entry in the store its reference names, for the contexts reading them there, without touching the file of any context.

Types

type Entry

type Entry struct {
	AccessTokenExpire   time.Time          `json:"access_expired_at"`
	AccessToken         string             `json:"access_token"`
	AccessTokenDuration *duration.Duration `json:"access_token_duration,omitempty"`
	RefreshTokenExpire  time.Time          `json:"refresh_expired_at"`
	RefreshToken        string             `json:"refresh_token"`

	// OpenID is set when the tokens were issued by the openid issuer the
	// cluster trusts, rather than by the cluster. They are then shared by
	// the contexts logging in at the same issuer and client, kept in the
	// token store OpenID names, and only this reference is in the file of
	// the context.
	OpenID *OpenID `json:"openid,omitempty"`
}

func FindOpenID

func FindOpenID(issuer, clientID string) *Entry

FindOpenID returns the tokens some context logged in at the issuer and client, in any usable store, so another context of the same issuer and client logs in with them, without a challenge. It returns nil when there are none.

func GetLast

func GetLast() (string, Entry)

func Load

func Load(contextName string) (*Entry, error)

func (Entry) HasValidRefresh

func (t Entry) HasValidRefresh(now time.Time) bool

HasValidRefresh says whether the refresh token of an entry can be tried: one whose expiry the issuer did not tell is tried until it is refused.

type OpenID

type OpenID struct {
	Issuer        string             `json:"issuer"`
	ClientID      string             `json:"client_id"`
	TokenEndpoint string             `json:"token_endpoint"`
	Store         tokenstore.Backend `json:"store"`
}

OpenID names the tokens an openid issuer gave for a client, and where they are kept.

func (OpenID) Name

func (t OpenID) Name() string

Name is the name of the entry of the token store the tokens are kept in, the same for every context of the issuer and client.

Jump to

Keyboard shortcuts

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