Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JWTAuthMiddleware ¶
func JWTAuthMiddleware(verificationKey string) echo.MiddlewareFunc
JWTAuthMiddleware returns a JWT-based authentication middleware.
func RegisterHandlers ¶
RegisterHandlers registers handlers for different HTTP requests.
Types ¶
type AccountGetter ¶
type LoginRequest ¶
type LoginRequest struct { // Username the username to authenticate with. Length has to be between 5 and // 128 characters. Username string `json:"username"` // Password password to authenticate with. Length has to be between 5 and // 128 characters. Password string `json:"password"` }
LoginRequest authentication login input request.
func (*LoginRequest) Validate ¶
func (r *LoginRequest) Validate() *response.Error
Validate validates the LoginRequest struct.
type LoginResponse ¶
type LoginResponse struct { // AccessToken the token to be used on authenticated requests. AccessToken string `json:"token"` // RefreshToken the token to be used to refresh the access token. RefreshToken string `json:"refresh_token,omitempty"` }
LoginResponse authentication login output response.
type RefreshRequest ¶
type RefreshRequest struct { // RefreshToken the token to be used to refresh the access token. RefreshToken string `json:"refresh_token"` }
RefreshRequest refresh your JWT token.
func (*RefreshRequest) Validate ¶
func (r *RefreshRequest) Validate() *response.Error
Validate validates the LoginRequest struct
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) (LoginResponse, error) Refresh(c context.Context, token string) (LoginResponse, error) }
Service encapsulates the authentication logic.
func NewService ¶
func NewService(cfg *config.Config, ar AccountGetter, appRepo app.Repository, logger log.Logger) Service
NewService creates a new authentication service.
Click to show internal directories.
Click to hide internal directories.