Documentation
¶
Index ¶
- Variables
- type Handler
- func (h *Handler) Login(ctx *gin.Context)
- func (h *Handler) Logout(c *gin.Context)
- func (h *Handler) RecoveryPassword(ctx *gin.Context)
- func (h *Handler) RefreshTokens(ctx *gin.Context)
- func (h *Handler) Register(ctx *gin.Context)
- func (h *Handler) RegisterConfirm(ctx *gin.Context)
- func (h *Handler) RegisterRoutes(router *gin.Engine, middlewares handler.RouteMiddlewares)
- func (h *Handler) ResetPassword(ctx *gin.Context)
- func (h *Handler) SocialLogin(ctx *gin.Context)
- func (h *Handler) SocialLoginCallback(ctx *gin.Context)
- func (h *Handler) VerifyRecoveryCode(ctx *gin.Context)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSessionExpired = dto2.NewI18nError("session expired", "errors.session_expired") ErrRedirectUrlNotFound = dto2.NewI18nError("not found redirect url", "errors.redirect_url_not_found") ErrInvalidState = dto2.NewI18nError("invalid state", "errors.invalid_state") )
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) Login ¶
Login godoc
@Id Login
@Summary Sign in
@Description Request for authentication. In response will be new access token in body and new refresh tokens in http-only cookie.
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Param body body dto.LoginInput true "Login request body"
@Success 200 {object} dto.JwtTokensOutput
@Header 200 {string} Set-Cookie "RefreshToken=; HttpOnly; Max-Age=86400; Secure"
@Failure 400 {object} dto.ErrorResponse
@Failure 403 {object} dto.ErrorResponse
@Failure 404 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/login [post]
func (*Handler) Logout ¶
Logout godoc
@Id Logout
@Summary Logout
@Description Request for logout. User must be logged in.
@Security BearerAuth
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Success 200
@Failure 401 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/logout [get]
func (*Handler) RecoveryPassword ¶
RecoveryPassword godoc
@Id RecoveryPassword
@Summary Recovery password
@Description Request for recovery password. At the end will be sent email with code
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Param body body dto.RecoveryPasswordInput true "Recovery password body"
@Success 202
@Failure 400 {object} dto.ErrorResponse
@Failure 404 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/recovery-password [post]
func (*Handler) RefreshTokens ¶
RefreshTokens godoc
@Id RefreshTokens
@Summary Refresh tokens
@Description Request for refreshing tokens. In response will be new access token in body and new refresh tokens in http-only cookie.
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Success 200 {object} dto.JwtTokensOutput
@Header 200 {string} Set-Cookie "RefreshToken=; HttpOnly; Max-Age=86400; Secure"
@Failure 400 {object} dto.ErrorResponse
@Failure 403 {object} dto.ErrorResponse
@Failure 404 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/refresh [get]
func (*Handler) Register ¶
Register godoc
@Id Register
@Summary Register
@Description Request for creating new user. At the end will be sent confirmation email with code
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Param body body dto.RegisterInput true "Register request body"
@Success 202
@Failure 400 {object} dto.ErrorResponse
@Failure 409 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/register [post]
func (*Handler) RegisterConfirm ¶
RegisterConfirm godoc
@Id RegisterConfirm
@Summary Register confirmation
@Description Request for confirming registration. At the end will be created new user
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Param body body dto.RegisterConfirmInput true "Register confirm body"
@Success 200
@Failure 400 {object} dto.ErrorResponse
@Failure 409 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/register/confirm [post]
func (*Handler) RegisterRoutes ¶
func (h *Handler) RegisterRoutes(router *gin.Engine, middlewares handler.RouteMiddlewares)
func (*Handler) ResetPassword ¶
ResetPassword godoc
@Id ResetPassword
@Summary Reset password
@Description Request for reset password. If code is correct will be updated password
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Param body body dto.ResetPasswordInput true "Reset password body"
@Success 200
@Failure 400 {object} dto.ErrorResponse
@Failure 404 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/reset-password [post]
func (*Handler) SocialLogin ¶
SocialLogin godoc
@Id SocialLogin
@Summary Social login
@Description Request for redirecting to OAuth consent page. After authorization, it will redirect to redirectUrl with authorization code and state
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Param provider path string true "Social login provider (yandex, google, mailru)"
@Param redirectUrl query string true "Redirect URL"
@Success 302
@Header 302 {string} Set-Cookie "OAuthGoogleState=; HttpOnly; Max-Age=1200; Secure"
@Failure 404 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/social/{provider} [get]
func (*Handler) SocialLoginCallback ¶
SocialLoginCallback godoc
@Id SocialLoginCallback
@Summary Social login callback
@Description Request for exchanging authorization code to token pairs. In process, it will exchange code to user info and register new user or login existing user. In response will be new access token in body and new refresh tokens in http-only cookie.
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Param provider path string true "Social login provider (yandex, google, mailru)"
@Param body body dto.SocialLoginCallbackInput true "Social login callback request body"
@Success 200 {object} dto.JwtTokensOutput
@Header 200 {string} Set-Cookie "RefreshToken=; HttpOnly; Max-Age=86400; Secure"
@Failure 400 {object} dto.ErrorResponse
@Failure 403 {object} dto.ErrorResponse
@Failure 404 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/social/{provider}/callback [post]
func (*Handler) VerifyRecoveryCode ¶
VerifyRecoveryCode godoc
@Id VerifyRecoveryCode
@Summary Verify recovery code
@Description Request for verify recovery code. If code is correct will be sent status 200
@Tags Authentication and Authorization API
@Accept json
@Produce json
@Param body body dto.VerifyRecoveryCodeInput true "Verify recovery code body"
@Success 200
@Failure 400 {object} dto.ErrorResponse
@Failure 500 {object} dto.ErrorResponse
@Router /v0/auth/recovery-password/verify [post]
Click to show internal directories.
Click to hide internal directories.