mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[Feature] Ability to use HTTP authentication in ATOM feeds by passing the GET parameter auth=http
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10430 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -267,6 +267,7 @@ class acp_board
|
||||
'legend1' => 'ACP_FEED_GENERAL',
|
||||
'feed_enable' => array('lang' => 'ACP_FEED_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true ),
|
||||
'feed_item_statistics' => array('lang' => 'ACP_FEED_ITEM_STATISTICS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true),
|
||||
'feed_http_auth' => array('lang' => 'ACP_FEED_HTTP_AUTH', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true),
|
||||
|
||||
'legend2' => 'ACP_FEED_POST_BASED',
|
||||
'feed_limit_post' => array('lang' => 'ACP_FEED_LIMIT', 'validate' => 'int:5', 'type' => 'text:3:4', 'explain' => true),
|
||||
|
@@ -3920,6 +3920,103 @@ function phpbb_optionset($bit, $set, $data)
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Login using http authenticate.
|
||||
*
|
||||
* @param array $param Parameter array, see $param_defaults array.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function phpbb_http_login($param)
|
||||
{
|
||||
global $auth, $user;
|
||||
global $config;
|
||||
|
||||
$param_defaults = array(
|
||||
'auth_message' => '',
|
||||
|
||||
'autologin' => false,
|
||||
'viewonline' => true,
|
||||
'admin' => false,
|
||||
);
|
||||
|
||||
// Overwrite default values with passed values
|
||||
$param = array_merge($param_defaults, $param);
|
||||
|
||||
// User is already logged in
|
||||
// We will not overwrite his session
|
||||
if (!empty($user->data['is_registered']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// $_SERVER keys to check
|
||||
$username_keys = array(
|
||||
'PHP_AUTH_USER',
|
||||
'Authorization',
|
||||
'REMOTE_USER', 'REDIRECT_REMOTE_USER',
|
||||
'HTTP_AUTHORIZATION', 'REDIRECT_HTTP_AUTHORIZATION',
|
||||
'REMOTE_AUTHORIZATION', 'REDIRECT_REMOTE_AUTHORIZATION',
|
||||
'AUTH_USER',
|
||||
);
|
||||
|
||||
$password_keys = array(
|
||||
'PHP_AUTH_PW',
|
||||
'REMOTE_PASSWORD',
|
||||
'AUTH_PASSWORD',
|
||||
);
|
||||
|
||||
$username = null;
|
||||
foreach ($username_keys as $k)
|
||||
{
|
||||
if (isset($_SERVER[$k]))
|
||||
{
|
||||
$username = $_SERVER[$k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$password = null;
|
||||
foreach ($password_keys as $k)
|
||||
{
|
||||
if (isset($_SERVER[$k]))
|
||||
{
|
||||
$password = $_SERVER[$k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Decode encoded information (IIS, CGI, FastCGI etc.)
|
||||
if (!is_null($username) && is_null($password) && strpos($username, 'Basic ') === 0)
|
||||
{
|
||||
list($username, $password) = explode(':', base64_decode(substr($username, 6)), 2);
|
||||
}
|
||||
|
||||
if (!is_null($username) && !is_null($password))
|
||||
{
|
||||
set_var($username, $username, 'string', true);
|
||||
set_var($password, $password, 'string', true);
|
||||
|
||||
$auth_result = $auth->login($username, $password, $param['autologin'], $param['viewonline'], $param['admin']);
|
||||
|
||||
if ($auth_result['status'] == LOGIN_SUCCESS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Prepend sitename to auth_message
|
||||
$param['auth_message'] = ($param['auth_message'] === '') ? $config['sitename'] : $config['sitename'] . ' - ' . $param['auth_message'];
|
||||
|
||||
// We should probably filter out non-ASCII characters - RFC2616
|
||||
$param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']);
|
||||
|
||||
header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
|
||||
trigger_error('NOT_AUTHORISED');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate page header
|
||||
*/
|
||||
|
@@ -350,6 +350,7 @@ class phpbb_questionnaire_phpbb_data_provider
|
||||
'enable_pm_icons' => true,
|
||||
'enable_post_confirm' => true,
|
||||
'feed_enable' => true,
|
||||
'feed_http_auth' => true,
|
||||
'feed_limit_post' => true,
|
||||
'feed_limit_topic' => true,
|
||||
'feed_overall' => true,
|
||||
|
Reference in New Issue
Block a user