Skip to content

feat: add auto-revoke mechanism for stale API tokens#2734

Merged
migmartri merged 17 commits into
chainloop-dev:mainfrom
migmartri:migmartri/stale-token-revoke
Feb 17, 2026
Merged

feat: add auto-revoke mechanism for stale API tokens#2734
migmartri merged 17 commits into
chainloop-dev:mainfrom
migmartri:migmartri/stale-token-revoke

Conversation

@migmartri

@migmartri migmartri commented Feb 11, 2026

Copy link
Copy Markdown
Member

Adds an organization-level configurable inactivity threshold for automatic API token revocation. A background job periodically sweeps for inactive tokens and revokes them based on each organization's configured threshold.

Closes #2742

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>
Comment thread app/controlplane/pkg/data/ent/schema/organization.go Outdated
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>
Comment thread app/cli/pkg/action/org_update.go Fixed
…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>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
jiparis
jiparis previously approved these changes Feb 16, 2026
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
@migmartri migmartri merged commit 20a3b78 into chainloop-dev:main Feb 17, 2026
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto-revoke stale API tokens based on organization inactivity threshold

4 participants