Skip to content

Commit

Permalink
Support reverse proxy the NextCloud way
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Toilal committed Apr 5, 2019
1 parent 7dd7c45 commit 9c2773d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/SAMLSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
use OneLogin\Saml2\Utils;

class SAMLSettings {
/** @var IURLGenerator */
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 9c2773d

Please sign in to comment.