Skip to content

Replace fragile SAML regex XML parsing with DOM-based extraction#120

Merged
Senthil455 merged 4 commits into
mainfrom
fix/issue-47-saml-regex
Jun 17, 2026
Merged

Replace fragile SAML regex XML parsing with DOM-based extraction#120
Senthil455 merged 4 commits into
mainfrom
fix/issue-47-saml-regex

Conversation

@Senthil455

Copy link
Copy Markdown
Owner

Replace 4 regex patterns for extracting NameID and SAML attribute values with robust DOM-based extraction using the already-parsed XML document. Moved DOMParser outside the SAML_IDP_CERT conditional to ensure doc is always available for attribute extraction.

Add backup_codes_shown flag to user_mfa table. Backup codes are only
returned on the initial setup request and marked as shown afterwards.
Re-running setup will regenerate codes but not display them. Add a
/mfa/rotate-backup-codes endpoint that requires current TOTP token
to view new backup codes.
Prevent token leak by removing the raw passwordless token from the API
response body. The token is still stored hashed in the database and can
be verified via /auth/passwordless/verify. The response now only returns
a generic success message.
Replace 4 fragile regex patterns for extracting NameID and SAML attribute
values with robust DOM-based extraction using the already-parsed XML
document. This fixes namespace sensitivity, encoding variations, and
CDATA handling issues. Also moves the DOMParser outside the
SAML_IDP_CERT conditional so it is always available for attribute
extraction.

@Senthil455 Senthil455 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces regex-based XML parsing with DOM methods already available from the signature verification code. Handles namespace variations, CDATA, encoding, and whitespace correctly.

@Senthil455 Senthil455 merged commit 4656103 into main Jun 17, 2026
2 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant