diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2016-11-14 13:54:03 +0300 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-11-14 15:47:30 +0300 |
commit | 314ae475f67051e84b99732d55026550de802552 (patch) | |
tree | f3f82f6397f6f8c4907090e15f2e0090e8890ec7 /appinfo | |
parent | 5855e6e2ccb352ea8aa8637e17c885e21be76e81 (diff) |
Add support for environment variable login
Diffstat (limited to 'appinfo')
-rw-r--r-- | appinfo/app.php | 35 | ||||
-rw-r--r-- | appinfo/info.xml | 7 | ||||
-rw-r--r-- | appinfo/update.php | 6 |
3 files changed, 39 insertions, 9 deletions
diff --git a/appinfo/app.php b/appinfo/app.php index e59d594e..88fd027b 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -21,6 +21,13 @@ require_once __DIR__ . '/../3rdparty/vendor/autoload.php'; +// If we run in CLI mode do not setup the app as it can fail the OCC execution +// since the URLGenerator isn't accessible. +if(OC::$CLI) { + return; +} + + $urlGenerator = \OC::$server->getURLGenerator(); $config = \OC::$server->getConfig(); $request = \OC::$server->getRequest(); @@ -32,7 +39,7 @@ $samlSettings = new \OCA\User_SAML\SAMLSettings( $userBackend = new \OCA\User_SAML\UserBackend( $config, - \OC::$server->getURLGenerator(), + $urlGenerator, \OC::$server->getSession(), \OC::$server->getDb() ); @@ -41,17 +48,33 @@ OC_User::useBackend($userBackend); OC_User::handleApacheAuth(); // Setting up the one login config may fail, if so, do not catch the requests later. -try { - $oneLoginSettings = new \OneLogin_Saml2_Settings($samlSettings->getOneLoginSettingsArray()); -} catch(OneLogin_Saml2_Error $e) { +$returnScript = false; +$type = ''; +switch($config->getAppValue('user_saml', 'type')) { + case 'saml': + try { + $oneLoginSettings = new \OneLogin_Saml2_Settings($samlSettings->getOneLoginSettingsArray()); + } catch (OneLogin_Saml2_Error $e) { + $returnScript = true; + } + $type = 'saml'; + break; + case 'environment-variable': + \OC::$server->getSession()->set('user_saml.samlUserData', $_SERVER); + $type = 'environment-variable'; + break; +} + +if($returnScript === true) { return; } $redirectSituation = false; - // All requests that are not authenticated and match against the "/login" route are // redirected to the SAML login endpoint -if(!$userSession->isLoggedIn() && \OC::$server->getRequest()->getPathInfo() === '/login') { +if(!$userSession->isLoggedIn() && + \OC::$server->getRequest()->getPathInfo() === '/login' && + $type === 'saml') { $redirectSituation = true; } diff --git a/appinfo/info.xml b/appinfo/info.xml index 210d5cd7..96a78ecb 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -1,11 +1,12 @@ <?xml version="1.0"?> <info> <id>user_saml</id> - <name>SAML authentication</name> - <description>Authenticates user against a SAML backend, such as Shibboleth.</description> + <name>SSO & SAML authentication</name> + <description>Authenticates user against a SAML backend, such as Shibboleth or + other SSO solutions such as Kerberos.</description> <licence>AGPL</licence> <author>Lukas Reschke</author> - <version>1.2.1</version> + <version>1.2.2</version> <dependencies> <owncloud min-version="9.1" max-version="9.2" /> </dependencies> diff --git a/appinfo/update.php b/appinfo/update.php index 4900f20b..ecf28c95 100644 --- a/appinfo/update.php +++ b/appinfo/update.php @@ -28,3 +28,9 @@ $installedVersion = $config->getAppValue('user_saml', 'installed_version'); if (version_compare($installedVersion, '1.2.1', '<')) { $config->setAppValue('user_saml', 'general-use_saml_auth_for_desktop', '1'); } + +// Versions below 1.2.2 don't have the choice between environment variable or +// native SAML integration as the default was SAML back then. +if (version_compare($installedVersion, '1.2.2', '<')) { + $config->setAppValue('user_saml', 'type', 'saml'); +} |