auth

package
v0.0.0-...-d6be14c Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeRequestQueryParamsAccountUUIDFieldNotValid    string = "err-400-rqpaufnv"
	ErrMessageRequestQueryParamsAccountUUIDFieldNotValid string = "query string 'accountUuid' in not valid"

	ErrCodeRequestQueryParamsOAuthURLTypeFieldNotValid    string = "err-400-rqpoutfnv"
	ErrMessageRequestQueryParamsOAuthURLTypeFieldNotValid string = "query string 'type' in not valid ('login' or 'bind')"

	ErrCodeRequestQueryParamEmailFieldNotValid    string = "err-400-rqpefnv"
	ErrMessageRequestQueryParamEmailFieldNotValid string = "query string 'email' in not valid"

	ErrCodeRequestHeaderCookieRefreshTokenFieldUnauthorized    string = "err-401-rhcrtfu"
	ErrMessageRequestHeaderCookieRefreshTokenFieldUnauthorized string = "refresh token unauthorized, expired or undefined"

	ErrCodeRequestRecordAlreadyExistWhenOAuthBinding    string = "err-409-rraewoab"
	ErrMessageRequestRecordAlreadyExistWhenOAuthBinding string = "OAuth info already exist"

	ErrCodeRequestOAuthAccessTokenGotError string = "err-500-roatge"
)

Variables

View Source
var OAuthProviderName = map[string]string{
	"google": "google",
}

Functions

func GetAuthTokenByRefreshToken

func GetAuthTokenByRefreshToken(c *gin.Context)

@Summary 取得 authToken @Description 使用 Cookie 中的 REFRESH_TOKEN field 來獲取 authToken @Tags auth @Accept json @Produce json @Success 200 {object} controllers.JSONResponse{data=getAuthTokenByRefreshTokenResponsePayload} @Failure 400 {object} controllers.JSONResponse @Failure 401 {object} controllers.JSONResponse @Failure 500 {object} controllers.JSONResponse @Router /auth/session/token/refresh [get]

func GetCaptchaImage

func GetCaptchaImage(c *gin.Context)

@Summary 取得圖形驗證圖片 @Description 取得與 UUID 相對應的驗證圖片 @Tags auth @Accept json @Produce json @Param captchaUUID path string true "Captcha Info" @Success 200 {string} content-type "image/png" @Failure 500 {object} controllers.JSONResponse @Router /auth/captcha/{captchaUUID}/image [get]

func GetCaptchaInfo

func GetCaptchaInfo(c *gin.Context)

@Summary 取得圖形驗證相關資訊 @Description 取得圖形驗證動態產生的相對應 UUID 及驗證圖片 @Tags auth @Accept json @Produce json @Success 200 {object} controllers.JSONResponse{data=getCaptchaInfoResponsePayload} @Failure 500 {object} controllers.JSONResponse @Router /auth/captcha [get]

func GetChatWSToken

func GetChatWSToken(c *gin.Context)

@Summary 取得 Chat WebSocket 連線用 Token @Description 取得 Chat WebSocket 連線用 Token (1 分鐘效期) @Tags auth @Accept json @Produce json @Security ApiKeyAuth @Success 200 {object} controllers.JSONResponse{data=getChatWSTokenResponse} @Failure 500 {object} controllers.JSONResponse @Router /auth/chat/ws/token [get]

func GetGoogleOAuthURL

func GetGoogleOAuthURL(c *gin.Context)

@Summary 取得 Google OAuth 相關 URL @Description 帶上 type (login, bind) 來表示要取得的是登入用,還是綁定第三方登入用,以及 redirectPath 表示成功後所導轉的終點 @Tags auth @Accept json @Produce json @Param type query string true "login or bind" @Param redirectPath query string true "導轉終點" @Success 200 {object} controllers.JSONResponse{data=getOAuthUrlResponsePayload} @Failure 400 {object} controllers.JSONResponse @Router /auth/o/google/url [get]

func GoogleOAuthBind

func GoogleOAuthBind(c *gin.Context)

@Summary 更新 Account 第三方登入綁定資訊 @Description 更新 Account 第三方登入綁定資訊 @Tags auth @Accept json @Produce json @Security ApiKeyAuth @Param grantCode body string true "Google grant code (from google)" @Success 200 {object} controllers.JSONResponse @Failure 400 {object} controllers.JSONResponse @Failure 409 {object} controllers.JSONResponse @Failure 500 {object} controllers.JSONResponse @Router /auth/o/google/bind [patch]

func GoogleOAuthRedirectURIForBind

func GoogleOAuthRedirectURIForBind(c *gin.Context)

@Summary Google OAuth 登入且授權成功後所導轉的 URI (綁定用) @Description 拿到 Google 給的 grant code 後導轉去指定前端頁面路徑 (導轉路徑為 "[GET]取得 Google OAuth 相關 URL" 當初打 API 時給什麼路徑就轉去那) @Tags auth @Accept json @Produce json @Param code query string true "Google grant code (from google)" @Param state query string true "Front end redirect path (from google OAuth state QS)" @Success 302 @Failure 400 {object} controllers.JSONResponse @Router /auth/o/google/bind [get]

func GoogleOAuthRedirectURIForLogin

func GoogleOAuthRedirectURIForLogin(c *gin.Context)

TODO: 登入、註冊有很多重複的 CODE 需要整理 @Summary Google OAuth 登入且授權成功後所導轉的 URI (登入用) @Description 拿到 Google 給的 grant code 後再去和 Google 拿 access token,再用 access token 去拿該 user 的相關資訊 (scope),若失敗會在 QS 加上 oauth_login_failed=1 @Tags auth @Accept json @Produce json @Param code query string true "Google grant code (from google)" @Param state query string true "Front end redirect path (from google OAuth state QS)" @Success 302 @Failure 302 @Failure 400 {object} controllers.JSONResponse @Failure 500 {object} controllers.JSONResponse @Router /auth/o/google/login [get]

func UpdateCaptchaInfo

func UpdateCaptchaInfo(c *gin.Context)

@Summary 刷新圖形驗證 @Description 刷新與 UUID 相對應的驗證圖片資訊及效期 @Tags auth @Accept json @Produce json @Param captchaUUID path string true "Captcha Info" @Success 200 {object} controllers.JSONResponse @Failure 500 {object} controllers.JSONResponse @Router /auth/captcha/{captchaUUID}/refresh [get]

Types

This section is empty.

Jump to

Keyboard shortcuts

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