auth

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKey

type APIKey struct {
	Name       string `json:"name"`
	PrivateKey string `json:"privateKey"`
}

APIKey represents a Coinbase Cloud API Key.

func NewAPIKey

func NewAPIKey(opts ...APIKeyOption) (*APIKey, error)

NewAPIKey creates a new Coinbase Cloud API Key based on the provided options.

type APIKeyClaims

type APIKeyClaims struct {
	*jwt.Claims
	URI string `json:"uri"`
}

APIKeyClaims holds public claim values for a JWT, as well as a URI.

type APIKeyOption

type APIKeyOption func(t *apiKeyConfig)

APIKeyOption is a function that applies changes to a apiKeyConfig.

func WithAPIKeyName

func WithAPIKeyName(apiKeyName, apiKeyPrivateKey string) APIKeyOption

WithAPIKeyName returns an option to set the API Key.

func WithLoadAPIKeyFromEnv

func WithLoadAPIKeyFromEnv(loadAPIKeyFromEnv bool) APIKeyOption

WithLoadAPIKeyFromEnv returns an option to set whether to load the API Key from environment variables. If the API Key name and private key are both set, they take precedence over the environment variables.

func WithLoadAPIKeyFromFile

func WithLoadAPIKeyFromFile(loadAPIKeyFromFile bool) APIKeyOption

WithLoadAPIKeyFromFile returns an option to set whether to load the API Key from file directly. If the API Key name and private key are both set, they take precedence over the environment variables. Next if the env vars are set they take precedence or else the file is used if set.

type Authenticator

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

Authenticator builds a JWT based on the APIKey.

func NewAuthenticator

func NewAuthenticator(apiKey *APIKey) *Authenticator

NewAuthenticator returns a new Authenticator.

func (*Authenticator) BuildJWT

func (a *Authenticator) BuildJWT(service, uri string) (string, error)

BuildJWT constructs and returns the JWT as a string along with an error, if any.

Jump to

Keyboard shortcuts

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