auth

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 12 Imported by: 0

README

auth

Golang library handling oauth2 stuff

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoOAuth2State         = errors.New("no oauth2 state provided")
	ErrNoOAuth2Code          = errors.New("no oauth2 code provided")
	ErrCouldNotRetrieveToken = errors.New("could not retrieve token")
	ErrSessionNotFound       = errors.New("session not found")
	ErrNoJWTReturned         = errors.New("no jwt returned")
)

Errors

Functions

This section is empty.

Types

type Config

type Config struct {
	ProviderUrl      string `kong:"prefix='oauth2-',help='Url of oauth2 provider',alias='oidc',env='OAUTH2_PROVIDER_URL'"`
	ClientID         string `kong:"prefix='oauth2-',help='Oauth2 client id to use',env='OAUTH2_CLIENTID',alias='cid'"`
	ClientSecret     string `kong:"prefix='oauth2-',help='Oauth2 client secret to use',env='OAUTH2_CLIENT_SECRET',alias='cis'"`
	LoginCallbackUrl string `kong:"prefix='oauth2-',help='Redirect url after successful login',env='OAUTH2_LOGIN_CALLBACK_URL'"`
}

Config values for authentication

type Handler

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

func New

func New(options *Options) (*Handler, error)

func (*Handler) RegisterEndpoint

func (h *Handler) RegisterEndpoint(r gin.IRouter)

type LoginResponse

type LoginResponse struct {
	Session string `json:"session"`
	Url     string `json:"url"`
}

LoginResponse represents the answer to a login request

type Options

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

func DefaultOptions

func DefaultOptions() *Options

func (*Options) WithConfig

func (o *Options) WithConfig(value *Config) *Options

WithConfig sets up stuff from the config

func (*Options) WithLogger

func (o *Options) WithLogger(value *zap.Logger) *Options

WithLogger sets the logger for the server

func (*Options) WithSessionHandler

func (o *Options) WithSessionHandler(value *session.Handler) *Options

WithSessionHandler sets the session handler for the server

Jump to

Keyboard shortcuts

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