Conversation
php-saml derives the current SAML endpoint URL from PHP server variables. When Nextcloud is exposed below a path prefix behind a reverse proxy, the external webroot may not be present in those variables. This causes the calculated URL to differ from the Destination in the SAML response and can make response validation fail. Configure php-saml with Nextcloud's webroot before initializing the SAML authentication handler so URL validation includes the external path prefix. Signed-off-by: Robert Dörfler <rodo@bloerp.de>
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.
Description
Fix SAML response validation when Nextcloud is exposed below a non-root path behind a reverse proxy.
For example, Nextcloud may be externally available at:
while the reverse proxy forwards the SAML ACS request internally without the
/nextcloudprefix:php-saml derives the current SAML endpoint URL from PHP server variables during response validation. In this setup, the externally visible Nextcloud webroot is missing from those variables, which can cause the calculated URL to differ from the
Destinationin the SAML response.Solution
Configure php-saml with Nextcloud's webroot before initializing the SAML authentication handler:
This makes php-saml take the external path prefix into account when constructing the routed SAML endpoint URL.
Example:
This uses php-saml's base URL path handling instead of modifying PHP request server variables.
Testing
Added a unit test verifying that
assertionConsumerService()configures php-saml with Nextcloud's webroot before initializing the SAML authentication handler.The relevant controller test suite passes:
The behavior was also verified with php-saml 4.3.2: with
/nextcloudconfigured as the base URL path,getSelfRoutedURLNoQuery()produces the externally visible ACS URL including the/nextcloudprefix.Related to #189