tokenmanager

package
v2.20.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BIGIP login url
	BIGIPLoginURL = "/mgmt/shared/authn/login"
	BIGIPTokenURL = "/mgmt/shared/authz/tokens/"
	RetryInterval = time.Duration(10)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Username          string `json:"username"`
	Password          string `json:"password"`
	LoginProviderName string `json:"loginProviderName,omitempty"`
}

Credentials represent the username and password used for authentication.

type Reference

type Reference struct {
	Link string `json:"link"`
}

Reference represents a reference to a resource.

type TokenManager

type TokenManager struct {
	Token string

	ServerURL string

	SslInsecure bool
	// contains filtered or unexported fields
}

TokenManagerInterface is responsible for managing the authentication Token.

func NewTokenManager

func NewTokenManager(serverURL string, credentials Credentials, httpClient *http.Client) *TokenManager

NewTokenManager creates a new instance of TokenManager.

func (*TokenManager) GetToken

func (tm *TokenManager) GetToken() string

GetToken returns the current valid saved Token.

func (*TokenManager) RefreshToken

func (tm *TokenManager) RefreshToken() error

RefreshToken extends the lifetime of the current Token.

func (*TokenManager) SetToken

func (tm *TokenManager) SetToken(token string, expirationMicros int64)

SetToken safely sets the Token in the TokenManager.

func (*TokenManager) Start

func (tm *TokenManager) Start(stopCh chan struct{}, duration time.Duration)

Start maintains valid Token. It fetches a new Token before expiry.

func (*TokenManager) SyncToken

func (tm *TokenManager) SyncToken() error

SyncToken is a helper function to fetch Token and retry on failure

func (*TokenManager) SyncTokenWithoutRetry

func (tm *TokenManager) SyncTokenWithoutRetry() (err error, exit bool)

SyncTokenWithoutRetry retrieves a new Token from the BIGIP.

type TokenManagerInterface

type TokenManagerInterface interface {
	GetToken() string
	RefreshToken() error
	SyncToken() error
	SyncTokenWithoutRetry() (error, bool)
	SetToken(token string, expirationMicros int64)
	Start(stopCh chan struct{}, duration time.Duration)
}

type TokenResponse

type TokenResponse struct {
	Token struct {
		Token            string    `json:"Token"`
		ExpirationMicros int64     `json:"expirationMicros"`
		LastUse          int64     `json:"lastUse"`
		Timeout          int       `json:"timeout"`
		UserReference    Reference `json:"userReference"`
	} `json:"Token"`
}

TokenResponse represents the response received from the BIGIP.

Jump to

Keyboard shortcuts

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