-
Notifications
You must be signed in to change notification settings - Fork 1
fix: reconcile API key expiry docs with server-side 365-day cap #407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -20,11 +20,16 @@ Kosli never stores your API token in plain text. Only a cryptographic hash of th | |||||
| When you rotate a service account API key, Kosli: | ||||||
|
|
||||||
| 1. Generates a **new** API key immediately and returns its value **once**. | ||||||
| 2. Keeps the **old** key valid for a configurable grace period (default: **24 hours**). | ||||||
| 3. Automatically revokes the old key when the grace period expires. | ||||||
| 2. Sets the new key's expiry to the **rotated key's current expiry** unless you pass `--expires-at` (CLI) or `expires_at` (API), bounded by the server-side **maximum lifetime of 365 days from creation**. | ||||||
| 3. Keeps the **old** key valid for a configurable grace period (default: **24 hours**). | ||||||
| 4. Automatically revokes the old key when the grace period expires. | ||||||
|
|
||||||
| The grace period lets you roll the new key out to all consumers without an interruption in service. Choose a window that matches your deployment cadence — short enough to limit exposure, long enough to update every dependent system. | ||||||
|
|
||||||
| <Warning> | ||||||
| Rotation on its own does not extend the credential. If the rotated key is already close to its expiry (for example, most of the way through the 365-day cap), the new key inherits that expiry and dies at the same moment — the exact failure rotation is supposed to prevent. Pass `--expires-at` to reset the clock, up to the 365-day cap. | ||||||
| </Warning> | ||||||
|
Comment on lines
+29
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Warning's only remedy is
Same applies to the Warning at |
||||||
|
|
||||||
| ## Rotate a key | ||||||
|
|
||||||
| Choose the interface that best fits your workflow. All three trigger the same rotation flow described above. | ||||||
|
|
@@ -46,10 +51,13 @@ Choose the interface that best fits your workflow. All three trigger the same ro | |||||
| kosli rotate api-key <<key-id>> \ | ||||||
| --service-account <<service-account-name>> \ | ||||||
| --grace-period-hours 24 \ | ||||||
| --expires-at 2026-12-31 \ | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This page already uses the
Suggested change
Same issue at line 89 — |
||||||
| --api-token "$KOSLI_ADMIN_TOKEN" \ | ||||||
| --org "$ORG" | ||||||
| ``` | ||||||
|
|
||||||
| `--expires-at` accepts an epoch timestamp, `YYYY-MM-DD`, `YYYY-MM-DD HH:MM:SS`, or an RFC3339 timestamp, and is capped at 365 days from creation. Omit it to inherit the rotated key's expiry — combine that with a rotation cadence well inside the 365-day cap, or pass `--expires-at` to reset the clock. | ||||||
|
|
||||||
| Rotate multiple keys for the same service account in one call by passing additional key IDs. When `--grace-period-hours` is omitted, the server-side default grace period applies: | ||||||
|
|
||||||
| ```shell | ||||||
|
|
@@ -78,10 +86,12 @@ Choose the interface that best fits your workflow. All three trigger the same ro | |||||
| curl -X POST \ | ||||||
| -H "Authorization: Bearer <<your-admin-api-key>>" \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '{"grace_period_hours": 24}' \ | ||||||
| -d '{"grace_period_hours": 24, "expires_at": 1798761600}' \ | ||||||
| https://app.kosli.com/api/v2/service-accounts/<<your-org>>/<<service-account-name>>/api-keys/<<key-id>>/rotate | ||||||
| ``` | ||||||
|
|
||||||
| `expires_at` is an epoch timestamp for the new key's expiry. Omit it to inherit the rotated key's expiry. The value is capped at 365 days from creation. | ||||||
|
|
||||||
| The response contains the new API key value. Capture it directly into your secrets store: | ||||||
|
|
||||||
| ```shell | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "Omitted → the server applies the maximum 365-day expiry" bullet is true only at creation, and it now reads as contradicting the schema entry at line 96 ("Removing a previously set value from configuration leaves the existing expiry unchanged").
The old text closed that gap with the trailing clause you removed (
to get a non-expiring key again, the key must be recreated (e.g. via terraform taint ...)). Without it, a reader who deletesexpires_atfrom a live resource to "reset the clock to 365 days" gets no change at all, and the page doesn't say how to actually get a fresh key.Two things folded into the suggestion, take or leave independently:
marks the resource tainted so the next apply revokes and recreates itis a specific Terraform-mechanics claim I can't verify from this repo.Provider produced inconsistent result after applyis an error diagnostic; whether the object ends up tainted and auto-recreated depends on the operation and Terraform version, andterraform tainthas been deprecated in favour of-replace=since 0.15.2. Either confirm it against a real apply ofinternal/provider/resource_service_account_api_key.goor state only the part that's certain.-replace=as the documented remedy, since the page no longer mentions any way to get a fresh key.