Remove credentials from URLs¶
Source: R/redaction.R ยท Help: ?redact_url
redact_url() strips credentials from a single URL; redact_urls_in_text()
finds every URL in free text and redacts each one. Scheme, host and port are
always kept -- they are what makes an error actionable -- while userinfo and
credential-bearing query and fragment parameters are replaced by ***.
Parameter names are matched token by token (accessToken, api_key,
X-Amz-Signature), not by substring, so ordinary parameters such as
keyword survive.
Usage¶
Arguments¶
url- A single URL. Anything that is not a URL with a host is returned unchanged.
keep_path- Keep the URL path? Use
FALSEwhere the path itself is the secret, as in the incoming-webhook URLs of Slack and similar services. text- A single string that may contain URLs.
Value¶
The redacted string. A URL that carries no credential is returned exactly as given.
Details¶
These are the rules of the Python DataExcept package, so a URL redacted in
either language reads the same. dataexcept applies them automatically to the
message and character fields of every condition it creates, and again, with
keep_path = FALSE, to everything it writes into an envelope.
What redaction cannot do: a bare secret that is not part of a URL cannot be recognised in free text, and is not removed.