client

package
v0.0.0-...-2bc129d Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	UserpoolID               string
	ClientID                 string
	Username                 string
	Password                 string
	AWSConfig                *aws.Config
	RequireTransportSecurity bool
}

Config holds configuration info for the cognito http client

func (*Config) Client

func (c *Config) Client() (*http.Client, error)

Client returns a new http.Client which will handle authentication with Cognito

type Token

type Token struct {
	AccessToken  string
	IDToken      string
	RefreshToken string
	TokenType    string
	Expiration   time.Time
}

Token holds the credentials received from Cognito

type TokenSource

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

TokenSource handles the retrieval and refreshing of tokens

func NewTokenSource

func NewTokenSource(conf *Config) (*TokenSource, error)

NewTokenSource returns a new TokenSource with the provided configuration

func (*TokenSource) GetRequestMetadata

func (ts *TokenSource) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata is used to implement PerRPCCredentials interface.

func (*TokenSource) GetToken

func (ts *TokenSource) GetToken() (*Token, error)

GetToken returns the existing Token if valid or refreshes and returns the new Token.

func (*TokenSource) RequireTransportSecurity

func (ts *TokenSource) RequireTransportSecurity() bool

RequireTransportSecurity is used to implement PerRPCCredentials interface. TODO: Make this default to true.

type Transport

type Transport struct {
	// Source supplies the token to add to outgoing requests'
	// Authorization headers.
	Source *TokenSource

	// Base is the base RoundTripper used to make HTTP requests.
	// If nil, http.DefaultTransport is used.
	Base http.RoundTripper
	// contains filtered or unexported fields
}

Transport is an http.RoundTripper that makes OAuth 2.0 HTTP requests, wrapping a base RoundTripper and adding an Authorization header with a token from the supplied Sources.

Transport is a low-level mechanism. Most code will use the higher-level Config.Client method instead.

func (*Transport) CancelRequest

func (t *Transport) CancelRequest(req *http.Request)

CancelRequest cancels an in-flight request by closing its connection.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip authorizes and authenticates the request with an access token from Transport's Source.

Jump to

Keyboard shortcuts

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