Add DOKU credential validation and normalization - #439
Merged
Conversation
DOKU answers the access token request with "Unauthorized. Unknown Client" when it does not recognise the client id in X-CLIENT-KEY. Nothing in the API made that diagnosable: a blank or mangled credential booted fine and only surfaced as a 500 at the customer's checkout. - Trim whitespace and surrounding quotes off the DOKU credentials, so a .env written by the deploy workflow cannot corrupt them. - Accept a newline-escaped or quoted DOKU_PRIVATE_KEY, the format .env.example documents and the one systemd may pass through verbatim. - Validate the whole DOKU config at boot and name every missing variable instead of failing later on a checkout. - Log the rejection with its response code, base URL and a masked client id, and carry the response code into the error message. - Add `make doku-check`, which asks DOKU for an access token with the configured credentials and prints what to check when it is refused. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TXdAv9tEdEFQtLYSRcRoUB
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Adds comprehensive validation and normalization for DOKU payment gateway credentials to catch configuration errors early and handle environment variable quirks from .env files and systemd EnvironmentFile.
Key Changes
Config.Validate()method checks all required DOKU configuration fields are present and non-emptynormalizePrivateKeyPEM()handles PEM keys that arrive quoted or with escaped newlines from environment sourcesgetCredential()trims and unquotes credential strings from environment variablesmaskCredential()function masks sensitive values in logs while preserving last 4 characters for debuggingdokucheckCLI command validates credentials by attempting to fetch an access token from DOKUImplementation Details
\nstrings) and literal newlines, plus surrounding quotesdokuchecktool provides helpful guidance for common configuration mistakes like using Checkout instead of SNAP client IDhttps://claude.ai/code/session_01TXdAv9tEdEFQtLYSRcRoUB