Skip to content

Commit 5717612

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 5717612

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
@@ -11,9 +11,11 @@
1111
use OCA\User_SAML\Db\ConfigurationsMapper;
1212
use OCP\DB\Exception;
1313
use OCP\IConfig;
14+
use OCP\IRequest;
1415
use OCP\ISession;
1516
use OCP\IURLGenerator;
1617
use OneLogin\Saml2\Constants;
18+
use OneLogin\Saml2\Utils;
1719

1820
class SAMLSettings {
1921
private const LOADED_NONE = 0;
@@ -77,7 +79,11 @@ public function __construct(
7779
private IConfig $config,
7880
private ISession $session,
7981
private ConfigurationsMapper $mapper,
82+
private IRequest $request,
8083
) {
84+
Utils::setSelfProtocol($this->request->getServerProtocol());
85+
Utils::setSelfHost($this->request->getServerHost());
86+
Utils::setProxyVars(true);
8187
}
8288

8389
/**

0 commit comments

Comments
 (0)