Package com.jsgalactic.axiom.security
Class HeaderRedaction
java.lang.Object
com.jsgalactic.axiom.security.HeaderRedaction
Replaces the values of credential-bearing headers before headers are logged.
var redaction = HeaderRedaction.defaults().and("X-Tenant-Secret");
LOG.log(INFO, "headers " + redaction.redact(ctx.request().headers()));
defaults() redacts Authorization, Proxy-Authorization,
Cookie, Set-Cookie, X-Api-Key, X-Auth-Token, X-Csrf-Token,
X-Xsrf-Token and X-Amz-Security-Token. Names compare case-insensitively. A
redacted value becomes "[redacted]"; it is replaced entirely, so neither the scheme nor the
length of a credential is kept. Other values are copied unchanged and remain untrusted client
input when they come from a request.
Redaction is a logging aid, not access control: Axiom never logs header values itself, and
Request.toString() omits them. Immutable and thread-safe.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns a copy that also redacts the named headers.static HeaderRedactiondefaults()Returns the default set of sensitive header names described above.booleanisSensitive(String name) Reports whether a header's value is redacted.Returns a copy of the headers with sensitive values replaced by "[redacted]".
-
Field Details
-
REDACTED
The value that replaces a sensitive header value.- See Also:
-
-
Method Details
-
defaults
Returns the default set of sensitive header names described above.- Returns:
- default redaction
-
and
Returns a copy that also redacts the named headers.- Parameters:
names- header names, HTTP tokens- Returns:
- a copy redacting the additional names
- Throws:
IllegalArgumentException- for a name that is not a token
-
isSensitive
Reports whether a header's value is redacted.- Parameters:
name- header name, matched case-insensitively- Returns:
- true if sensitive
-
redact
Returns a copy of the headers with sensitive values replaced by "[redacted]". Works for request headers (request.headers()) and response headers alike.- Parameters:
headers- header map- Returns:
- immutable, case-insensitive copy, in name order
-