Changeset 26605 for extensions/oAuth/include/functions.inc.php
- Timestamp:
- Jan 11, 2014, 1:27:14 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/oAuth/include/functions.inc.php
r26604 r26605 25 25 function oauth_assign_template_vars($u_redirect=null) 26 26 { 27 global $template, $conf, $hybridauth_conf ;27 global $template, $conf, $hybridauth_conf, $user; 28 28 29 29 $conf['oauth']['include_common_template'] = true; … … 31 31 if ($template->get_template_vars('OAUTH') == null) 32 32 { 33 if (!empty($user['oauth_id'])) 34 { 35 list($provider, $identifier) = explode('---', $user['oauth_id'], 2); 36 if ($provider == 'Persona') 37 { 38 $persona_email = $identifier; 39 } 40 } 41 33 42 $template->assign('OAUTH', array( 34 43 'conf' => $conf['oauth'], 35 44 'u_login' => get_root_url() . OAUTH_PATH . 'auth.php?provider=', 36 45 'providers' => $hybridauth_conf['providers'], 46 'persona_email' => @$persona_email, 37 47 )); 38 48 $template->assign(array( … … 70 80 } 71 81 } 82 83 // http://www.sitepoint.com/authenticate-users-with-mozilla-persona/ 84 function persona_verify() 85 { 86 $url = 'https://verifier.login.persona.org/verify'; 87 88 $assert = filter_input( 89 INPUT_POST, 90 'assertion', 91 FILTER_UNSAFE_RAW, 92 FILTER_FLAG_STRIP_LOW|FILTER_FLAG_STRIP_HIGH 93 ); 94 95 $scheme = 'http'; 96 if ( (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ) 97 { 98 $scheme = 'https'; 99 } 100 $audience = sprintf( 101 '%s://%s:%s', 102 $scheme, 103 $_SERVER['HTTP_HOST'], 104 $_SERVER['SERVER_PORT'] 105 ); 106 107 $params = 'assertion=' . urlencode($assert) . '&audience=' . urlencode($audience); 108 109 $options = array( 110 CURLOPT_URL => $url, 111 CURLOPT_RETURNTRANSFER => true, 112 CURLOPT_POST => true, 113 CURLOPT_POSTFIELDS => $params, 114 CURLOPT_SSL_VERIFYPEER => true, 115 CURLOPT_SSL_VERIFYHOST => 2, 116 ); 117 118 $ch = curl_init(); 119 curl_setopt_array($ch, $options); 120 $result = curl_exec($ch); 121 curl_close($ch); 122 123 if ($result === false) 124 { 125 return false; 126 } 127 else 128 { 129 return json_decode($result, true); 130 } 131 }
Note: See TracChangeset
for help on using the changeset viewer.