Add workaround for stable9 non-stable entry URL

This commit is contained in:
Lukas Reschke 2016-06-30 00:31:11 +02:00
parent b9a157e36d
commit 1abff7050e
No known key found for this signature in database
GPG key ID: 9AB0ADB949B6898C
2 changed files with 9 additions and 7 deletions

View file

@ -50,19 +50,17 @@ try {
return; return;
} }
// Redirect all requests to the login page to the SAML login
// Since with Nextcloud 9 we don't have an unique entry point this is a little // Since with Nextcloud 9 we don't have an unique entry point this is a little
// bit hacky and won't necessarily detect all situations. // bit hacky and won't necessarily detect all situations. So we inject some magic
$currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT)); // Javascript that does the work for us.
if(($currentUrl === '/index.php') && !OC_User::isLoggedIn()) { if(!OC_User::isLoggedIn()) {
$csrfToken = \OC::$server->getCsrfTokenManager()->getToken(); \OCP\Util::addHeader('script', ['src' => $urlGenerator->linkTo('user_saml', 'js/preauth.js')], '');
header('Location: '.$urlGenerator->linkToRouteAbsolute('user_saml.SAML.login') .'?requesttoken='. urlencode($csrfToken->getEncryptedValue()));
exit();
} }
// If a request to OCS or remote.php is sent by the official desktop clients it can // If a request to OCS or remote.php is sent by the official desktop clients it can
// be intercepted as it supports SAML. All other clients don't yet and thus we // be intercepted as it supports SAML. All other clients don't yet and thus we
// require the usage of application specific passwords there. // require the usage of application specific passwords there.
$currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT));
if(substr($currentUrl, 0, 12) === '/remote.php/' || substr($currentUrl, 0, 5) === '/ocs/') { if(substr($currentUrl, 0, 12) === '/remote.php/' || substr($currentUrl, 0, 5) === '/ocs/') {
if(!OC_User::isLoggedIn() && $request->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_OWNCLOUD_DESKTOP])) { if(!OC_User::isLoggedIn() && $request->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_OWNCLOUD_DESKTOP])) {
$csrfToken = \OC::$server->getCsrfTokenManager()->getToken(); $csrfToken = \OC::$server->getCsrfTokenManager()->getToken();

4
js/preauth.js Normal file
View file

@ -0,0 +1,4 @@
if(typeof OC.Login !== "undefined") {
// Redirect to login page
window.location = OC.generateUrl('/apps/user_saml/saml/login')+'?requesttoken='+encodeURIComponent(OC.requestToken);
}