auth

package
v0.0.0-rc5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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 NewHandler

func NewHandler(svc *auth.Service, cfg *config.Config) *Handler

func (*Handler) Login

func (h *Handler) Login(ctx *gin.Context)

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

func (h *Handler) Logout(c *gin.Context)

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

func (h *Handler) RecoveryPassword(ctx *gin.Context)

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

func (h *Handler) RefreshTokens(ctx *gin.Context)

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

func (h *Handler) Register(ctx *gin.Context)

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

func (h *Handler) RegisterConfirm(ctx *gin.Context)

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

func (h *Handler) ResetPassword(ctx *gin.Context)

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

func (h *Handler) SocialLogin(ctx *gin.Context)

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

func (h *Handler) SocialLoginCallback(ctx *gin.Context)

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

func (h *Handler) VerifyRecoveryCode(ctx *gin.Context)

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]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL