Allow expressions in require statements. #469
Merged
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.
LocationMatch config statements allow regex match groups to be used in
Require
expressions. However, mod_auth_openidc was not parsing these expressions, and instead the raw expression text was used directly. This patch uses existing Apache2 methods to parse and evaluate these expressions. These changes are modeled after the implementation in the Apache2 ldap plugin.If the expression syntax might cause problems for existing statements, then a config option could be introduced to enable or disable expression parsing in order to not break existing configs. However, it seems unlikely that existing
Require
statements would be misinterpreted after introducing this change.Unfortunately, this functionality was difficult to test given the requirement to stub the
ap_*
methods that actually perform expression parsing. Because of this, presently the unit tests simply bypass the expression parsing and use the rawrequire_args
by hiding therequire_args
in theparsed_require_args->filename
pointer and directly returning that pointer as the "parsed" expression. I have manually tested these changes using an expression and observed them to work correctly, but unfortunately they're not well-tested by the test suite, and there doesn't appear to be a simple way to do so.