feat: implement RegenerateCurrentUserPAT RPC#1468
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR introduces PAT regeneration functionality by extending the repository interface with a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Pull Request Test Coverage Report for Build 23425613145Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
core/userpat/service_test.go (1)
2148-2371: Strengthen regenerate tests with return-value and boundary assertions.
Current success cases only verifyerr == nil; please also assert returned PAT fields/token and add a case where existing expiry is exactlynowto lock the active-limit boundary behavior.internal/api/v1beta1connect/user_pat_test.go (1)
1169-1252: Add explicit coverage forErrExpiryExceededmapping.
RegenerateCurrentUserPATmaps both expiry errors toCodeInvalidArgument; this suite currently asserts onlyErrExpiryInPast.core/userpat/service.go (1)
167-183: Consider documenting or hardening the count-then-regenerate race window.
CountActive+Regenerateis non-atomic, so concurrent revivals can exceedMaxPerUserPerOrg.Createalready documents a similar TOCTOU risk; this path should get equivalent treatment (comment or atomic DB guard strategy).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dfed0060-a853-4392-ac7f-108e4a9ee92b
⛔ Files ignored due to path filters (1)
proto/v1beta1/frontier.pb.gois excluded by!**/*.pb.go
📒 Files selected for processing (14)
Makefilecore/userpat/mocks/repository.gocore/userpat/service.gocore/userpat/service_test.gocore/userpat/userpat.gointernal/api/v1beta1connect/interfaces.gointernal/api/v1beta1connect/mocks/user_pat_service.gointernal/api/v1beta1connect/user_pat.gointernal/api/v1beta1connect/user_pat_test.gointernal/store/postgres/userpat_repository.gopkg/auditrecord/consts.gopkg/server/connect_interceptors/authorization.goproto/v1beta1/frontier.pb.validate.goproto/v1beta1/frontierv1beta1connect/frontier.connect.go
Description:
Summary
RegenerateCurrentUserPATRPC that creates a new secret and updates expiry for an existing PATChanges
RegenerateCurrentUserPATRPC, request (UUID-validated id, required expires_at), response with PAT (includes new plaintext token)Regeneratemethod — updates secret_hash + expires_at viaRETURNING, handles ErrNotFoundRegeneratemethod — ownership check, expiry validation, limit check for expired PATs, new secret generation, audit recordPATRegeneratedEventwith expires_at and old_expires_at in metadataDesign decisions
GetByIDdoesn't filter by expiry (onlydeleted_at), so expired PATs can be regenerated.Manual test verification
pat.regeneratedevent, including old and new expiry date