-
Notifications
You must be signed in to change notification settings - Fork 5
fix: restore OpenSAML class loading and make SAML parsing engine-portable #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dougcain
wants to merge
2
commits into
coldbox-modules:development
Choose a base branch
from
dougcain:fix/boxlang-jar-loading-and-saml-parsing
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dougcain why does this code get called a second time after
initializeOpenSAMLLib();is already used earlier in the function? Why not just callinitializeOpenSAMLLib();again if it is necessary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — you're right that it's redundant, and it's removed in c976525.
For the record on where it came from: it predates both #16 and #17. It arrived with
7cf0359("Verify SAML responses using OpenSAML") and was moved around byc8a56b0/86f2021; #18 never touched this file. My PR only wrapped what was already there, which is why it looked deliberate.It really is a no-op, from the jar rather than from reading the CFML:
Static, synchronized, guarded by a static flag. Worth noting your suggested alternative wouldn't have done anything either —
initializeOpenSAMLLib()early-returns on!isNull( variables.AuthNRequestGenerator ), and even past that guardinitOpenSAML()short-circuits.One thing the redundant call was quietly doing, though. The old ordering assigned
variables.AuthNRequestGeneratorbefore callinginitOpenSAML(). So if initialisation threw, the guard at the top ofinitializeOpenSAMLLib()would short-circuit from then on and the provider could never initialise again for the life of the application — the second call was providing the retry. So rather than just deleting it, initialisation now publishes the objects only onceinitOpenSAML()has returned. Same effect, without depending on a duplicate call to recover.The
runWithClassLoaderaroundparseAndValidatestays, but my justification for it was wrong and I've corrected the comment. I'd written that it was needed becauseparseAndValidatereads the provider registry throughXMLObjectProviderRegistrySupport— butgetRawSAMLRequest()goes through that same registry unwrapped and works fine, which disproves it. The real reason is narrower:verifySignature→SignatureValidator.validateresolves crypto providers through the thread context classloader, which on BoxLang isn't the one the OpenSAML classes were loaded from. The comment now says that, and warns against both wrong conclusions (wrap everything / remove it).Two other things came out of chasing this, both in the same commit:
cacheCerts()is now reachable with an unsetfederationMetadataURL, since initialisation is lazy and no longer runs only from the setter. It throws a namedMicrosoftSAMLProvider.MissingConfigurationinstead of failing against an empty string on a user's first sign-in.Re-verified end to end on BoxLang 1.14.0+55 / ColdBox 7 against Entra after a cold boot: registration does no jar loading or IdP fetch, sign-in redirects with a valid signed
SAMLRequest, ACS authenticates. Worth flagging that CI can't cover any of this — the repo has nolib/, so the SAML provider path never executes there.