Skip to content

Commit f293513

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 f293513

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/SAMLSettings.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
use OCP\IRequest;
2727
use OCP\ISession;
2828
use OCP\IURLGenerator;
29-
use OneLogin\Saml2\Constants;
29+
use OneLogin\Saml2\Utils;
3030

3131
class SAMLSettings {
3232
/** @var IURLGenerator */
@@ -54,6 +54,11 @@ public function __construct(IURLGenerator $urlGenerator,
5454
$this->config = $config;
5555
$this->request = $request;
5656
$this->session = $session;
57+
58+
Utils::setSelfProtocol($this->request->getServerProtocol());
59+
Utils::setSelfHost($this->request->getServerHost());
60+
Utils::setSelfPort(null);
61+
Utils::setProxyVars(true);
5762
}
5863

5964
/**

0 commit comments

Comments
 (0)