cspauth

package
v0.0.0-...-b3aaee5 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Retry = 3
)

Variables

View Source
var (
	DummyAccessToken = "dummy-access-token"
	SendError        = "send-error"
)
View Source
var (
	ErrorCspForbidden            = errors.New("forbidden")
	ErrorCspUnauthorized         = errors.New("unauthorized")
	ErrorCspBadRequest           = errors.New("invalid api_token, it might be expired")
	ErrorRefreshTokenNotValid    = errors.New("refresh_token cannot be empty")
	UnexpectedResponseStatusCode = errors.New("unexpected csp error")
)
View Source
var RetryDelay time.Duration = 5

Functions

This section is empty.

Types

type CSPAuthorizeResponse

type CSPAuthorizeResponse struct {
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
	AccessToken  string `json:"access_token"`
	Scope        string `json:"scope"`
	IDToken      string `json:"id_token"`
	TokenType    string `json:"token_type"`
}

CSPAuthorizeResponse represents a response from CSP with information about the authorization. AccessToken is the value needed to perform valid calls to TAC backend.

type CSPClient

type CSPClient interface {
	GetCspAuthorization(ctx context.Context, refreshToken string) (*CSPAuthorizeResponse, error)
}

CSPClient represents a CSPClient place here for future mocking purposes Will contain all methods related to calls directly to CSP. Please note this is not usual since it would be TAC the one talking with CSP.

type CSPHttpClient

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

CSPHttpClient is the client to perform talks to CSP.

func NewCspHTTPClient

func NewCspHTTPClient() (*CSPHttpClient, error)

NewCspHTTPClient creates a new CSPHttpClient

func (*CSPHttpClient) GetCspAuthorization

func (c *CSPHttpClient) GetCspAuthorization(ctx context.Context, apiToken string) (*CSPAuthorizeResponse, error)

GetCspAuthorization connects to CSP to retrieve information regarding the given API token

type CspAuth

type CspAuth struct {
	CspClient CSPClient
	// contains filtered or unexported fields
}

func (*CspAuth) GetBearerToken

func (a *CspAuth) GetBearerToken(clientSet kubernetes.Interface, ctx context.Context, cspSecretNamespace string, cspSecretName string) (string, error)

type MockCSPClient

type MockCSPClient struct {
}

MockCSPClient is a mock of the CSPClient interface

func NewMockCSPClient

func NewMockCSPClient() *MockCSPClient

NewMockCSPClient creates a new mock instance

func (*MockCSPClient) GetCspAuthorization

func (m *MockCSPClient) GetCspAuthorization(ctx context.Context, apiToken string) (*CSPAuthorizeResponse, error)

type Provider

type Provider interface {
	// GetBearerToken retrieves a short-lived access token to use in a single HTTP request
	GetBearerToken(kubernetes.Interface, context.Context, string, string) (string, error)
}

Provider is an interface to interact with an authorization service

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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