v1auth

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2017 License: Apache-2.0 Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) GetJWT

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

GetJWT gets a JWT for a given scope

func (*Client) GetWorkerJWT

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

GetWorkerJWT gets a new worker JWT

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, 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 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, localServerURL string) (output *v1payload.GetOAuthCredentialsOutput, err error)
	RefreshOAuthCredentials(refreshToken, clientID 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