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;
}
// 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
// bit hacky and won't necessarily detect all situations.
$currentUrl = substr(explode('?',$request->getRequestUri(), 2)[0], strlen(\OC::$WEBROOT));
if(($currentUrl === '/index.php') && !OC_User::isLoggedIn()) {
$csrfToken = \OC::$server->getCsrfTokenManager()->getToken();
header('Location: '.$urlGenerator->linkToRouteAbsolute('user_saml.SAML.login') .'?requesttoken='. urlencode($csrfToken->getEncryptedValue()));
exit();
// bit hacky and won't necessarily detect all situations. So we inject some magic
// Javascript that does the work for us.
if(!OC_User::isLoggedIn()) {
\OCP\Util::addHeader('script', ['src' => $urlGenerator->linkTo('user_saml', 'js/preauth.js')], '');
}
// 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
// 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(!OC_User::isLoggedIn() && $request->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_OWNCLOUD_DESKTOP])) {
$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);
}