Skip to content

Adopt secrecy for sensitive configuration #2079

Closed

Description

@josecelano

Goal

Adopt the Rust secrecy crate for configuration API tokens in both v2 and v3. This makes tokens explicit in the Rust type system, redacts them from Debug and Display output, clears them from memory when dropped, and makes intentional exposure reviewable.

Scope

  • Add secrecy with the supported serialization configuration.
  • Change v2 and v3 API tokens to Secret<String> without changing TOML syntax.
  • Update authentication, bootstrap, tests, logging, tracing, error, and output boundaries so .expose_secret() occurs only where authentication needs the token.
  • Add regression tests for the exact Secret([REDACTED]) representation and to ensure test tokens do not appear in output.
  • Preserve legacy v2 and current v3 database URLs as plain strings with their existing mask_secrets() behavior.
  • Update secret-handling policy documentation.

Sequencing and release gate

This is implemented before #1490. It establishes the Secret<String> convention for API tokens while deliberately leaving legacy database URLs unchanged. #1490 subsequently decomposes v3 database configuration and uses Secret<String> for its new isolated database password.

Both #2079 and #1490 must be merged before publishing a torrust-tracker-configuration release exposing the v3 types. Changing public fields from String to Secret<String> is semver-breaking for Rust consumers.

Out of scope

  • Changing v2 or v3 TOML syntax.
  • Wrapping legacy database URLs in Secret<String>.
  • Database configuration decomposition; tracked by Decompose v3 database configuration #1490.
  • Encrypting configuration files at rest.
  • A custom secret-wrapper type.

Verification

  • Run focused configuration, REST API server, and tracker-core tests.
  • Run the workspace test suite and linter all.
  • Verify v2 and v3 Debug formatting uses exactly Secret([REDACTED]) for test API tokens.
  • Verify authentication receives the actual token only at its runtime integration boundary.
  • Verify tokens do not occur in logs, tracing output, errors, or CLI JSON output.

References

The Git-tracked implementation specification is the source of truth: docs/issues/open/2079-adopt-secrecy-for-sensitive-configuration.md. This GitHub body is a summary and may become stale.

Activity

  1. josecelano commented on Aug 21, 2026

    @josecelano
    MemberAuthor

    This issue is the prerequisite API-token secrecy refactor for #1490. It intentionally retains legacy database URLs and their manual masking; #1490 subsequently isolates the v3 password and represents it as Secret<String>.\n\nFor implementation, the Git-tracked specification is the source of truth: docs/issues/open/2079-adopt-secrecy-for-sensitive-configuration.md. The GitHub issue body is informational and may be stale.

  2. self-assigned this
    on Aug 21, 2026
  3. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions