oauthclient

package
v3.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback added in v3.9.1

type Callback func(echo.Context, *oauth2.Token, string) error

Callback occurs after the OAuth2 token exchange has been performed successfully.

type Config

type Config struct {
	AuthorizeURL string `name:"authorize-url" description:"The OAuth Authorize URL"`
	LogoutURL    string `name:"logout-url" description:"The OAuth Logout URL"`
	TokenURL     string `name:"token-url" description:"The OAuth Token Exchange URL"`
	RootURL      string `name:"-"`

	ClientID     string `name:"client-id" description:"The OAuth client ID"`
	ClientSecret string `name:"client-secret" description:"The OAuth client secret" json:"-"`

	StateCookieName string `name:"-"`
	AuthCookieName  string `name:"-"`
	// contains filtered or unexported fields
}

Config is the configuration for the OAuth client.

type OAuth2ConfigProvider added in v3.9.1

type OAuth2ConfigProvider func(echo.Context) *oauth2.Config

OAuth2ConfigProvider provides an OAuth2 client config based on the context.

type OAuthClient

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

OAuthClient is the OAuth client component.

func New

func New(c *component.Component, config Config, opts ...Option) (*OAuthClient, error)

New returns a new OAuth client instance.

func (*OAuthClient) AuthCookie

func (oc *OAuthClient) AuthCookie() *cookie.Cookie

AuthCookie returns a new authCookie.

func (*OAuthClient) HandleCallback

func (oc *OAuthClient) HandleCallback(c echo.Context) error

HandleCallback is a handler that takes the auth code and exchanges it for the access token.

func (*OAuthClient) HandleLogin

func (oc *OAuthClient) HandleLogin(c echo.Context) error

HandleLogin is the handler for redirecting the user to the authorization endpoint.

func (*OAuthClient) HandleLogout

func (oc *OAuthClient) HandleLogout(c echo.Context) error

HandleLogout invalidates the user's authorization, removes the auth cookie and provides a URL to logout of the OAuth provider as well.

func (*OAuthClient) HandleToken

func (oc *OAuthClient) HandleToken(c echo.Context) error

HandleToken is a handler that returns a valid OAuth token. It reads the token from the authorization cookie and refreshes it if needed. If the cookie is not there, it returns a 401 Unauthorized error.

func (*OAuthClient) StateCookie

func (oc *OAuthClient) StateCookie() *cookie.Cookie

StateCookie returns the cookie storing the state of the console.

type Option added in v3.9.1

type Option func(*OAuthClient)

Option is an OAuth2Client configuration option.

func WithCallback added in v3.9.1

func WithCallback(cb Callback) Option

WithCallback adds a callback to be executed at the end of the OAuth2 token exchange.

func WithNextKey added in v3.9.1

func WithNextKey(key string) Option

WithNextKey overrides the default query parameter used for callback return.

func WithOAuth2ConfigProvider added in v3.9.1

func WithOAuth2ConfigProvider(provider OAuth2ConfigProvider) Option

WithOAuth2ConfigProvider overrides the default OAuth2 configuration provider.

Jump to

Keyboard shortcuts

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