Skip to content

Correct generated-credentials log sample and signing-key rotation window - #986

Open
Devon-White wants to merge 1 commit into
mainfrom
devon/server-sdks/security-guide-fixes
Open

Devon-White wants to merge 1 commit into
mainfrom
devon/server-sdks/security-guide-fixes

Conversation

@Devon-White

Copy link
Copy Markdown
Collaborator

Closes #959

Summary

  • Server SDK security guide (/docs/server-sdks/guides/security): the "Let SDK Generate Credentials" option no longer claims the SDK prints the generated password. It now shows the line each SDK actually logs at startup (in Python and TypeScript code tabs), describes the username neutrally (SWML_BASIC_AUTH_USER when set, an SDK default otherwise), and tells readers to set SWML_BASIC_AUTH_USER and SWML_BASIC_AUTH_PASSWORD when they need to know the credentials.
  • Signing-key rotation: one figure, "about a minute", on every page that states the window, plus a sentence that calls in progress keep signing with the old key until they end, so readers accept both keys until those calls finish:
    • /docs/swml/guides/webhook-security (rotation paragraph and the troubleshooting bullet)
    • /docs/platform/your-signalwire-api-space (was "a minute or two")
    • /docs/platform/projects (was "a minute or two"; not named in the issue, but it states the same window)

Source anchors

Server SDKs (public repos, at their current default branch):

Platform (internal source, described here as behavior only): a call resolves the project's signing key on its first signed request and keeps that key for the rest of the call. Keys are also shared across a project's new calls for 60 seconds by default, which is the "about a minute" window. Rotating the key through the Dashboard or the REST API clears the control plane's own cached copy immediately, so that 60-second shared cache is the only delay for new calls. Reviewers with access can ask for the exact anchors.

Notes for reviewers

  • The 60-second shared-cache TTL is a code default that a deployment can override through the environment. I couldn't see the production value, so the pages say "about a minute" to match the default. If production overrides it, the figure needs updating on all four pages.
  • A call that hasn't sent a signed request yet when the key rotates can still pick up the old key from that shared cache within the window, then keeps it for the rest of the call. The pages cover this with "accept both keys until the new key is active and those calls have finished", without spelling out the mechanism.
  • The issue's reporter reproduced the per-call behavior on a live call: requests every 18 seconds stayed signed with the old key for 3.5 minutes after a rotation, until the call ended, while new calls placed 2.5 minutes after the rotation used the new key. The page claim rests on source; this run is consistent with it.
  • The console samples show only the credentials line. Both SDKs print other startup lines around it (URL, and a basic_auth_password_autogenerated warning), and TypeScript's logger adds a timestamp/level prefix whose format depends on SIGNALWIRE_LOG_FORMAT, so I left those out rather than reproduce a format that varies.
  • Untouched text on the security page still has pre-existing style issues (Title-Case headings such as "Configuring Credentials", "Option 2: Let SDK Generate Credentials (Development)"). Left as-is to keep the diff scoped.

Verification

  • yarn fern-md-check: all 2895 MDX files valid.
  • No links or anchors added or changed.

Preview

  • /docs/server-sdks/guides/security
  • /docs/swml/guides/webhook-security
  • /docs/platform/your-signalwire-api-space
  • /docs/platform/projects

- Server SDK security guide: the SDK never prints a generated password;
  show the real startup log line per language and point to
  SWML_BASIC_AUTH_USER / SWML_BASIC_AUTH_PASSWORD
- One rotation figure (about a minute) on every page that states it, and
  note that calls in progress keep signing with the old key until they end

Closes #959
@Devon-White Devon-White self-assigned this Nov 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@Manny-r31

Copy link
Copy Markdown
Collaborator

Close to ready. The SDK log samples are right and the new rotation window holds up, but the REST reference for Rotate signing key still says "about 1–2 minutes", so the pages and the API reference now disagree. The PR description also needs an edit before merge.

Technical

1. The REST reference still states the old window. specs/signalwire-rest/projects-api/main.tsp, the @doc on rotate_signing_key, says "The new key takes about 1–2 minutes to become active". It renders at /docs/apis/rest/projects/rotate-signing-key, the page api-credentials.mdx links to from the same paragraph you changed. Change the tsp to match the guides, for example:

The new key takes about a minute to become active, and until then requests can still arrive signed with the previous key. Calls already in progress keep signing with the previous key until they end. Accept a request whose signature verifies with either key until the new key is active and those calls have finished, then stop accepting the previous key.

Then run yarn build:specs and commit the regenerated fern/apis/signalwire-rest/openapi.yaml with it. Don't hand-edit the yaml.

2. The window and the in-progress behavior check out. In the referenced source code, a new key reaches new calls within about a minute of a Dashboard reset or an API rotation, and a call that has already signed a request keeps that key until it ends. All four pages now say that.

3. The log samples match the published SDKs. I installed signalwire-sdk 3.15.3 and @signalwire/sdk 3.15.3 and read the startup path in each. Python prints Basic Auth: signalwire:(credentials configured) (source: generated). TypeScript logs Auth: <name>:**** (source: generated). Neither one prints the password, and both read SWML_BASIC_AUTH_USER and SWML_BASIC_AUTH_PASSWORD. The samples contain no secrets.

4. Name the default usernames. security.mdx line 141 says "The username is SWML_BASIC_AUTH_USER when you set it, and an SDK default otherwise." Two problems. The env var isn't the username, its value is. And "an SDK default" hides a difference between the languages: Python falls back to signalwire and TypeScript falls back to the agent's name. That is why the TypeScript sample shows my-agent, and a reader can't work that out from the prose. Suggested:

The username is the value of SWML_BASIC_AUTH_USER when you set it. Otherwise the Python SDK uses signalwire and the TypeScript SDK uses the agent's name.

Consistency

5. projects.mdx line 381 drops half the condition. It ends "so accept either key until those calls finish." With no calls in progress, that reads as "stop accepting the old key now", but the old key can still sign new calls for about a minute. The other pages say "until the new key is active and those calls have finished". Use that wording here too.

6. This one is pre-existing, so follow-up is fine. fern/products/server-sdks/pages/reference/python/rest/projects/rotate-signing-key.mdx has the description "Issue a new signing key for a project, invalidating the old one." That's no longer accurate given the overlap these pages describe. "Issue a new signing key for a project." matches the TypeScript page. The cXML webhook security page already says "about a minute", so its window is consistent. It just doesn't mention in-progress calls.

7. Possible follow-up for the Server SDK guide. The agent's signing_key / signingKey option takes one key. That means "accept both keys" doesn't happen in an SDK agent on its own: whichever key you configure, requests signed with the other one get 403 during the overlap. security.mdx doesn't cover rotation at all, so readers who follow the SWML page's advice won't know how to do it with an agent. It's out of scope for this PR, but worth an issue.

Style

8. security.mdx line 158: "To know the credentials, for example to put them in a webhook URL or call the agent yourself, set both..." reads awkwardly. Try "To use the credentials yourself, for example in a webhook URL or a test request, set both SWML_BASIC_AUTH_USER and SWML_BASIC_AUTH_PASSWORD."

9. Optional. The bold "Option 2: Let SDK Generate Credentials (Development)" sits right above the block you rewrote. Since you're already in that section, sentence-casing it is a cheap win. Leaving it is fine too, as your notes say.

Everything else looks clean. The new text has no em dashes, no links or anchors were added, and the code block titles follow the house template for language tabs.

PR description

Please edit the description before merge. This repo is public, and the "Platform" source-anchor paragraph and two of the reviewer notes describe how the platform handles signing keys internally. Keep the conclusions, which are the about-a-minute window, in-progress calls keeping the old key, and the reporter's live repro. Cut the explanation of how that happens. The public SDK links are fine to keep.

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.

SDK security guide shows a password the SDK never prints; key rotation omits calls in progress

2 participants