Documentation ¶
Index ¶
- func GenerateJWT(id string, data map[string]string) string
- func GenerateRefreshToken(id string) string
- func GenerateToken(id string) string
- type AuthClient
- type GoAuth
- func (g *GoAuth) CheckClientInRedis(client AuthClient) (AuthClient, error)
- func (g *GoAuth) CheckTokenInRedis(token string) (AuthClient, error)
- func (g *GoAuth) ClientCredential(client AuthClient, isRefresh bool) (AuthClient, error)
- func (g *GoAuth) CreateClient(client AuthClient) AuthClient
- func (g *GoAuth) CreateClientResponse(client AuthClient, isRefresh bool) (AuthClient, error)
- func (g *GoAuth) DeleteClientFromRedis(client AuthClient) error
- func (g *GoAuth) GetTokenFromRedis(clientId string) (interface{}, error)
- func (g *GoAuth) GetUserFromRedis(clientId string) (interface{}, error)
- func (g *GoAuth) InsertClientToRedis(client AuthClient) error
- type GoAuthMiddleware
- func (ig *GoAuthMiddleware) GinAuthMiddleware() gin.HandlerFunc
- func (ig *GoAuthMiddleware) SetupGoAuthMiddleware()
- func (ig *GoAuthMiddleware) SetupStrategies(strategies ...auth.Strategy)
- func (ig *GoAuthMiddleware) ValidateBasicAuth(ctx context.Context, r *http.Request, username, password string) (auth.Info, error)
- func (ig *GoAuthMiddleware) ValidateTokenAuth(ctx context.Context, r *http.Request, tokenString string) (auth.Info, time.Time, error)
- type IGoAuth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateRefreshToken ¶
func GenerateToken ¶
Types ¶
type AuthClient ¶
type AuthClient struct { ClienId string `json:"client_id"` UserId string `json:"user_id"` Token string `json:"token"` RefreshToken string `json:"refresh_token"` CreatedTime time.Time `json:"created_at"` ExpiredTime time.Time `json:"expired_at"` ExpiredIn int `json:"expired_in"` Scope string `json:"scope"` TokenType string `json:"token_type"` JWT string `json:"jwt"` UserData map[string]string `json:"-"` }
type GoAuth ¶
type GoAuth struct { RedisTokenKey string RedisUserKey string RedisExpiredIn int RedisClient *redis.Client TokenType string }
func (*GoAuth) CheckClientInRedis ¶
func (g *GoAuth) CheckClientInRedis(client AuthClient) (AuthClient, error)
func (*GoAuth) CheckTokenInRedis ¶
func (g *GoAuth) CheckTokenInRedis(token string) (AuthClient, error)
func (*GoAuth) ClientCredential ¶
func (g *GoAuth) ClientCredential(client AuthClient, isRefresh bool) (AuthClient, error)
func (*GoAuth) CreateClient ¶
func (g *GoAuth) CreateClient(client AuthClient) AuthClient
func (*GoAuth) CreateClientResponse ¶
func (g *GoAuth) CreateClientResponse(client AuthClient, isRefresh bool) (AuthClient, error)
func (*GoAuth) DeleteClientFromRedis ¶
func (g *GoAuth) DeleteClientFromRedis(client AuthClient) error
func (*GoAuth) GetTokenFromRedis ¶
func (*GoAuth) GetUserFromRedis ¶
func (*GoAuth) InsertClientToRedis ¶
func (g *GoAuth) InsertClientToRedis(client AuthClient) error
type GoAuthMiddleware ¶
type GoAuthMiddleware struct { GoAuth IGoAuth CacheObj libcache.Cache Strategy union.Union TokenStrategy auth.Strategy }
func NewAuthMiddleware ¶
func NewAuthMiddleware(client IGoAuth) (*GoAuthMiddleware, error)
func (*GoAuthMiddleware) GinAuthMiddleware ¶
func (ig *GoAuthMiddleware) GinAuthMiddleware() gin.HandlerFunc
func (*GoAuthMiddleware) SetupGoAuthMiddleware ¶
func (ig *GoAuthMiddleware) SetupGoAuthMiddleware()
func (*GoAuthMiddleware) SetupStrategies ¶
func (ig *GoAuthMiddleware) SetupStrategies(strategies ...auth.Strategy)
func (*GoAuthMiddleware) ValidateBasicAuth ¶
type IGoAuth ¶
type IGoAuth interface { GetTokenFromRedis(clientId string) (interface{}, error) GetUserFromRedis(clientId string) (interface{}, error) InsertClientToRedis(client AuthClient) error DeleteClientFromRedis(client AuthClient) error ClientCredential(client AuthClient, isRefresh bool) (AuthClient, error) CheckClientInRedis(client AuthClient) (AuthClient, error) CheckTokenInRedis(token string) (AuthClient, error) CreateClient(client AuthClient) AuthClient CreateClientResponse(client AuthClient, isRefresh bool) (AuthClient, error) }
Click to show internal directories.
Click to hide internal directories.