public function testCheckMailOrigin()
 {
     $idp = 'https://idp.example.com/idp/test';
     $result = LoginLib::checkMailOrigin($idp, '*****@*****.**');
     $this->assertTrue($result);
     $result = LoginLib::checkMailOrigin($idp, '*****@*****.**');
     $this->assertFalse($result);
 }
示例#2
0
            //user is external
            //crop $mail to fit into display_name column of oc_shibboleth_user
            if (strlen($mail) > 64) {
                $mail = substr($mail, 0, 64);
            }
            //make sure that user entry exists in oc_shibboleth_user
            $loginName = \OCA\user_shibboleth\LoginLib::persistentId2LoginName($persistentId);
            $displayName = $mail;
            if (\OCA\user_shibboleth\DB::loginNameExists($loginName)) {
                //update display name if it has changed since last login
                if ($displayName !== \OCA\user_shibboleth\DB::getDisplayName($loginName)) {
                    \OCA\user_shibboleth\DB::updateDisplayName($loginName, $displayName);
                }
            } else {
                //create a new user account
                $homeDir = \OCA\user_shibboleth\LoginLib::getHomeDirPath($loginName);
                \OCA\user_shibboleth\DB::addUser($loginName, $displayName, $homeDir);
            }
        }
        //perform OC login
        \OC_User::login($loginName, 'irrelevant');
        \OCP\Util::writeLog('user_shibboleth', 'Login ' . $loginName, \OCP\Util::DEBUG);
    } else {
        //not authenticated, yet
        //follow shibboleth authentication procedure
        $location = $sessionsHandlerUrl . $sessionInitiatorLocation . '?target=' . \OCA\user_shibboleth\LoginLib::getForwardingPageUrl();
    }
} else {
    \OCP\Util::writeLog('user_shibboleth', 'backend not enabled or not configured', \OCP\Util::INFO);
}
header('Location: ' . $location);