Back to

Package oauthclient

Latest Go to latest

The latest major version is v3.

Published: Apr 29, 2020 | License: Apache-2.0 | Module:


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:"-"`

Config is the configuration for the OAuth client.

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) (*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.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier