Documentation
¶
Index ¶
- Variables
- func ContextWithProvider(ctx *fiber.Ctx, provider string) *fiber.Ctx
- func DefaultSession() any
- func GetAuthURLFromContext(c *fiber.Ctx, session SessionStore) (string, error)
- func GetStateFromContext(ctx *fiber.Ctx) string
- func NewBeginAuthHandler(config ...Config) fiber.Handler
- func NewCompleteAuthHandler(config ...Config) fiber.Handler
- func NewLogoutHandler(config ...Config) fiber.Handler
- func NewSessionStore(store *session.Store) *sessionStore
- func ProviderFromContext(c *fiber.Ctx) string
- type BeginAuthHandler
- type CompleteAuthCompleteHandler
- type Config
- type GothHandler
- type LogoutHandler
- type Params
- type SessionStore
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingProviderName is thrown if the provider cannot be determined. ErrMissingProviderName = errors.New("missing provider name in request") // ErrMissingSession is thrown if there is no active session. ErrMissingSession = errors.New("could not find a matching session for this request") )
var ConfigDefault = Config{ ErrorHandler: defaultErrorHandler, ResponseFilter: defaultResponseFilter, BeginAuthHandler: BeginAuthHandler{}, CompleteAuthHandler: CompleteAuthCompleteHandler{}, LogoutHandler: LogoutHandler{}, Session: NewSessionStore(session.New(defaultSessionConfig)), }
ConfigDefault is the default config.
Functions ¶
func ContextWithProvider ¶
ContextWithProvider returns a new request context containing the provider.
func GetAuthURLFromContext ¶
func GetAuthURLFromContext(c *fiber.Ctx, session SessionStore) (string, error)
GetAuthURLFromContext returns the provider specific authentication URL.
func GetStateFromContext ¶
GetStateFromContext return the state that is returned during the callback.
func NewBeginAuthHandler ¶
NewBeginAuthHandler creates a new middleware handler to start authentication.
func NewCompleteAuthHandler ¶
NewBeginCompleteAuthHandler creates a new middleware handler to complete authentication.
func NewLogoutHandler ¶
NewLogoutHandler returns a new default logout handler.
func NewSessionStore ¶
NewSessionStore returns a new default store based on the session middleware.
func ProviderFromContext ¶
ProviderFromContext returns the provider from the request context.
Types ¶
type BeginAuthHandler ¶
type BeginAuthHandler struct{}
BeginAuthHandler is the default handler to begin the authentication process.
type CompleteAuthCompleteHandler ¶
type CompleteAuthCompleteHandler struct{}
CompleteAuthComplete is the default handler to complete the authentication process.
type Config ¶
type Config struct {
// Next defines a function to skip this middleware when returned true.
Next func(c *fiber.Ctx) bool
// BeginAuthHandler is the handler to start authentication.
BeginAuthHandler GothHandler
// CompleteAuthHandler is the handler to complete the authentication.
CompleteAuthHandler GothHandler
// LogoutHandler is the handler to logout.
LogoutHandler GothHandler
// Session stores an authentication session.
Session SessionStore
// Response filter that is executed when responses need to returned.
ResponseFilter func(c *fiber.Ctx) error
// ErrorHandler is executed when an error is returned from fiber.Handler.
//
// Optional. Default: DefaultErrorHandler
ErrorHandler fiber.ErrorHandler
}
Config caputes the configuration for running the goth middleware.
type GothHandler ¶
GothHandler is the interface for defining handlers for the middleware.
type LogoutHandler ¶
type LogoutHandler struct{}
LogoutHandler is the default handler for the logout process.
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
Params maps the parameters of the Fiber context to the gothic context.
type SessionStore ¶
type SessionStore interface {
// Get ...
Get(c *fiber.Ctx, key string) (string, error)
// Update ...
Update(c *fiber.Ctx, key, value string) error
// Destroy ...
Destroy(c *fiber.Ctx) error
// Interface ...
Interface() any
}
SessionStore is the interface to store session information for authentication.