Secret
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 = ""
)Content copied to clipboard
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
The number of characters to leave unmasked when using MaskStrategy.PARTIAL or MaskStrategy.EDGES. Defaults to 4.