Documentation
¶
Index ¶
- func AuthRetryMiddleware(tokenManager *TokenManager) ...
- func GetAdminToken(settingsFile ...string) (string, error)
- func GetToken(email, password, apiKey string, opts ...option.RequestOption) (string, error)
- func WithAutoAuth(tokenManager *TokenManager) option.RequestOption
- func WithTokenAuth(token string) option.RequestOption
- type TokenInfo
- type TokenManager
- type TokenRequest
- type TokenResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthRetryMiddleware ¶
func AuthRetryMiddleware(tokenManager *TokenManager) func(*http.Request, func(*http.Request) (*http.Response, error)) (*http.Response, error)
AuthRetryMiddleware automatically retries requests with fresh tokens on 401/403 errors
func GetAdminToken ¶
GetAdminToken generates an admin token using environment variables or settings file
func GetToken ¶
func GetToken(email, password, apiKey string, opts ...option.RequestOption) (string, error)
GetToken attempts to generate a CloudCIX token for the given credentials
func WithAutoAuth ¶
func WithAutoAuth(tokenManager *TokenManager) option.RequestOption
WithAutoAuth creates a request option that automatically adds authentication
func WithTokenAuth ¶
func WithTokenAuth(token string) option.RequestOption
WithTokenAuth creates a request option that sets the X-Auth-Token header
Types ¶
type TokenInfo ¶
type TokenInfo struct {
Token string `json:"token"`
ExpiresAt time.Time `json:"expires_at"`
IssuedAt time.Time `json:"issued_at"`
}
TokenInfo holds token details and expiration
type TokenManager ¶
type TokenManager struct {
// contains filtered or unexported fields
}
TokenManager handles automatic token renewal
func NewTokenManager ¶
func NewTokenManager(settings *config.Settings) *TokenManager
NewTokenManager creates a new token manager
func (*TokenManager) GetValidToken ¶
func (tm *TokenManager) GetValidToken(ctx context.Context, opts ...option.RequestOption) (string, error)
GetValidToken returns a valid token, refreshing if necessary
func (*TokenManager) InvalidateToken ¶
func (tm *TokenManager) InvalidateToken()
InvalidateToken forces token refresh on next request
func (*TokenManager) IsTokenValid ¶
func (tm *TokenManager) IsTokenValid() bool
IsTokenValid checks if the current token is still valid
type TokenRequest ¶
type TokenRequest struct {
Email string `json:"email"`
Password string `json:"password"`
ApiKey string `json:"api_key"`
}
TokenRequest represents the request payload for token creation
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token"`
}
TokenResponse represents the response from token creation