feat: add auto-revoke mechanism for stale API tokens#2734
Open
migmartri wants to merge 15 commits intochainloop-dev:mainfrom
Open
feat: add auto-revoke mechanism for stale API tokens#2734migmartri wants to merge 15 commits intochainloop-dev:mainfrom
migmartri wants to merge 15 commits intochainloop-dev:mainfrom
Conversation
Adds an organization-level configurable inactivity threshold (default 30 days) and a background job that periodically sweeps for inactive tokens and revokes them. Includes proto API changes, CLI flag for token threshold configuration, and a new APITokenStaleRevoker background service that runs hourly. Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
jiparis
reviewed
Feb 12, 2026
Changes the default API token inactivity threshold from 30 to 90 days and removes the backfill UPDATE so existing organizations are not affected. Also resolves merge conflicts with main branch. Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
…er input Renames the flag from --api-token-inactivity-threshold (duration string) to --api-token-max-days-inactive (integer days) for clarity. Users now pass a simple number of days instead of Go duration syntax. Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Replaces `google.protobuf.Duration api_token_inactivity_threshold` with `int32 api_token_max_days_inactive` in proto definitions. This eliminates unnecessary duration-to-days conversion in the service and CLI layers since the feature inherently operates on whole days. Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
…ax days Addresses CodeQL finding about potential integer overflow when converting the api-token-max-days-inactive value from int (architecture-dependent) to int32. Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
The api_token_inactivity_threshold_days column is now NULL by default, meaning the feature is opt-in rather than enabled for all organizations. Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Rename repo RevokeInactive to FindInactive (query-only) and have the stale revoker call APITokenUseCase.Revoke per token so audit events are properly dispatched. Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an organization-level configurable inactivity threshold (default 30 days) for automatic API token revocation. A background job periodically sweeps for inactive tokens and revokes them based on each organization's configured threshold.