Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CurrentSession ¶
CurrentUser returns the user identity from the given context. Nil is returned if no user identity is found in the context.
func Handler ¶
func Handler(verificationKey string, dbase db.IDB, logger log.ILogger, sessRepo session.IRepository) routing.Handler
Handler returns a JWT-based authentication middleware. func Handler(verificationKey string, dbase db.IDB, logger log.ILogger) routing.Handler {
func RegisterHandlers ¶
RegisterHandlers registers handlers for different HTTP requests.
POST /api/register - регистрация POST /api/login - логин
Types ¶
type Identity ¶
type Identity interface { // GetID returns the user ID. GetID() string // GetName returns the user name. GetName() string }
Identity represents an authenticated user identity.
type Service ¶
type Service interface { // authenticate authenticates a user using username and password. // It returns a JWT token if authentication succeeds. Otherwise, an error is returned. Login(ctx context.Context, username, password string) (string, error) Register(ctx context.Context, username, password string) (string, error) NewUser(username, password string) (*user.User, error) }
Service encapsulates the authentication logic.
type UserService ¶
type UserService interface { }
Click to show internal directories.
Click to hide internal directories.