NAME
Azure::SDK::Core::SecretString - opaque wrapper that protects a secret value
SYNOPSIS
use Azure::SDK::Core::SecretString;
my $secret = Azure::SDK::Core::SecretString->new(value => $account_key);
"$secret"; # '[REDACTED]' — safe to interpolate/log
$secret->reveal; # the raw secret — the only way to read it
DESCRIPTION
Azure::SDK::Core::SecretString holds a sensitive string (an account key, a bearer token, a shared access signature) and makes reading it an explicit, greppable act. The raw value is only available through reveal; every other way of observing the object is redacted:
Stringification (interpolation,
warn, log lines) yields[REDACTED].Comparison through
equals,eq, ornecompares two wrapped values and returns only a boolean. Unwrapped strings never compare equal.The object is always boolean-true, so truthiness checks behave sensibly without exposing the secret's length or content.
The value is stored in a field of a core
classobject, whichData::Dumperand similar structure walkers cannot introspect, so a casualDumper($cred)or crash dump does not print the secret.
Credential classes wrap their secret fields in a SecretString and call reveal internally when they need the raw value to sign or authenticate a request. This gives a single, auditable place to read secrets and a natural home for future hardening (for example memory zeroization).
CONSTRUCTOR
new
my $secret = Azure::SDK::Core::SecretString->new(value => $raw);
Named parameter value is required and must be defined. Callers are expected to validate emptiness or format on the raw string before wrapping it.
METHODS
reveal
my $raw = $secret->reveal;
Returns the raw secret value. This is the only method that exposes the secret; call it only at the point of use.
equals
if ($secret->equals($other_secret)) {
...
}
Compares two SecretString values and returns a boolean without returning or stringifying either raw value. A non-SecretString argument returns false. The overloaded eq and ne operators delegate to this method.