Skip to content

Commit ed2b533

Browse files
Toilalblizzz
authored andcommitted
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 4b3b0fe commit ed2b533

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/SAMLSettings.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OCP\ISession;
1515
use OCP\IURLGenerator;
1616
use OneLogin\Saml2\Constants;
17+
use OneLogin\Saml2\Utils;
1718

1819
class SAMLSettings {
1920
private const LOADED_NONE = 0;
@@ -78,6 +79,10 @@ public function __construct(
7879
private ISession $session,
7980
private ConfigurationsMapper $mapper,
8081
) {
82+
Utils::setSelfProtocol($this->request->getServerProtocol());
83+
Utils::setSelfHost($this->request->getServerHost());
84+
Utils::setSelfPort(null);
85+
Utils::setProxyVars(true);
8186
}
8287

8388
/**

0 commit comments

Comments
 (0)