ecauth

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthorizationProvider

type AuthorizationProvider interface {
	GetAuthorizationHeader() (string, error)
}

AuthorizationProvider defines structs that can provide Authorization headers

type IDSAuthorizationProvider

type IDSAuthorizationProvider struct {
	// The latest token. May be expired.
	CurrentToken *IDSToken

	// TokenClient retrievees new tokens
	TokenClient OAuth2Client

	// The Credentials used to retrieve new tokens
	Credentials OAuth2Credentials
}

Generates IDS Authorization Header values

func NewIDSAuthorizationProvider

func NewIDSAuthorizationProvider(
	baseIDSURL url.URL,
	credentials OAuth2Credentials,
) (*IDSAuthorizationProvider, error)

Creates a new IDSAuthorizationProvider with the given credentials that retrieves tokens from the specified URL

func (*IDSAuthorizationProvider) GetAuthorizationHeader

func (ip *IDSAuthorizationProvider) GetAuthorizationHeader() (string, error)

GetAuthorizationHeader creates an authorization header value for the current token, refreshing it if it has expired. Used for EdgeCast APIs that use IDS OAuth 2.0 tokens.

type IDSClient

type IDSClient struct {
	IDSBaseUrl *url.URL
}

Calls the IDS token endpoint

func NewIDSClient

func NewIDSClient(baseURL url.URL) IDSClient

NewIDSClientWithURL -

func (IDSClient) GetToken

func (c IDSClient) GetToken(
	credentials OAuth2Credentials,
) (*OAuth2TokenResponse, error)

Gets a new token from the IDS Token Endpoint

type IDSToken

type IDSToken struct {
	AccessToken    string
	ExpirationTime time.Time
}

IDSToken holds an authorization token and its expiration time

type OAuth2Client

type OAuth2Client interface {
	GetToken(credentials OAuth2Credentials) (*OAuth2TokenResponse, error)
}

Defines structs that can retrieve OAuth 2.0 Tokens

type OAuth2Credentials

type OAuth2Credentials struct {
	ClientID     string
	ClientSecret string
	Scope        string
}

Holds a customer's OAuth 2.0 Credentials

type OAuth2ErrorResponse added in v1.0.0

type OAuth2ErrorResponse struct {
	Error string `json:"error"`
}

OAuth2ErrorResponse represents an error response from an identity server

type OAuth2TokenResponse

type OAuth2TokenResponse struct {
	AccessToken string  `json:"access_token"`
	ExpiresIn   float64 `json:"expires_in"`
	TokenType   string  `json:"token_type"`
	Scope       string  `json:"scope"`
}

OAuth2TokenResponse represents the response from an identity server when retrieving a new token

type TokenAuthorizationProvider

type TokenAuthorizationProvider struct {
	APIToken string
}

TokenAuthorizationProvider creates authorization header values for legacy EdgeCast API calls

func NewTokenAuthorizationProvider

func NewTokenAuthorizationProvider(
	apiToken string,
) (*TokenAuthorizationProvider, error)

NewTokenAuthorizationProvider -

func (*TokenAuthorizationProvider) GetAuthorizationHeader

func (lp *TokenAuthorizationProvider) GetAuthorizationHeader() (string, error)

GetAuthorizationHeader gets the authorization header value for EdgeCast APIs that require an API Token

Jump to

Keyboard shortcuts

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