auth

package
v0.0.0-...-8dd3885 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	S256 = "S256"
)

Variables

View Source
var (
	UserCtxKey   = &contextKey{"token"}
	ErrorCtxKey  = &contextKey{"error"}
	TokenGetters = []TokenGetter{TokenFromHeader, TokenFromCookie, TokenFromQuery}
)

Functions

func Authenticator

func Authenticator(db *gorm.DB, provider *TokenProvider, clientId string) func(http.Handler) http.Handler

func NewClient

func NewClient(insecure bool) *http.Client

func NewContext

func NewContext(ctx context.Context, user *apis.User) context.Context

func TokenFromCookie

func TokenFromCookie(r *http.Request) string

func TokenFromHeader

func TokenFromHeader(r *http.Request) string

func TokenFromQuery

func TokenFromQuery(r *http.Request) string

func UserFromContext

func UserFromContext(ctx context.Context) (*apis.User, error)

Types

type CompletedConfig

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

type Config

type Config struct {
	*Options
	Client *http.Client
}

func NewConfig

func NewConfig(o *Options) *Config

func (*Config) Complete

func (c *Config) Complete() CompletedConfig

type Options

type Options struct {
	ClientId               string `mapstructure:"client-id"`
	TokenFile              string `mapstructure:"token-file"`
	LocalAddr              string `mapstructure:"local-addr"`
	AuthorizationServerURL string `mapstructure:"server-url"`
	InsecureClient         bool   `mapstructure:"insecure-client"`

	RedirectURL string
}

func NewOptions

func NewOptions() *Options

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet, prefix string)

func (*Options) Complete

func (o *Options) Complete() error

func (*Options) Validate

func (o *Options) Validate() []error

type Params

type Params struct {
	Challenge string
	Method    string
	Verifier  string
}
var Empty Params

func NewPKCEParams

func NewPKCEParams(methods []string) (Params, error)

func S256From

func S256From(b []byte) Params

func (Params) IsEmpty

func (p Params) IsEmpty() bool

type TokenGetter

type TokenGetter func(*http.Request) string

type TokenProvider

type TokenProvider struct {
	CompletedConfig

	Server *http.Server

	ClientContext context.Context
	Provider      *oidc.Provider
	Verifier      *oidc.IDTokenVerifier
	OAuth2Config  *oauth2.Config
	CachedToken   *tokenWrapper
}

TokenProvider holds the data necessary to complete an OAuth2 auth code flow

func NewTokenProvider

func NewTokenProvider(c CompletedConfig) (*TokenProvider, error)

NewTokenProvider creates a new OIDCFlow that can be used to

func (*TokenProvider) GetIdToken

func (l *TokenProvider) GetIdToken() (string, error)

func (*TokenProvider) Verify

func (l *TokenProvider) Verify(token string) (*oidc.IDToken, error)

Jump to

Keyboard shortcuts

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