auth

package
v0.0.0-...-aca7f8d Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MPL-2.0 Imports: 8 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 {
	ProviderURL  string
	ClientID     string
	ClientSecret string
	RedirectURL  string

	Scopes  []string
	Enabled bool
}

Config defines the configuration used for the authentication middleware and the token verifier

type ContextKey

type ContextKey string

ContextKey is used to store the auth context value in the request context

type Provider

type Provider struct {
	Verifier *oidc.IDTokenVerifier
	Disabled bool
	// contains filtered or unexported fields
}

Provider stores the runtime configuration and verifier for the authorizer and the middleware

func NewProvider

func NewProvider(ctx context.Context, conf *Config) (*Provider, error)

NewProvider creates a new OIDC provider instance

func (*Provider) AuthorizeHandler

func (p *Provider) AuthorizeHandler(w http.ResponseWriter, r *http.Request)

AuthorizeHandler validates the authentication code from the client and returns a access token as a response

func (*Provider) EchoAuthorizeHandler

func (p *Provider) EchoAuthorizeHandler() echo.HandlerFunc

EchoAuthorizeHandler returns a wrapped http handler for the echo router

func (*Provider) EchoMiddleware

func (p *Provider) EchoMiddleware() echo.MiddlewareFunc

EchoMiddleware returns an instance of the Middleware wrapped for Echo

func (*Provider) Middleware

func (p *Provider) Middleware(h http.Handler) http.Handler

Middleware reads and verifies the bearer tokens and injects the extracted data to the request context

type Session

type Session struct {
	UserID string `json:"sub"`
	Email  string `json:"email"`
}

Session is used to store authentication data as a context value

func GetSession

func GetSession(ctx context.Context) *Session

GetSession is a helper function to return the session struct stored in the request context

Jump to

Keyboard shortcuts

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