auth

package
v0.0.0-...-1967991 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2023 License: AGPL-3.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 LoginController

type LoginController struct {
	// Dependencies
	AuthService LoginService
}

func (LoginController) ListRoutes

func (controller LoginController) ListRoutes() []route.Route

type LoginService

type LoginService interface {
	AuthenticateOrSignup(credentials userLoginCredentials) (authToken string, isNew bool, err error)
	IsAuthenticated(authToken string) (userId string, err error)
}

type Middleware

type Middleware struct {
	LoginService LoginService
}

func (Middleware) Intercept

func (middleware Middleware) Intercept(handler route.SecureHandler) route.Handler

type UserIdLoginService

type UserIdLoginService struct {
	// Dependencies
	UserDao user.Dao
}

func (UserIdLoginService) AuthenticateOrSignup

func (service UserIdLoginService) AuthenticateOrSignup(credentials userLoginCredentials) (string, bool, error)

AuthenticateOrSignup tries to authenticate the user specified with the credentials, and returns the user token or an error. In case a user with these credentials cannot be found, it creates a new user with that username.

func (UserIdLoginService) IsAuthenticated

func (service UserIdLoginService) IsAuthenticated(authToken string) (string, error)

IsAuthenticated checks if the given authToken can be assigned to a User. In case no user is found, it returns errUnknownUser

Jump to

Keyboard shortcuts

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