Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidCredentials = server.NewHTTPError(http.StatusUnauthorized, "INVALID_CREDENTIALS", "Email 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") ErrTokenExpired = server.NewHTTPError(http.StatusUnauthorized, "TOKEN_EXPIRED", "Invalid refresh token") ErrInvalidPayloadType = server.NewHTTPError(http.StatusUnauthorized, "INVALID_PAYLOAD_TYPE", "Invalid payload type") ErrRefreshToken = server.NewHTTPError(http.StatusInternalServerError, "REFRESH_TOKEN_ERROR", "An error occur while refreshing token") ErrInvalidGrantType = server.NewHTTPError(http.StatusBadRequest, "INVALID_GRANT_TYPE", "Invalid grant type") )
Custom errors
Functions ¶
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth represents auth application service
func (*Auth) Login ¶
func (s *Auth) Login(c echo.Context, data Credentials) (*types.AuthToken, error)
Login tries to authenticate the user provided by given credentials
func (*Auth) RefreshToken ¶
func (s *Auth) RefreshToken(c echo.Context, data RefreshTokenData) (*types.AuthToken, error)
RefreshToken refreshes the access token
type AuthenticateInput ¶
AuthenticateInput represents internal authenticate data
type Credentials ¶
type Credentials struct { // example: loki@gram.sky Email string `json:"email" form:"email" validate:"required_without=Username"` // example: user123!@# Password string `json:"password" form:"password" validate:"required"` // This is for SwaggerUI authentication which only support `username` field // swagger:ignore Username string `json:"username" form:"username"` // example: app GrantType string `json:"grant_type" form:"grant_type" validate:"required"` }
Credentials represents login request data swagger:model
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP represents auth http service
type JWT ¶
type JWT interface { GenerateToken(*jwt.TokenInput, *jwt.TokenOutput) error ParseToken(string) (*gjwt.Token, error) }
JWT represents token generator (jwt) interface
type RefreshTokenData ¶
type RefreshTokenData struct {
RefreshToken string `json:"refresh_token" validate:"required"`
}
RefreshTokenData represents refresh token request data swagger:model
type Service ¶
type Service interface { Login(echo.Context, Credentials) (*types.AuthToken, error) RefreshToken(echo.Context, RefreshTokenData) (*types.AuthToken, error) }
Service represents auth service interface
Click to show internal directories.
Click to hide internal directories.