authtoken

package
v0.11.5 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT license.

Copyright (c) Microsoft Corporation. Licensed under the MIT license.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultRefreshDurationFunc = func(token AuthToken) time.Duration {
		return time.Until(token.ExpiresOn) / 2
	}
	DefaultCreateTicker    = time.Tick
	DefaultRefreshDuration = time.Second * 30
)

Functions

This section is empty.

Types

type AuthToken added in v0.11.2

type AuthToken struct {
	Token     string    // The authentication token string.
	ExpiresOn time.Time // The expiration time of the token.
}

An AuthToken is an authentication token used to communicate with the hub API server.

type CreateTickerFuncType

type CreateTickerFuncType func(time.Duration) <-chan time.Time

type Factory

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

func NewFactory

func NewFactory(filePath string) Factory

func (Factory) Create

func (w Factory) Create() (io.WriteCloser, error)

type Provider added in v0.11.2

type Provider interface {
	// FetchToken fetches an authentication token to make requests to its associated fleet's hub cluster.
	// It returns the token for a given input context, or an error if the retrieval fails.
	FetchToken(ctx context.Context) (AuthToken, error)
}

Provider defines a method for fetching an authentication token.

type RefreshDurationFuncType

type RefreshDurationFuncType func(token AuthToken) time.Duration

type Refresher

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

func NewAuthTokenRefresher

func NewAuthTokenRefresher(tokenProvider Provider,
	writer Writer,
	refreshCalculate RefreshDurationFuncType,
	createTicker CreateTickerFuncType) *Refresher

func (*Refresher) RefreshToken

func (at *Refresher) RefreshToken(ctx context.Context) error

type TokenWriter added in v0.11.2

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

func (*TokenWriter) WriteToken added in v0.11.2

func (w *TokenWriter) WriteToken(token AuthToken) error

type Writer

type Writer interface {
	// WriteToken writes the provided authentication token to a filepath location specified in a TokenWriter.
	// It returns an error if the writing process fails.
	WriteToken(token AuthToken) error
}

Writer defines a method for writing an authentication token to a specified location.

func NewWriter

func NewWriter(factory func() (io.WriteCloser, error)) Writer

Directories

Path Synopsis
providers

Jump to

Keyboard shortcuts

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