4 * @property CI_Config $config
6 class Test extends CI_Controller {
10 parent::__construct();
12 $this->lang->load('openid', 'english');
13 $this->load->library('openid');
14 $this->load->helper('url');
15 //$this->output->enable_profiler(TRUE);
21 if ($this->input->post('action') == 'verify')
23 $user_id = $this->input->post('openid_identifier');
24 $pape_policy_uris = $this->input->post('policies');
26 if (!$pape_policy_uris)
28 $pape_policy_uris = array();
31 $this->config->load('openid');
32 $req = $this->config->item('openid_required');
33 $opt = $this->config->item('openid_optional');
34 $policy = site_url($this->config->item('openid_policy'));
35 $request_to = site_url($this->config->item('openid_request_to'));
37 $this->openid->set_request_to($request_to);
38 $this->openid->set_trust_root(base_url());
39 $this->openid->set_args(null);
40 $this->openid->set_sreg(true, $req, $opt, $policy);
41 $this->openid->set_pape(true, $pape_policy_uris);
42 $this->openid->authenticate($user_id);
46 $data['pape_policy_uris'] = array(
47 PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
48 PAPE_AUTH_MULTI_FACTOR,
49 PAPE_AUTH_PHISHING_RESISTANT
52 $this->load->view('view_openid', $data);
59 $this->load->view('openid_policy_view');
63 function _set_message($msg, $val = '', $sub = '%s')
65 return str_replace($sub, $val, $this->lang->line($msg));
71 $this->config->load('openid');
72 $request_to = site_url($this->config->item('openid_request_to'));
74 $this->openid->set_request_to($request_to);
75 $response = $this->openid->getResponse();
77 switch ($response->status)
79 case Auth_OpenID_CANCEL:
80 $data['msg'] = $this->lang->line('openid_cancel');
82 case Auth_OpenID_FAILURE:
83 $data['error'] = $this->_set_message('openid_failure', $response->message);
85 case Auth_OpenID_SUCCESS:
86 $openid = $response->getDisplayIdentifier();
87 $esc_identity = htmlspecialchars($openid, ENT_QUOTES);
89 $data['success'] = $this->_set_message('openid_success', array($esc_identity, $esc_identity), array('%s', '%t'));
91 if ($response->endpoint->canonicalID)
93 $data['success'] .= $this->_set_message('openid_canonical', $response->endpoint->canonicalID);
96 $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
97 $sreg = $sreg_resp->contents();
99 foreach ($sreg as $key => $value)
101 $data['success'] .= $this->_set_message('openid_content', array($key, $value), array('%s', '%t'));
104 $pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
108 if ($pape_resp->auth_policies)
110 $data['success'] .= $this->lang->line('openid_pape_policies_affected');
112 foreach ($pape_resp->auth_policies as $uri)
114 $data['success'] .= "<li><tt>$uri</tt></li>";
117 $data['success'] .= "</ul>";
121 $data['success'] .= $this->lang->line('openid_pape_not_affected');
124 if (isset($pape_resp->auth_age) && $pape_resp->auth_age)
126 $data['success'] .= $this->_set_message('openid_auth_age', $pape_resp->auth_age);
129 if ($pape_resp->nist_auth_level)
131 $data['success'] .= $this->_set_message('openid_nist_level', $pape_resp->nist_auth_level);
136 $data['success'] .= $this->lang->line('openid_pape_noresponse');
141 $data['pape_policy_uris'] = array(
142 PAPE_AUTH_MULTI_FACTOR_PHYSICAL,
143 PAPE_AUTH_MULTI_FACTOR,
144 PAPE_AUTH_PHISHING_RESISTANT
147 // echo "nickname: $nickname";
148 // echo "esc_identity: $esc_identity";
150 $this->load->view('view_openid', $data);