v1auth

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	//NCEScope is the JWT scope for the NCE service
	NCEScope = "nce.nerdalize.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ClientConfig
	// contains filtered or unexported fields
}

Client is the client for the nerdalize authentication server.

func NewClient

func NewClient(c ClientConfig) *Client

NewClient creates a new Auth.

func (*Client) GetCluster added in v1.0.0

func (c *Client) GetCluster(url string) (output *v1payload.GetClusterOutput, err error)

GetCluster retrieve a precised cluster so we can get its authentication details.

func (*Client) GetJWT

func (c *Client) GetJWT(scope string) (output *v1payload.GetJWTOutput, err error)

GetJWT gets a JWT for a given scope

func (*Client) GetProject added in v1.0.0

func (c *Client) GetProject(id string) (output *v1payload.GetProjectOutput, err error)

GetProject retrieve a precised project so we can validate its existence and find on which cluster it's living.

func (*Client) GetWorkerJWT

func (c *Client) GetWorkerJWT(project, scope string) (output *v1payload.GetWorkerJWTOutput, err error)

GetWorkerJWT gets a new worker JWT

func (*Client) ListClusters added in v1.0.0

func (c *Client) ListClusters() (output *v1payload.ListClustersOutput, err error)

ListClusters lists clusters

func (*Client) ListProjects

func (c *Client) ListProjects() (output *v1payload.ListProjectsOutput, err error)

ListProjects lists projects

type ClientConfig

type ClientConfig struct {
	Doer               Doer
	Base               *url.URL
	OAuthTokenProvider OAuthTokenProvider
	Logger             *log.Logger
}

ClientConfig provides config details to create an Auth client.

type Doer

type Doer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer executes http requests. It is implemented by *http.Client.

type HTTPError

type HTTPError struct {
	StatusCode int
	Err        *v1payload.Error
}

HTTPError is an error that is used when a server responded with a status code >= 400. Based on the actual status code a custom error message will be generated.

func (HTTPError) Cause

func (e HTTPError) Cause() error

Cause is implemented to be compatible with the pkg/errors package.

func (HTTPError) Error

func (e HTTPError) Error() string

Error returns the error message specific for the status code.

type OAuthTokenProvider

type OAuthTokenProvider interface {
	IsExpired() bool
	Retrieve() (string, error)
}

OAuthTokenProvider is capable of providing a oauth access token. When IsExpired return false the in-memory token will be used to prevent from calling Retrieve for each API call.

type OpsClient

type OpsClient struct {
	OpsClientConfig
}

OpsClient is used for a bunch of operations on the auth API that don't require oauth authentication.

func NewOpsClient

func NewOpsClient(c OpsClientConfig) *OpsClient

NewOpsClient creates a new OpsClient.

func (*OpsClient) GetOAuthCredentials

func (c *OpsClient) GetOAuthCredentials(code, clientID, clientSecret, localServerURL string) (output *v1payload.GetOAuthCredentialsOutput, err error)

GetOAuthCredentials gets oauth credentials based on a 'session' code

func (*OpsClient) RefreshOAuthCredentials

func (c *OpsClient) RefreshOAuthCredentials(refreshToken, clientID, clientSecret string) (output *v1payload.RefreshOAuthCredentialsOutput, err error)

RefreshOAuthCredentials refreshes an oauth access token

type OpsClientConfig

type OpsClientConfig struct {
	Doer   Doer
	Base   *url.URL
	Logger *log.Logger
}

OpsClientConfig is the config for OpsClient

type OpsClientInterface

type OpsClientInterface interface {
	GetOAuthCredentials(code, clientID, clientSecret, localServerURL string) (output *v1payload.GetOAuthCredentialsOutput, err error)
	RefreshOAuthCredentials(refreshToken, clientID, clientSecret string) (output *v1payload.RefreshOAuthCredentialsOutput, err error)
}

OpsClientInterface is an interface so client calls can be mocked.

type StaticOAuthTokenProvider

type StaticOAuthTokenProvider struct {
	Token string
}

StaticOAuthTokenProvider is a simple oauth token provider that always returns the same token.

func NewStaticOAuthTokenProvider

func NewStaticOAuthTokenProvider(token string) *StaticOAuthTokenProvider

NewStaticOAuthTokenProvider creates a new StaticOAuthTokenProvider for the given token.

func (*StaticOAuthTokenProvider) IsExpired

func (s *StaticOAuthTokenProvider) IsExpired() bool

IsExpired always returns false.

func (*StaticOAuthTokenProvider) Retrieve

func (s *StaticOAuthTokenProvider) Retrieve() (string, error)

Retrieve always returns the given token.

type TokenClient

type TokenClient struct {
	TokenClientConfig
}

TokenClient is used for a bunch of operations on the auth API that don't require oauth authentication.

func NewTokenClient

func NewTokenClient(c TokenClientConfig) *TokenClient

NewTokenClient creates a new TokenClient.

func (*TokenClient) RefreshJWT

func (c *TokenClient) RefreshJWT(projectID, jwt, secret string) (output *v1payload.RefreshWorkerJWTOutput, err error)

RefreshJWT refreshes a JWT with a refresh token

func (*TokenClient) RevokeJWT

func (c *TokenClient) RevokeJWT(projectID, jwt, secret string) (output *v1payload.RefreshWorkerJWTOutput, err error)

RevokeJWT revokes a JWT

type TokenClientConfig

type TokenClientConfig struct {
	Doer   Doer
	Base   *url.URL
	Logger *log.Logger
}

TokenClientConfig is the config for TokenClient

type TokenClientInterface

type TokenClientInterface interface {
	RefreshJWT(projectID, jwt, secret string) (output *v1payload.RefreshWorkerJWTOutput, err error)
	RevokeJWT(projectID, jwt, secret string) (output *v1payload.RefreshWorkerJWTOutput, err error)
}

TokenClientInterface is an interface so client calls can be mocked.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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