fix(security): harden refresh token validation and add auth tests

Reject refresh attempts when the DB token type is not refresh_token,
and add service-layer tests for bearer refresh rejection, logout
revocation, and expired-token logout handling.
This commit is contained in:
wizardchen
2026-07-02 17:06:06 +08:00
committed by lyingbug
parent 26cc335420
commit 235e86b876
2 changed files with 197 additions and 0 deletions
+3
View File
@@ -978,6 +978,9 @@ func (s *userService) RefreshToken(
if err != nil || tokenRecord == nil || tokenRecord.IsRevoked {
return "", "", errors.New("refresh token is revoked")
}
if tokenRecord.TokenType != "refresh_token" {
return "", "", errors.New("not a refresh token")
}
// Get user
user, err := s.userRepo.GetUserByID(ctx, userID)