Rework the redaction API - #4
Merged
Merged
Conversation
v1.2.1 exposed redaction as a static class plus three flat config keys holding a
list of uppercase substrings. Adding one term meant copying the whole default
list, there was no way to name a single variable, and no way to force a variable
to stay visible.
Redactor replaces it. Four methods cover the cases:
FilamentPHPInfoPlugin::make()
->redact('SESSION_FINGERPRINT')
->redactContaining('tenant')
->reveal('AWS_ACCESS_KEY_ID')
->placeholder('***')
redact() and reveal() take exact names, ignore case, and accept APP_KEY or
$_ENV['APP_KEY'] for the same variable. redactContaining() adds to the defaults
rather than replacing them. reveal() beats every other rule.
Term matching stays scoped to the Environment and PHP Variables sections, so PHP
settings named "Max keys" or "Tokenizer Support" keep their values. A name passed
to redact() applies everywhere, because you named it on purpose.
The page hands the view a Redactor rather than the view calling a static, so a
panel can configure it. fromConfig() still reads the 1.2.x config keys, so an
edited config file does not silently lose a term and start printing that value
again. A view published against 1.2.x calls the removed static and must be
republished.
The page handed the view a Redactor and left every cell to call it. A published view that missed one call printed that secret. The page now redacts the capture in getViewData(), so the view receives safe data and needs nothing. The packaged view and config are back to their v1.2.0 form. redact() and reveal() now take exact names or * wildcards, which covers what redactContaining() did, so that method is gone. The config file no longer holds redaction settings. The plugin is the one place to adjust it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #3.
What this changes
v1.2.1 left redaction to the view. Every cell had to call
Redaction::value(), and a published view that missed one call printed that secret.Now the page redacts the capture before the view receives it. The packaged view and config are back to their v1.2.0 form, byte for byte, and a published view needs nothing.
Using it
Nothing to set up. To adjust:
Both methods take exact names or
*wildcards, ignore case, and apply anywhere on the page.->placeholder()and->withoutRedaction()cover the rest.The built-in terms (
password,key,secretand so on) match only the Environment and PHP Variables sections, soMax keysandTokenizer Supportkeep their values.Breaking for v1.2.1 users
Redactionand theredact-*config keys are gone. A config file published from v1.2.1 referencesRedaction::DEFAULT_PATTERNS, so the app will not boot until those keys are deleted. The README covers it.Tests
44 passing.
🤖 Generated with Claude Code