auth

package
v0.0.0-rc6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(svc service.AuthService, cfg *config.Config) *Handler

func (*Handler) Login

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

Login godoc

@Id				Login
@Summary		Sign in
@Description	Request for serviceentication. 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"
@Header			200		{string}	Set-Cookie	"RefreshToken=; HttpOnly; Max-Age=86400; Secure"
@Success		200		{object}	dto.JwtTokensOutput	"JWT access token"
@Failure		400		{object}	dto.ErrorResponse	"Validation error"
@Failure		403		{object}	dto.ErrorResponse	"User is blocked"
@Failure		404		{object}	dto.ErrorResponse	"User not found"
@Failure		500		{object}	dto.ErrorResponse	"Internal server error"
@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	"Unauthorized"
@Failure		500	{object}	dto.ErrorResponse	"Internal server error"
@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	"Validation error"
@Failure		404	{object}	dto.ErrorResponse	"User not found"
@Failure		500	{object}	dto.ErrorResponse	"Internal server error"
@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
@Header			200	{string}	Set-Cookie	"RefreshToken=; HttpOnly; Max-Age=86400; Secure"
@Success		200	{object}	dto.JwtTokensOutput	"JWT access token"
@Failure		400	{object}	dto.ErrorResponse	"Validation error"
@Failure		403	{object}	dto.ErrorResponse	"User is blocked"
@Failure		404	{object}	dto.ErrorResponse	"User not found"
@Failure		500	{object}	dto.ErrorResponse	"Internal server error"
@Router			/v0/auth/refresh [get]

func (*Handler) Register

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

Register godoc

@Id				RegisterClient
@Summary		RegisterClient
@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	"RegisterClient request body"
@Success		202
@Failure		400	{object}	dto.ErrorResponse	"Validation error"
@Failure		409	{object}	dto.ErrorResponse	"User already exists"
@Failure		500	{object}	dto.ErrorResponse	"Internal server error"
@Router			/v0/auth/register [post]

func (*Handler) RegisterConfirm

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

RegisterConfirm godoc

@Id				RegisterConfirm
@Summary		RegisterClient 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	"RegisterClient confirm body"
@Success		200
@Failure		400	{object}	dto.ErrorResponse	"Validation error"
@Failure		409	{object}	dto.ErrorResponse	"User already exists"
@Failure		500	{object}	dto.ErrorResponse	"Internal server error"
@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	"Validation error"
@Failure		404	{object}	dto.ErrorResponse	"User not found"
@Failure		500	{object}	dto.ErrorResponse	"Internal server error"
@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 serviceorization, it will redirect to redirectUrl with serviceorization 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"
@Header			302	{string}	Set-Cookie	"OAuthGoogleState=; HttpOnly; Max-Age=1200; Secure"
@Success		302
@Failure		404	{object}	dto.ErrorResponse	"Provider not found"
@Failure		500	{object}	dto.ErrorResponse	"Internal server error"
@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 serviceorization 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"
@Header			200			{string}	Set-Cookie	"RefreshToken=; HttpOnly; Max-Age=86400; Secure"
@Success		200			{object}	dto.JwtTokensOutput	"JWT access token"
@Failure		400			{object}	dto.ErrorResponse	"Validation error"
@Failure		403			{object}	dto.ErrorResponse	"User already exists"
@Failure		404			{object}	dto.ErrorResponse	"User not found"
@Failure		500			{object}	dto.ErrorResponse	"Internal server error"
@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	"Validation error"
@Failure		500	{object}	dto.ErrorResponse	"Internal server error"
@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