Documentation ¶
Index ¶
- Constants
- Variables
- func MiddlewareBearerToken(db DB) echo.MiddlewareFunc
- func MiddlewareMustBeAuthenticated(db DB) echo.MiddlewareFunc
- func MiddlewareOIDC() echo.MiddlewareFunc
- func MiddlewareSessionManager(session Session, key string) echo.MiddlewareFunc
- func New(g *echo.Echo, opts ...Option) error
- type DB
- type Log
- type Option
- func SetBackend(raw string) Option
- func SetDatabase(db DB) Option
- func SetFrontend(raw string) Option
- func SetLogger(logger Log) Option
- func SetNames(sesson, provider, refetch, addition string) Option
- func SetPaths(login, logout, profile, err string) Option
- func SetSessions(s Session) Option
- func SetStore(store sessions.Store) Option
- func WithProvider(p provider.Provider, key, secret, callbackDomain, source string) Option
- type Options
- type Session
Constants ¶
View Source
const (
DefaultProvider = "provider"
)
Variables ¶
View Source
var ( ErrEmptyArgument = errors.New("argument can not be empty") ErrInvalidProvider = errors.New("provider is invalid") ErrLoggerIsInvalid = errors.New("provided logger is nil") ErrMissingDB = errors.New("missing database") ErrMissingDomain = errors.New("missing domain") ErrMissingProvider = errors.New("missing provider") ErrNotSetup = errors.New("this function has not been completed") ErrSessionsStoreIsNil = errors.New("provided sessions.Store is nil") ErrSessionsIsNil = errors.New("provided Sessions is nil") )
Functions ¶
func MiddlewareBearerToken ¶
func MiddlewareBearerToken(db DB) echo.MiddlewareFunc
func MiddlewareMustBeAuthenticated ¶
func MiddlewareMustBeAuthenticated(db DB) echo.MiddlewareFunc
func MiddlewareOIDC ¶
func MiddlewareOIDC() echo.MiddlewareFunc
Types ¶
type DB ¶
type DB interface { GetUserWithSession(ctx context.Context, userID string, token string) (user any, err error) // Get the user with the userID and the active token. GetUserID(ctx context.Context, gothID string) (userID string, err error) // GetUserID takes a id from goth and searches for a user in the database. It returns the id of the user GetUserIDFromToken(ctx context.Context, apiToken string) (string, error) // Get the user id from the api key UpdateUserInfo(ctx context.Context, id string, email string, name string) error // Update a user with the given id from the database with the given email and name. CreateOrUpdateUser(ctx context.Context, gothID, provider, email, name string) (userID string, err error) // Create or update a user for the given gothID UserDisabled(ctx context.Context, userID string) (disabled bool, err error) // Check if a user is disabled. AddSessionToUser(ctx context.Context, gothID string, session string) error // Adds the session to the user with the connected goth id. Returns an error if a user is not connected to the goth id. }
gothID is for the id of the user from the provider. userID is for the id of the user from the database.
type Log ¶
type Log interface {
LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)
}
Log interface that this package uses. By default it is `log/slog`
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func SetBackend ¶
SetBackend sets the url for the backend to use.
func SetFrontend ¶
SetFrontend sets the url for the frontend to use.
func SetSessions ¶
type Session ¶
type Session interface { GetString(ctx context.Context, key string) string Token(context.Context) string Destroy(context.Context) error Put(ctx context.Context, key string, val any) PopBool(ctx context.Context, key string) bool RenewToken(context.Context) error Commit(context.Context) (token string, expires time.Time, err error) }
Click to show internal directories.
Click to hide internal directories.