auth

package
v0.0.0-...-ccca5b4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const QueryTokenKey = "token"

Variables

This section is empty.

Functions

func Callback

func Callback(h *Handler) gin.HandlerFunc

func Login

func Login(h *Handler) gin.HandlerFunc

func Register

func Register(r *gin.Engine, h *Handler)

Types

type Client

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

func NewClient

func NewClient(baseURL string) *Client

func (*Client) Close

func (c *Client) Close() error

Close will clean all listeners and channels required by the Client.

func (*Client) GetAuthCodeURL

func (c *Client) GetAuthCodeURL() (string, error)

GetAuthCodeURL will connect to the server and retrieve the URL, which the client will be redirected to as part of the OIDC flow. Make sure to start the callback server via StartCallbackServer first or this function will return an error.

func (*Client) GetToken

func (c *Client) GetToken() string

GetToken return the current value of the token. If the token has not been retrieved, the value will be an empty string.

func (*Client) StartCallbackServer

func (c *Client) StartCallbackServer() error

func (*Client) StopCallbackServer

func (c *Client) StopCallbackServer() error

StopCallbackServer will shutdown the server, which receives the token by being the final redirect as part of the OIDC flow.

func (*Client) WaitUntilTokenReceived

func (c *Client) WaitUntilTokenReceived(ctx context.Context) error

WaitUntilTokenReceived will block until either the token was received or the context is done. The token can only be received if the callback server is running and the user is finishing the OIDC flow with his browser.

type ExtraClaims

type ExtraClaims struct {
	Email         string `json:"email"`
	EmailVerified bool   `json:"email_verified"`
}

type Handler

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

func NewHandler

func NewHandler(config *HandlerConfig) (*Handler, error)

func (*Handler) Exchange

func (h *Handler) Exchange(ctx context.Context, code string) (*oauth2.Token, error)

func (*Handler) GetAuthCodeURL

func (h *Handler) GetAuthCodeURL(state *State) (string, error)

func (*Handler) Refresh

func (h *Handler) Refresh(ctx context.Context, refreshToken string) (*oauth2.Token, error)

func (*Handler) Verify

func (h *Handler) Verify(ctx context.Context, token *oauth2.Token) (*oidc.IDToken, error)

func (*Handler) VerifyStateAndClaims

func (h *Handler) VerifyStateAndClaims(ctx context.Context, token *oauth2.Token, encoded string) (*State, *ExtraClaims, error)

type HandlerConfig

type HandlerConfig struct {
	IssuerURL          string
	OfflineAsScope     bool
	ClientID           string
	ClientSecret       string
	RedirectURL        string
	Nonce              string
	AuthCodeURLMutator func(string) string
}

type State

type State struct {
	Callback string `form:"callback" json:"callback,omitempty"`
}

Jump to

Keyboard shortcuts

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