Documentation
¶
Index ¶
- Constants
- func BindBody(w http.ResponseWriter, r *http.Request, i interface{}) *model.ErrorResBody
- func ParamGroupUuid(r *http.Request) string
- func ValidateBody(w http.ResponseWriter, i interface{}) *model.ErrorResBody
- func ValidateTokenRequest(w http.ResponseWriter, tokenRequest *model.TokenRequest) *model.ErrorResBody
- type Interceptor
- type InterceptorImpl
- func (i InterceptorImpl) Intercept(next http.HandlerFunc) http.HandlerFunc
- func (i InterceptorImpl) InterceptAuthenticateGroupAdmin(next http.HandlerFunc) http.HandlerFunc
- func (i InterceptorImpl) InterceptAuthenticateGroupUser(next http.HandlerFunc) http.HandlerFunc
- func (i InterceptorImpl) InterceptAuthenticateOperator(next http.HandlerFunc) http.HandlerFunc
- func (i InterceptorImpl) InterceptAuthenticateUser(next http.HandlerFunc) http.HandlerFunc
- func (i InterceptorImpl) InterceptSecret(next http.HandlerFunc) http.HandlerFunc
- type Migration
- type TokenProcessor
- type TokenProcessorImpl
- func (tp TokenProcessorImpl) Generate(userType string, tokenRequest model.TokenRequest) (*model.TokenResponse, *model.ErrorResBody)
- func (tp TokenProcessorImpl) GetJwtPayload(token string, isRefresh bool) (*model.JwtPayload, *model.ErrorResBody)
- func (tp TokenProcessorImpl) VerifyOperatorToken(token string) (*model.JwtPayload, *model.ErrorResBody)
- func (tp TokenProcessorImpl) VerifyUserToken(token string, roleNames string, permissionNames string, groupUuid string) (*model.JwtPayload, *model.ErrorResBody)
Constants ¶
View Source
const ( Authorization = "Authorization" ClientSecret = "Client-Secret" ContentType = "Content-Type" AccessControlAllowOrigin = "Access-Control-Allow-Origin" AccessControlAllowHeaders = "Access-Control-Allow-Headers" ScopeSecret = "secret" ScopeJwt = "jwt" )
Http Header, Request scope const
Variables ¶
This section is empty.
Functions ¶
func BindBody ¶
func BindBody(w http.ResponseWriter, r *http.Request, i interface{}) *model.ErrorResBody
Bind request body what http request converts to interface
func ParamGroupUuid ¶
Parse request group_uuid of path parameter
func ValidateBody ¶
func ValidateBody(w http.ResponseWriter, i interface{}) *model.ErrorResBody
Validate request body
func ValidateTokenRequest ¶
func ValidateTokenRequest(w http.ResponseWriter, tokenRequest *model.TokenRequest) *model.ErrorResBody
Validate request body
Types ¶
type Interceptor ¶
type Interceptor interface { // Intercept Http request and Client-Secret header Intercept(next http.HandlerFunc) http.HandlerFunc // InterceptSecret // Intercept only http header InterceptSecret(next http.HandlerFunc) http.HandlerFunc // InterceptAuthenticateUser // Intercept Http request and Client-Secret header with user authentication InterceptAuthenticateUser(next http.HandlerFunc) http.HandlerFunc // InterceptAuthenticateGroupAdmin // Intercept Http request and Client-Secret header with user and group admin role authentication InterceptAuthenticateGroupAdmin(next http.HandlerFunc) http.HandlerFunc // InterceptAuthenticateGroupUser // Intercept Http request and Client-Secret header with user and group user role authentication InterceptAuthenticateGroupUser(next http.HandlerFunc) http.HandlerFunc // InterceptAuthenticateOperator // Intercept Http request and Client-Secret header with operator authentication InterceptAuthenticateOperator(next http.HandlerFunc) http.HandlerFunc }
func GetInterceptorInstance ¶
func GetInterceptorInstance() Interceptor
func NewInterceptor ¶
func NewInterceptor() Interceptor
type InterceptorImpl ¶
type InterceptorImpl struct {
// contains filtered or unexported fields
}
func (InterceptorImpl) Intercept ¶
func (i InterceptorImpl) Intercept(next http.HandlerFunc) http.HandlerFunc
func (InterceptorImpl) InterceptAuthenticateGroupAdmin ¶
func (i InterceptorImpl) InterceptAuthenticateGroupAdmin(next http.HandlerFunc) http.HandlerFunc
func (InterceptorImpl) InterceptAuthenticateGroupUser ¶
func (i InterceptorImpl) InterceptAuthenticateGroupUser(next http.HandlerFunc) http.HandlerFunc
func (InterceptorImpl) InterceptAuthenticateOperator ¶
func (i InterceptorImpl) InterceptAuthenticateOperator(next http.HandlerFunc) http.HandlerFunc
func (InterceptorImpl) InterceptAuthenticateUser ¶
func (i InterceptorImpl) InterceptAuthenticateUser(next http.HandlerFunc) http.HandlerFunc
func (InterceptorImpl) InterceptSecret ¶
func (i InterceptorImpl) InterceptSecret(next http.HandlerFunc) http.HandlerFunc
type Migration ¶
type Migration struct {
// contains filtered or unexported fields
}
func NewMigration ¶
func NewMigration() Migration
type TokenProcessor ¶
type TokenProcessor interface { // Generate jwt token Generate(userType string, tokenRequest model.TokenRequest) (*model.TokenResponse, *model.ErrorResBody) // Verify operator token VerifyOperatorToken(token string) (*model.JwtPayload, *model.ErrorResBody) // Verify user token VerifyUserToken(token string, roleNames string, permissionNames string, groupUuid string) (*model.JwtPayload, *model.ErrorResBody) // Get auth user data in token // If invalid token, return 401 GetJwtPayload(token string, isRefresh bool) (*model.JwtPayload, *model.ErrorResBody) }
func GetTokenProcessorInstance ¶
func GetTokenProcessorInstance() TokenProcessor
Get TokenProcessor instance. If use singleton pattern, call this instance method
type TokenProcessorImpl ¶
type TokenProcessorImpl struct { UserService service.UserService OperatorPolicyService service.OperatorPolicyService Service service.Service PolicyService service.PolicyService RoleService service.RoleService PermissionService service.PermissionService ServerConfig common.ServerConfig Token *jwt.Token }
TokenProcessor struct
func (TokenProcessorImpl) Generate ¶
func (tp TokenProcessorImpl) Generate(userType string, tokenRequest model.TokenRequest) (*model.TokenResponse, *model.ErrorResBody)
func (TokenProcessorImpl) GetJwtPayload ¶
func (tp TokenProcessorImpl) GetJwtPayload(token string, isRefresh bool) (*model.JwtPayload, *model.ErrorResBody)
func (TokenProcessorImpl) VerifyOperatorToken ¶
func (tp TokenProcessorImpl) VerifyOperatorToken(token string) (*model.JwtPayload, *model.ErrorResBody)
func (TokenProcessorImpl) VerifyUserToken ¶
func (tp TokenProcessorImpl) VerifyUserToken(token string, roleNames string, permissionNames string, groupUuid string) (*model.JwtPayload, *model.ErrorResBody)
Click to show internal directories.
Click to hide internal directories.