Documentation
¶
Index ¶
- Variables
- func NewHTTP(svc Service, e *echo.Echo)
- type Auth
- func (s *Auth) Authenticate(ctx context.Context, data Credentials) (*model.AuthToken, error)
- func (s *Auth) LoginUser(ctx context.Context, u *model.User) (*model.AuthToken, error)
- func (s *Auth) RefreshToken(ctx context.Context, data RefreshTokenData) (*model.AuthToken, error)
- func (s *Auth) User(c echo.Context) *model.AuthUser
- type Credentials
- type Crypter
- type HTTP
- type JWT
- type RefreshTokenData
- type Service
- type UserDB
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidCredentials = server.NewHTTPError(http.StatusUnauthorized, "INVALID_CREDENTIALS", "Username or password is incorrect") ErrUserBlocked = server.NewHTTPError(http.StatusUnauthorized, "USER_BLOCKED", "Your account has been blocked and may not login") ErrInvalidRefreshToken = server.NewHTTPError(http.StatusUnauthorized, "INVALID_REFRESH_TOKEN", "Invalid refresh token") )
Custom errors
Functions ¶
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth represents auth application service
func (*Auth) Authenticate ¶
Authenticate tries to authenticate the user provided by given credentials
func (*Auth) RefreshToken ¶
RefreshToken returns the new access token with expired time extended
type Credentials ¶
type Credentials struct { Username string `json:"username" validate:"required" example:"superadmin"` Password string `json:"password" validate:"required" example:"superadmin123!@#"` }
Credentials represents login request data
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP represents auth http service
type RefreshTokenData ¶
type RefreshTokenData struct {
RefreshToken string `json:"refresh_token" validate:"required"`
}
RefreshTokenData represents refresh token request data
Click to show internal directories.
Click to hide internal directories.