Documentation
¶
Index ¶
- type AuthData
- type AuthResult
- type Config
- type JWTAuth
- func (j *JWTAuth) ClearCookie(w http.ResponseWriter, name string)
- func (j *JWTAuth) Close() error
- func (j *JWTAuth) Create(r *http.Request, w http.ResponseWriter, u *AuthData) (*TokenResult, error)
- func (j *JWTAuth) CreateRefreshId(userID, name, email, fp string) string
- func (j *JWTAuth) GetAccessToken(r *http.Request) string
- func (j *JWTAuth) GetFingerprint(r *http.Request) string
- func (j *JWTAuth) GetRefreshData(refreshId, fp string) (*RefreshData, error)
- func (j *JWTAuth) GetRefreshId(r *http.Request) string
- func (j *JWTAuth) GetUserData(data map[string]interface{}) AuthData
- func (j *JWTAuth) GinMiddleware() gin.HandlerFunc
- func (j *JWTAuth) HTTPMiddleware(next http.Handler) http.Handler
- func (j *JWTAuth) Refresh(r *http.Request, w http.ResponseWriter, refreshId, fp string) *AuthResult
- func (j *JWTAuth) Revoke(r *http.Request, w http.ResponseWriter) error
- func (j *JWTAuth) SetCookie(w http.ResponseWriter, name, value string, expires time.Time)
- func (j *JWTAuth) Verify(r *http.Request, w http.ResponseWriter) *AuthResult
- type RedisConfig
- type RefreshData
- type TokenResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthData ¶
type AuthResult ¶
type Config ¶
type Config struct {
PrivateKeyPath string `json:"private_key_path"` // 私鑰檔案路徑
PublicKeyPath string `json:"public_key_path"` // 公鑰檔案路徑
PrivateKey string `json:"private_key,omitempty"` // 或直接提供私鑰內容
PublicKey string `json:"public_key,omitempty"` // 或直接提供公鑰內容
AccessTokenExpires time.Duration `json:"access_token_expires"`
RefreshIdExpires time.Duration `json:"refresh_id_expires"`
IsProd bool `json:"is_prod"`
Domain string `json:"domain,omitempty"`
Redis RedisConfig `json:"redis"`
CheckUserExists func(AuthData) (bool, error) `json:"-"`
AccessTokenCookieKey string `json:"access_token_cookie_key"`
RefreshIdCookieKey string `json:"refresh_id_cookie_key"`
}
type JWTAuth ¶
type JWTAuth struct {
// contains filtered or unexported fields
}
func (*JWTAuth) ClearCookie ¶
func (j *JWTAuth) ClearCookie(w http.ResponseWriter, name string)
func (*JWTAuth) Create ¶
func (j *JWTAuth) Create(r *http.Request, w http.ResponseWriter, u *AuthData) (*TokenResult, error)
func (*JWTAuth) CreateRefreshId ¶
func (*JWTAuth) GetRefreshData ¶
func (j *JWTAuth) GetRefreshData(refreshId, fp string) (*RefreshData, error)
func (*JWTAuth) GetUserData ¶
set user data from json and return AuthData
func (*JWTAuth) GinMiddleware ¶
func (j *JWTAuth) GinMiddleware() gin.HandlerFunc
func (*JWTAuth) Refresh ¶
func (j *JWTAuth) Refresh(r *http.Request, w http.ResponseWriter, refreshId, fp string) *AuthResult
func (*JWTAuth) Verify ¶
func (j *JWTAuth) Verify(r *http.Request, w http.ResponseWriter) *AuthResult
type RedisConfig ¶
type RefreshData ¶
type TokenResult ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.