Documentation
¶
Index ¶
- Constants
- type Credentials
- type Reference
- type TokenManager
- func (tm *TokenManager) GetToken() string
- func (tm *TokenManager) RefreshToken() error
- func (tm *TokenManager) SetToken(token string, expirationMicros int64)
- func (tm *TokenManager) Start(stopCh chan struct{}, duration time.Duration)
- func (tm *TokenManager) SyncToken() error
- func (tm *TokenManager) SyncTokenWithoutRetry() (err error, exit bool)
- type TokenManagerInterface
- type TokenResponse
Constants ¶
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 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.