Secret

annotation class Secret(val mask: MaskStrategy = MaskStrategy.FULL, val visibleChars: Int = 4)

Marks a configuration field as sensitive, ensuring its value is masked in logs, debug output, and serialized representations.

Use this annotation for passwords, API keys, tokens, and other credentials. The masking behavior is controlled by the mask strategy and visibleChars parameter.

Usage:

data class ApiConfig(
@Secret
val apiKey: String = "",

@Secret(mask = MaskStrategy.PARTIAL, visibleChars = 4)
val token: String = "",

@Secret(mask = MaskStrategy.EDGES)
val password: String = ""
)

Since

1.0

See also

Properties

Link copied to clipboard

The masking strategy to apply when the value is displayed. Defaults to MaskStrategy.FULL.

Link copied to clipboard
val visibleChars: Int = 4

The number of characters to leave unmasked when using MaskStrategy.PARTIAL or MaskStrategy.EDGES. Defaults to 4.