/**
 * Displays the XRDS document for this SimpleID installation.
 * 
 */
function simpleid_xrds()
{
    global $xtpl;
    log_debug('Providing XRDS.');
    header('Content-Type: application/xrds+xml');
    header('Content-Disposition: inline; filename=yadis.xml');
    $types = extension_invoke_all('xrds_types');
    foreach ($types as $type) {
        $xtpl->assign('uri', htmlspecialchars($type, ENT_QUOTES, 'UTF-8'));
        $xtpl->parse('xrds.op_xrds.type');
    }
    $xtpl->assign('simpleid_base_url', htmlspecialchars(simpleid_url(), ENT_QUOTES, 'UTF-8'));
    $xtpl->parse('xrds.op_xrds');
    $xtpl->parse('xrds');
    $xtpl->out('xrds');
}
Example #2
0
 /**
  * Provides a form for user consent of an OpenID relying party, where the 
  * {@link simpleid_checkid_identity()} function returns a CHECKID_APPROVAL_REQUIRED
  * or CHECKID_RETURN_TO_SUSPECT.
  *
  * Alternatively, provide a form for the user to rectify the situation where
  * {@link simpleid_checkid_identity()} function returns a CHECKID_IDENTITIES_NOT_MATCHING
  * or CHECKID_IDENTITY_NOT_EXIST
  *
  * @param Request $request the original OpenID request
  * @param Response $response the proposed OpenID response, subject to user
  * verification
  * @param int $reason either CHECKID_APPROVAL_REQUIRED, CHECKID_RETURN_TO_SUSPECT,
  * CHECKID_IDENTITIES_NOT_MATCHING or CHECKID_IDENTITY_NOT_EXIST
  */
 protected function consentForm($request, $response, $reason = self::CHECKID_APPROVAL_REQUIRED)
 {
     $tpl = new \Template();
     $form_state = array('rq' => $request, 'rs' => $response, 'code' => $reason);
     $cancel = $response['mode'] == 'cancel';
     $realm = $request->getRealm();
     if ($cancel) {
         $this->f3->set('unable_label', t('Unable to log into <strong class="realm">@realm</strong>.', array('@realm' => $realm)));
         $this->f3->set('identity_not_matching_label', t('Your current identity does not match the requested identity %identity.', array('%identity' => $request['openid.identity'])));
         $this->f3->set('switch_user_label', t('<a href="!url">Switch to a different user</a> and try again.', array('!url' => simpleid_url('logout', 'destination=continue&s=' . rawurlencode($request_state), true))));
     } else {
         $base_path = $this->f3->get('base_path');
         $form_state['prefs'] = isset($user_clients[$realm]) ? $user_clients[$realm] : array();
         $forms = $this->mgr->invokeAll('openIDConsentForm', $form_state);
         uasort($forms, function ($a, $b) {
             if ($a['weight'] == $b['weight']) {
                 return 0;
             }
             return $a['weight'] < $b['weight'] ? -1 : 1;
         });
         $this->f3->set('forms', $forms);
         if ($reason == self::CHECKID_RETURN_TO_SUSPECT) {
             $this->f3->set('return_to_suspect', true);
             $this->f3->set('suspect_label', t('Warning: This web site has not confirmed its identity and might be fraudulent.  Do not share any personal information with this web site unless you are sure it is legitimate. See the <a href="!url" class="popup">SimpleID documentation for details</a> (OpenID version 2.0 return_to discovery failure)', array('!url' => 'http://simpleid.koinic.net/documentation/troubleshooting/returnto-discovery-failure')));
             $this->f3->set('js_locale', array('openid_suspect' => addslashes(t('This web site has not confirmed its identity and might be fraudulent.')) . '\\n\\n' . addslashes(t('Are you sure you wish to automatically send your information to this site for any future requests?'))));
             $this->f3->set('realm_class', 'return-to-suspect');
         }
         $this->f3->set('realm_label', $this->t('You are being logged into <strong class="realm">@realm</strong>.', array('@realm' => $realm)));
         $this->f3->set('openid_consent_label', $this->t('Automatically send my information to this site for any future requests.'));
         $this->f3->set('ok_button', $this->t('OK'));
     }
     $token = new SecurityToken();
     $this->f3->set('tk', $token->generate('openid_consent', SecurityToken::OPTION_BIND_SESSION));
     $this->f3->set('fs', $token->generate($form_state));
     $this->f3->set('cancel', $cancel);
     $this->f3->set('cancel_button', $this->t('Cancel'));
     $this->f3->set('logout_destination', '/continue/' . rawurlencode($token->generate($request->toArray())));
     $this->f3->set('user_header', true);
     $this->f3->set('framekiller', true);
     $this->f3->set('title', $this->t('OpenID Login'));
     $this->f3->set('page_class', 'dialog-page');
     $this->f3->set('layout', 'openid_consent.html');
     header('X-Frame-Options: DENY');
     print $tpl->render('page.html');
 }