oauth

package
v0.0.0-...-c42bc8f Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

TODO: Need a way to exchange the refresh token for another access token Client encapsulates all OAuth actions

func NewClient

func NewClient(setOpts ...Option) *Client

NewClient creates a new OAuth client

func (*Client) Exchange

func (c *Client) Exchange(ctx context.Context, code string) (*oauth.IDToken, error)

Exchange exchanges a code for a wrapped ID token

func (*Client) GetOAuthLoginURL

func (c *Client) GetOAuthLoginURL() string

GetOAuthLoginURL returns the OAuth login URL

func (*Client) IDToken

func (c *Client) IDToken(tokenSource oauth2.TokenSource) (*oauth.IDToken, error)

IDToken takes in a token source, validates it, and returns an ID token TODO: For now, we're not using the production version - we're just hitting an endpoint to validate that the token is valid. To productionize this we should be hitting the JWKS URI

func (*Client) TokenSourceFromCredentials

func (c *Client) TokenSourceFromCredentials(ctx context.Context, credentials []byte) (oauth2.TokenSource, error)

TokenSourceFromCredentials takes in a credentials file and returns a token source

type Option

type Option func(o *Options)

Option is functional way of setting options for the OAuthClient

func WithClient

func WithClient(c *http.Client) Option

WithClient sets an HTTP client on the Option

func WithConfig

func WithConfig(c config.OAuth) Option

WithConfig sets the OAuth configs on the Options struct

func WithLogger

func WithLogger(l *zap.Logger) Option

WithLogger sets logger on the Options struct

type Options

type Options struct {
	Logger *zap.Logger
	Client *http.Client
	Config config.OAuth
}

Options contains all OAuthClient options

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions set defaults

Jump to

Keyboard shortcuts

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