From 9c2773ddf1ee0549ccee767856c79507e2c6afed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Alvergnat?= Date: Fri, 5 Apr 2019 10:39:27 +0200 Subject: [PATCH] Support reverse proxy the NextCloud way In some network configurations involving a reverse proxy, the base url generated by the underlying SAML library is not consistent with the way it's generated in NextCloud. For example, it may generate `http://` urls instead of `https://` when the SSL Layer is handled by a proxy, even when NextCloud URLGenerator#getAbsoluteURL effectively generates `https://` urls. This change setup SAML library to use the Server Protocol and Server Host as returned by the NextCloud Request object to build SAML urls properly. --- lib/SAMLSettings.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/SAMLSettings.php b/lib/SAMLSettings.php index 39fd10195..6ba6e9f67 100644 --- a/lib/SAMLSettings.php +++ b/lib/SAMLSettings.php @@ -26,6 +26,7 @@ use OCP\IRequest; use OCP\ISession; use OCP\IURLGenerator; +use OneLogin\Saml2\Utils; class SAMLSettings { /** @var IURLGenerator */ @@ -53,6 +54,11 @@ public function __construct(IURLGenerator $urlGenerator, $this->config = $config; $this->request = $request; $this->session = $session; + + Utils::setSelfProtocol($this->request->getServerProtocol()); + Utils::setSelfHost($this->request->getServerHost()); + Utils::setSelfPort(null); + Utils::setProxyVars(true); } /**