Skip to content

Commit 17a24e5

Browse files
committed
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. Signed-off-by: Rémi Alvergnat <[email protected]>
1 parent 83ca392 commit 17a24e5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/SAMLSettings.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OCP\ISession;
2828
use OCP\IURLGenerator;
2929
use OneLogin\Saml2\Constants;
30+
use OneLogin\Saml2\Utils;
3031

3132
class SAMLSettings {
3233
/** @var IURLGenerator */
@@ -54,6 +55,11 @@ public function __construct(IURLGenerator $urlGenerator,
5455
$this->config = $config;
5556
$this->request = $request;
5657
$this->session = $session;
58+
59+
Utils::setSelfProtocol($this->request->getServerProtocol());
60+
Utils::setSelfHost($this->request->getServerHost());
61+
Utils::setSelfPort(null);
62+
Utils::setProxyVars(true);
5763
}
5864

5965
/**

0 commit comments

Comments
 (0)