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"` // Path to private key file
PublicKeyPath string `json:"public_key_path"` // Path to public key file
PrivateKey string `json:"private_key,omitempty"` // Or directly provide private key content
PublicKey string `json:"public_key,omitempty"` // Or directly provide public key content
AccessTokenExpires time.Duration `json:"access_token_expires,omitempty"` // Default 15 minutes
RefreshIdExpires time.Duration `json:"refresh_id_expires,omitempty"` // Default 7 days
IsProd bool `json:"is_prod"` // Default false
Domain string `json:"domain,omitempty"` // Default localhost
Redis RedisConfig `json:"redis"`
CheckUserExists func(AuthData) (bool, error) `json:"-"`
AccessTokenCookieKey string `json:"access_token_cookie_key,omitempty"` // Default access_token
RefreshIdCookieKey string `json:"refresh_id_cookie_key,omitempty"` // Default refresh_id
MaxVersion int `json:"max_version,omitempty"` // Version threshold, default 5
RefreshTTL float64 `json:"refresh_ttl,omitempty"` // TTL threshold, default 0.5
}
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.