test: add comprehensive test coverage and improve code quality
- Add new test files for auth, service, and handler modules - Improve test organization and coverage - Refactor code for better maintainability - Add captcha, settings, stats, and theme handler tests - Add auth module tests (CAS, OAuth, password, SSO, state) - Add service layer tests for auth, export, permissions, roles - All Go tests pass (exit code 0) - All frontend tests pass (325 tests in 59 files)
This commit is contained in:
@@ -36,23 +36,23 @@ type JWTOptions struct {
|
||||
|
||||
// JWT JWT管理器
|
||||
type JWT struct {
|
||||
algorithm string
|
||||
secret []byte
|
||||
privateKey *rsa.PrivateKey
|
||||
publicKey *rsa.PublicKey
|
||||
accessTokenExpire time.Duration
|
||||
refreshTokenExpire time.Duration
|
||||
rememberLoginExpire time.Duration
|
||||
initErr error
|
||||
algorithm string
|
||||
secret []byte
|
||||
privateKey *rsa.PrivateKey
|
||||
publicKey *rsa.PublicKey
|
||||
accessTokenExpire time.Duration
|
||||
refreshTokenExpire time.Duration
|
||||
rememberLoginExpire time.Duration
|
||||
initErr error
|
||||
}
|
||||
|
||||
// Claims JWT声明
|
||||
type Claims struct {
|
||||
UserID int64 `json:"user_id"`
|
||||
Username string `json:"username"`
|
||||
Type string `json:"type"` // access, refresh
|
||||
Type string `json:"type"` // access, refresh
|
||||
Remember bool `json:"remember,omitempty"` // 记住登录标记
|
||||
JTI string `json:"jti"` // JWT ID,用于黑名单
|
||||
JTI string `json:"jti"` // JWT ID,用于黑名单
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
@@ -82,10 +82,10 @@ func NewJWT(secret string, accessTokenExpire, refreshTokenExpire time.Duration)
|
||||
})
|
||||
if err != nil {
|
||||
return &JWT{
|
||||
algorithm: jwtAlgorithmHS256,
|
||||
algorithm: jwtAlgorithmHS256,
|
||||
accessTokenExpire: accessTokenExpire,
|
||||
refreshTokenExpire: refreshTokenExpire,
|
||||
initErr: err,
|
||||
refreshTokenExpire: refreshTokenExpire,
|
||||
initErr: err,
|
||||
}
|
||||
}
|
||||
return manager
|
||||
|
||||
Reference in New Issue
Block a user