consumer_keys[$consumer_key]['allow_domain_override']; $domain = $this->consumer_keys[$consumer_key]['domain']; if (!$username) { throw new InvalidArgumentException('user_id must not be empty'); } if ($domain === null) { $domain = $consumer_key; } if ($override && strpos($username, '@') !== false) { list($username, $domain) = explode('@', $username); } if ($domain !== '') { $username .= '@' . $domain; $this->domain = $domain; } return $this->username = parent::verifyUsername($username); } /** * Check whether this user can be authenticated. Since we trust the user * information sent by the LTI consumer, only the OAuth signature is checked. * * @param string $username account name * @param string $password (ignored) * * @return bool true if authentication succeeds * */ public function isAuthenticated($username, $password) { $consumer_key = Request::get('oauth_consumer_key'); $consumer_secret = $this->consumer_keys[$consumer_key]['consumer_secret']; if (!Studip\OAuth1::verifyRequest($this->getPsrRequest(), $consumer_secret, '')) { return false; } return parent::isAuthenticated($username, $password); } /** * Authenticate this user and handle auto enrollment. If the URL parameter * "sem_id" is set, the user is automatically redircted to the enrollment * action for this course. * * @param string $username the username to check * @param string $password the password (ignored) * * @return mixed if authentication succeeds: the Stud.IP user, else false */ public function authenticateUser($username, $password) { $user = parent::authenticateUser($username, $password); $course_id = Request::option('sem_id'); if ($user && $course_id) { header('Location: ' . URLHelper::getURL('dispatch.php/lti/index/' . $course_id)); } return $user; } /** * Return the current username of the pending authentication request. */ public function getUser() { return $this->username; } /** * Get the user domains to assign to the current user (if any). * * @return array array of user domain names */ public function getUserDomains() { return $this->domain ? [$this->domain] : null; } /** * Callback that can be used in user_data_mapping array. For LTI, this is * equivalent to Request::get(), since all launch data is POST parameters. * @see http://www.imsglobal.org/specs/ltiv1p1/implementation-guide * * @param string key (e.g. "lis_person_contact_email_primary") * * @return string parameter value (null if not set) */ public function getUserData($key) { return Request::get($key); } }