tokenmanager

package
v3.0.0-...-edfc480 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//CM login url
	CMLoginURL              = "/api/login"
	CMAccessTokenExpiration = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Credentials

type Credentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

Credentials represent the username and password used for authentication.

type TokenManager

type TokenManager struct {
	ServerURL string

	SslInsecure  bool
	TrustedCerts string
	// contains filtered or unexported fields
}

TokenManager is responsible for managing the authentication token.

func NewTokenManager

func NewTokenManager(serverURL string, credentials Credentials, trustedCerts string, sslInsecure bool) *TokenManager

NewTokenManager creates a new instance of TokenManager.

func (*TokenManager) FetchToken

func (tm *TokenManager) FetchToken() error

FetchToken retrieves a new token from the CM.

func (*TokenManager) GetToken

func (tm *TokenManager) GetToken() string

GetToken returns the current valid saved token.

func (*TokenManager) SyncToken

func (tm *TokenManager) SyncToken(stopCh chan struct{})

SyncToken maintains valid token. It fetches a new token before expiry.

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	UserID       string `json:"user_id"`
}

TokenResponse represents the response received from the CM.

Jump to

Keyboard shortcuts

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