fixed authorization
This commit is contained in:
+6
-9
@@ -31,10 +31,7 @@ var (
|
||||
jwtSecretError error
|
||||
|
||||
// Pre-allocate error messages to avoid repeated allocations
|
||||
errInvalidAuthFormat = "invalid authorization header format"
|
||||
errInvalidToken = "Invalid token"
|
||||
errExpiredToken = "Invalid or expired token"
|
||||
errInvalidClaims = "Invalid token claims"
|
||||
errExpiredToken = "Invalid or expired token"
|
||||
)
|
||||
|
||||
// Initialize JWT secret once
|
||||
@@ -100,11 +97,11 @@ func checkTokenCache(tokenString string) (*models.Claims, bool) {
|
||||
}
|
||||
|
||||
// removeExpiredCacheEntry removes a single expired token from cache
|
||||
func removeExpiredCacheEntry(tokenString string) {
|
||||
tokenCacheMutex.Lock()
|
||||
defer tokenCacheMutex.Unlock()
|
||||
delete(tokenCache, tokenString)
|
||||
}
|
||||
// func removeExpiredCacheEntry(tokenString string) {
|
||||
// tokenCacheMutex.Lock()
|
||||
// defer tokenCacheMutex.Unlock()
|
||||
// delete(tokenCache, tokenString)
|
||||
// }
|
||||
|
||||
// parseAndValidateToken parses JWT token and validates it
|
||||
func parseAndValidateToken(tokenString string) (*models.Claims, error) {
|
||||
|
||||
Reference in New Issue
Block a user