Documentation ¶
Overview ¶
Package controllers provides the controllers for the API
Index ¶
- type AuthenticationController
- func (ctr *AuthenticationController) Login(c echo.Context) error
- func (ctr *AuthenticationController) Logout(c echo.Context) error
- func (ctr *AuthenticationController) RefreshToken(c echo.Context) error
- func (ctr *AuthenticationController) Register(c echo.Context) error
- func (ctr *AuthenticationController) VerifyFactor(c echo.Context) error
- type ChannelController
- type HealthCheckController
- type HealthCheckResponse
- type LoginResponse
- type MeChannelResponse
- type MeController
- type MeResponse
- type RegisterRequest
- type UserChannelResponse
- type UserController
- type UserResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticationController ¶
type AuthenticationController struct {
// contains filtered or unexported fields
}
AuthenticationController is the controller for the authentication routes
func NewAuthenticationController ¶
func NewAuthenticationController(s models.Querier, rdb *redis.Client, t func() time.Time) *AuthenticationController
NewAuthenticationController returns a new AuthenticationController
func (*AuthenticationController) Login ¶
func (ctr *AuthenticationController) Login(c echo.Context) error
Login godoc @Summary Authenticate user to retrieve JWT token @Tags accounts @Accept json @Produce json @Param data body loginRequest true "Login request" @Success 200 {object} LoginResponse @Failure 401 "Invalid username or password" @Router /authn [post]
func (*AuthenticationController) Logout ¶
func (ctr *AuthenticationController) Logout(c echo.Context) error
Logout godoc @Summary Logout user @Tags accounts @Accept json @Produce json @Param data body logoutRequest true "Logout request" @Success 200 {string} string "Logged out" @Failure 400 {object} customError "Bad request" @Failure 401 {object} customError "Unauthorized" @Router /authn/logout [post]
func (*AuthenticationController) RefreshToken ¶
func (ctr *AuthenticationController) RefreshToken(c echo.Context) error
RefreshToken godoc @Summary Request new session tokens using a Refresh JWT token @Tags accounts @Accept json @Produce json @Param data body refreshTokenRequest true "Refresh token" @Success 200 {object} LoginResponse @Failure 400 {object} customError "Bad request" @Failure 401 {object} customError "Unauthorized" @Router /authn/refresh [post]
func (*AuthenticationController) Register ¶ added in v0.0.4
func (ctr *AuthenticationController) Register(c echo.Context) error
Register example @Summary Register a new user @Tags accounts @Accept json @Produce json @Param data body RegisterRequest true "Register request" @Success 201 "User created" @Failure 400 {object} customError "Bad request" @Failure 500 {object} customError "Internal server error" @Router /authn/register [post]
func (*AuthenticationController) VerifyFactor ¶ added in v0.0.2
func (ctr *AuthenticationController) VerifyFactor(c echo.Context) error
VerifyFactor is used to verify the user factor (OTP) @Summary Verify the user factor (OTP) @Tags accounts @Accept json @Produce json @Param data body factorRequest true "State token and OTP" @Success 200 {object} LoginResponse @Failure 400 {object} customError "Bad request" @Failure 401 {object} customError "Unauthorized" @Router /authn/factor_verify [post]
type ChannelController ¶
type ChannelController struct {
// contains filtered or unexported fields
}
func NewChannelController ¶
func NewChannelController(s models.Querier) *ChannelController
func (*ChannelController) GetChannel ¶
func (ctr *ChannelController) GetChannel()
type HealthCheckController ¶
type HealthCheckController struct {
// contains filtered or unexported fields
}
func NewHealthCheckController ¶
func NewHealthCheckController(dbPool *pgxpool.Pool, rdb *redis.Client) *HealthCheckController
func (*HealthCheckController) HealthCheck ¶
func (ctr *HealthCheckController) HealthCheck(c echo.Context) error
type HealthCheckResponse ¶
type LoginResponse ¶
type LoginResponse struct { AccessToken string `json:"access_token" extensions:"x-order=0"` RefreshToken string `json:"refresh_token,omitempty" extensions:"x-order=1"` }
LoginResponse is the response sent to a client upon successful FULL authentication
type MeChannelResponse ¶
type MeController ¶
type MeController struct {
// contains filtered or unexported fields
}
func NewMeController ¶
func NewMeController(s models.Querier) *MeController
func (*MeController) GetMe ¶
func (ctr *MeController) GetMe(c echo.Context) error
GetMe godoc @Summary Get detailed information about the current user @Tags accounts @Accept json @Produce json @Success 200 {object} MeResponse @Failure 401 "Authorization information is missing or invalid." @Router /me [get]
type MeResponse ¶
type MeResponse struct { ID int32 `json:"id" extensions:"x-order=0"` Username string `json:"username" extensions:"x-order=1"` Email string `json:"email,omitempty" extensions:"x-order=2"` MaxLogins int32 `json:"max_logins" extensions:"x-order=3"` LanguageCode string `json:"language_code,omitempty" extensions:"x-order=4"` LanguageName string `json:"language_name,omitempty" extensions:"x-order=5"` LastSeen int32 `json:"last_seen,omitempty" extensions:"x-order=6"` TotpEnabled bool `json:"totp_enabled" extensions:"x-order=8"` Channels []MeChannelResponse `json:"channels,omitempty" extensions:"x-order=9"` }
type RegisterRequest ¶ added in v0.0.4
type RegisterRequest struct { Username string `json:"username" validate:"required,min=2,max=12" extensions:"x-order=0"` Password string `json:"password" validate:"required,min=10,max=72" extensions:"x-order=1"` Email string `json:"email" validate:"required,email" extensions:"x-order=2"` EULA bool `json:"eula" validate:"required,eq=true" extensions:"x-order=3"` COPPA bool `json:"coppa" validate:"required,eq=true" extensions:"x-order=4"` }
RegisterRequest is the request body for the register route
type UserChannelResponse ¶
type UserController ¶
type UserController struct {
// contains filtered or unexported fields
}
func NewUserController ¶
func NewUserController(s models.Querier) *UserController
func (*UserController) GetUser ¶
func (ctr *UserController) GetUser(c echo.Context) error
type UserResponse ¶
type UserResponse struct { ID int32 `json:"id" extensions:"x-order=0"` Username string `json:"username" extensions:"x-order=1"` Email string `json:"email,omitempty" extensions:"x-order=2"` MaxLogins int32 `json:"max_logins" extensions:"x-order=3"` LanguageCode string `json:"language_code,omitempty" extensions:"x-order=4"` LanguageName string `json:"language_name,omitempty" extensions:"x-order=5"` LastSeen int32 `json:"last_seen,omitempty" extensions:"x-order=6"` TotpEnabled bool `json:"totp_enabled" extensions:"x-order=7"` Channels []UserChannelResponse `json:"channels,omitempty" extensions:"x-order=8"` }