Changeset 522706
- Timestamp:
- 03/23/2012 04:03:03 PM (14 years ago)
- Location:
- http-authentication/trunk
- Files:
-
- 3 edited
-
http-authentication.php (modified) (5 diffs)
-
options-page.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
http-authentication/trunk/http-authentication.php
r522675 r522706 12 12 13 13 class HTTPAuthenticationPlugin { 14 var $db_version = 1;14 var $db_version = 2; 15 15 var $option_name = 'http_authentication_options'; 16 16 var $options; … … 59 59 'login_uri' => htmlspecialchars_decode(wp_login_url()), 60 60 'logout_uri' => remove_query_arg('_wpnonce', htmlspecialchars_decode(wp_logout_url())), 61 'additional_server_keys' => '', 61 62 'auto_create_user' => false, 62 63 'auto_create_email_domain' => '', … … 77 78 <style type="text/css"> 78 79 p#http-authentication-link { 79 width: 100%;80 height: 4em;81 text-align: center;82 margin-top: 2em;80 width: 100%; 81 height: 4em; 82 text-align: center; 83 margin-top: 2em; 83 84 } 84 85 p#http-authentication-link a { 85 margin: 0 auto;86 float: none;86 margin: 0 auto; 87 float: none; 87 88 } 88 89 </style> … … 174 175 $username = ''; 175 176 176 foreach (array('REMOTE_USER', 'REDIRECT_REMOTE_USER') as $key) { 177 if (! empty($_SERVER[$key])) { 178 $username = $_SERVER[$key]; 177 $server_keys = $this->_get_server_keys(); 178 foreach ($server_keys as $server_key) { 179 if (! empty($_SERVER[$server_key])) { 180 $username = $_SERVER[$server_key]; 179 181 } 180 182 } 181 183 182 184 if (! $username) { 183 return new WP_Error('empty_username', '<strong>ERROR</strong>: No REMOTE_USER or REDIRECT_REMOTE_USER found.');185 return new WP_Error('empty_username', '<strong>ERROR</strong>: No user found in server variables.'); 184 186 } 185 187 … … 197 199 198 200 return $user; 201 } 202 203 /* 204 * Return the list of $_SERVER keys that we will check for a username. By 205 * default, these are REMOTE_USER and REDIRECT_REMOTE_USER. Additional keys 206 * can be configured from the options page. 207 */ 208 function _get_server_keys() { 209 $server_keys = array('REMOTE_USER', 'REDIRECT_REMOTE_USER'); 210 211 $additional_server_keys = $this->options['additional_server_keys']; 212 if (! empty($additional_server_keys)) { 213 $keys = preg_split('/,\s*/', $additional_server_keys); 214 $server_keys = array_merge($server_keys, $keys); 215 } 216 217 return $server_keys; 199 218 } 200 219 -
http-authentication/trunk/options-page.php
r515095 r522706 30 30 add_settings_field('http_authentication_login_uri', 'Login URI', array(&$this, '_display_option_login_uri'), $this->page, $section); 31 31 add_settings_field('http_authentication_logout_uri', 'Logout URI', array(&$this, '_display_option_logout_uri'), $this->page, $section); 32 add_settings_field('http_authentication_additional_server_keys', '$_SERVER variables', array(&$this, '_display_option_additional_server_keys'), $this->page, $section); 32 33 add_settings_field('http_authentication_auto_create_user', 'Automatically create accounts?', array(&$this, '_display_option_auto_create_user'), $this->page, $section); 33 34 add_settings_field('http_authentication_auto_create_email_domain', 'Email address domain', array(&$this, '_display_option_auto_create_email_domain'), $this->page, $section); … … 140 141 141 142 /* 143 * Display the additional $_SERVER keys field. 144 */ 145 function _display_option_additional_server_keys() { 146 $additional_server_keys = $this->options['additional_server_keys']; 147 $this->_display_input_text_field('additional_server_keys', $additional_server_keys); 148 ?> 149 <code>$_SERVER</code> variables in addition to <code>REMOTE_USER</code> and <code>REDIRECT_REMOTE_USER</code> to check for the username value, separated by a comma. Use this to e.g. support personal X.509 certificates for authentication.<br /> 150 Example: <code>SSL_CLIENT_S_DN_CN</code> 151 <?php 152 } 153 154 /* 142 155 * Display the automatically create accounts checkbox. 143 156 */ -
http-authentication/trunk/readme.txt
r522705 r522706 140 140 * Avoid some PHP notices due to saving options (William Schneider) 141 141 * Fix for redirect loop on some multisite setups (#1497) 142 * Add option to support additional $_SERVER variables in authentication (#1477) 142 143 143 144 = 4.4 =
Note: See TracChangeset
for help on using the changeset viewer.