File inc/user.inc.php changed (mode: 100644) (index a78b788..91ff189) |
... |
... |
function rg_user_http_git($db, $rg, $paras) |
2222 |
2222 |
header('Cache-Control: no-cache, max-age=0, must-revalidate'); |
header('Cache-Control: no-cache, max-age=0, must-revalidate'); |
2223 |
2223 |
header('Content-Type: text/plain'); |
header('Content-Type: text/plain'); |
2224 |
2224 |
|
|
2225 |
|
// if user is valid, retry auth |
|
2226 |
|
// if user is not valid, consider anonymous |
|
|
2225 |
|
// If user is valid, retry auth. |
|
2226 |
|
// If user is not valid, consider anonymous. |
2227 |
2227 |
$authd = FALSE; |
$authd = FALSE; |
2228 |
2228 |
$u = ''; |
$u = ''; |
2229 |
|
$empty_user = TRUE; |
|
|
2229 |
|
$no_user_provided = TRUE; |
2230 |
2230 |
$auth_ui = rg_user_empty(); |
$auth_ui = rg_user_empty(); |
2231 |
2231 |
while (isset($_SERVER['PHP_AUTH_USER']) |
while (isset($_SERVER['PHP_AUTH_USER']) |
2232 |
2232 |
&& isset($_SERVER['PHP_AUTH_PW'])) { |
&& isset($_SERVER['PHP_AUTH_PW'])) { |
|
... |
... |
function rg_user_http_git($db, $rg, $paras) |
2234 |
2234 |
$p = $_SERVER['PHP_AUTH_PW']; |
$p = $_SERVER['PHP_AUTH_PW']; |
2235 |
2235 |
rg_log('DEBUG: HTTP auth: u=' . $u); |
rg_log('DEBUG: HTTP auth: u=' . $u); |
2236 |
2236 |
|
|
2237 |
|
if (empty($u)) |
|
2238 |
|
break; |
|
2239 |
|
if (strcasecmp($u, 'guest') == 0) { |
|
|
2237 |
|
$no_user_provided = FALSE; |
|
2238 |
|
|
|
2239 |
|
if (strcasecmp($u, 'guest') == 0) |
2240 |
2240 |
$u = ''; |
$u = ''; |
|
2241 |
|
if (empty($u)) |
2241 |
2242 |
break; |
break; |
2242 |
|
} |
|
2243 |
|
|
|
2244 |
|
$empty_user = FALSE; |
|
2245 |
2243 |
|
|
2246 |
2244 |
$auth_ui = rg_user_info($db, 0, $u, ''); |
$auth_ui = rg_user_info($db, 0, $u, ''); |
2247 |
2245 |
if ($auth_ui['ok'] !== 1) { |
if ($auth_ui['ok'] !== 1) { |
|
... |
... |
function rg_user_http_git($db, $rg, $paras) |
2297 |
2295 |
if ($r['allow'] !== 1) { |
if ($r['allow'] !== 1) { |
2298 |
2296 |
rg_log('DEBUG: allow != 1 => 401'); |
rg_log('DEBUG: allow != 1 => 401'); |
2299 |
2297 |
// Connecting user has no rights to push, not even anon. |
// Connecting user has no rights to push, not even anon. |
2300 |
|
// The user be authed at this point, but may try another |
|
|
2298 |
|
// The user may be authed at this point, but may try another |
2301 |
2299 |
// user/pass combination. |
// user/pass combination. |
2302 |
2300 |
header($protocol . ' 401 Unauthorized status'); |
header($protocol . ' 401 Unauthorized status'); |
2303 |
2301 |
header('WWW-Authenticate: Basic' |
header('WWW-Authenticate: Basic' |
|
... |
... |
function rg_user_http_git($db, $rg, $paras) |
2309 |
2307 |
} |
} |
2310 |
2308 |
|
|
2311 |
2309 |
rg_log('DEBUG: push_allowed=' . $r['push_allowed'] |
rg_log('DEBUG: push_allowed=' . $r['push_allowed'] |
2312 |
|
. ' empty_user=' . ($empty_user ? 'yes' : 'no') |
|
|
2310 |
|
. ' no_user_provided=' . ($no_user_provided ? 'yes' : 'no') |
2313 |
2311 |
. ' authd=' . ($authd['ok'] === 1 ? 'yes' : 'no') |
. ' authd=' . ($authd['ok'] === 1 ? 'yes' : 'no') |
2314 |
2312 |
. ' exists=' . $auth_ui['exists'] |
. ' exists=' . $auth_ui['exists'] |
2315 |
2313 |
. ' push=' . $r['push']); |
. ' push=' . $r['push']); |
|
... |
... |
function rg_user_http_git($db, $rg, $paras) |
2318 |
2316 |
// If user is correct, but password is not, we will ask |
// If user is correct, but password is not, we will ask |
2319 |
2317 |
// the user to try again. If user is not correct, |
// the user to try again. If user is not correct, |
2320 |
2318 |
// we will go on with anon push access. |
// we will go on with anon push access. |
2321 |
|
if ($empty_user |
|
|
2319 |
|
if ($no_user_provided |
2322 |
2320 |
|| (($authd['ok'] !== 1) && ($auth_ui['exists'] == 1))) { |
|| (($authd['ok'] !== 1) && ($auth_ui['exists'] == 1))) { |
2323 |
2321 |
rg_log('DEBUG: send 401'); |
rg_log('DEBUG: send 401'); |
2324 |
2322 |
header($protocol . ' 401 Unauthorized status'); |
header($protocol . ' 401 Unauthorized status'); |