| | @@ -1371,10 +1371,11 @@ |
| 1371 | 1371 | ** g.zLogin Database USER.LOGIN value. NULL for user "nobody" |
| 1372 | 1372 | ** g.perm Permissions granted to this user |
| 1373 | 1373 | ** g.anon Permissions that would be available to anonymous |
| 1374 | 1374 | ** g.isRobot True if the client is known to be a spider or robot |
| 1375 | 1375 | ** g.perm Populated based on user account's capabilities |
| 1376 | +** g.eAuthMethod The mechanism used for authentication |
| 1376 | 1377 | ** |
| 1377 | 1378 | */ |
| 1378 | 1379 | void login_check_credentials(void){ |
| 1379 | 1380 | int uid = 0; /* User id */ |
| 1380 | 1381 | const char *zCookie; /* Text of the login cookie */ |
| | @@ -1411,10 +1412,11 @@ |
| 1411 | 1412 | } |
| 1412 | 1413 | g.zLogin = db_text("?", "SELECT login FROM user WHERE uid=%d", uid); |
| 1413 | 1414 | zCap = "sxy"; |
| 1414 | 1415 | g.noPswd = 1; |
| 1415 | 1416 | g.isRobot = 0; |
| 1417 | + g.eAuthMethod = AUTH_LOCAL; |
| 1416 | 1418 | zSeed = db_text("??", "SELECT uid||quote(login)||quote(pw)||quote(cookie)" |
| 1417 | 1419 | " FROM user WHERE uid=%d", uid); |
| 1418 | 1420 | login_create_csrf_secret(zSeed); |
| 1419 | 1421 | fossil_free(zSeed); |
| 1420 | 1422 | } |
| | @@ -1490,10 +1492,11 @@ |
| 1490 | 1492 | " AND octet_length(cap)>0" |
| 1491 | 1493 | " AND octet_length(pw)>0"); |
| 1492 | 1494 | } |
| 1493 | 1495 | } |
| 1494 | 1496 | } |
| 1497 | + if( uid ) g.eAuthMethod = AUTH_COOKIE; |
| 1495 | 1498 | login_create_csrf_secret(zHash); |
| 1496 | 1499 | } |
| 1497 | 1500 | |
| 1498 | 1501 | /* If no user found and the REMOTE_USER environment variable is set, |
| 1499 | 1502 | ** then accept the value of REMOTE_USER as the user. |
| | @@ -1502,19 +1505,21 @@ |
| 1502 | 1505 | const char *zRemoteUser = P("REMOTE_USER"); |
| 1503 | 1506 | if( zRemoteUser && db_get_boolean("remote_user_ok",0) ){ |
| 1504 | 1507 | uid = db_int(0, "SELECT uid FROM user WHERE login=%Q" |
| 1505 | 1508 | " AND octet_length(cap)>0 AND octet_length(pw)>0", |
| 1506 | 1509 | zRemoteUser); |
| 1510 | + if( uid ) g.eAuthMethod = AUTH_ENV; |
| 1507 | 1511 | } |
| 1508 | 1512 | } |
| 1509 | 1513 | |
| 1510 | 1514 | /* If the request didn't provide a login cookie or the login cookie didn't |
| 1511 | 1515 | ** match a known valid user, check the HTTP "Authorization" header and |
| 1512 | 1516 | ** see if those credentials are valid for a known user. |
| 1513 | 1517 | */ |
| 1514 | 1518 | if( uid==0 && db_get_boolean("http_authentication_ok",0) ){ |
| 1515 | 1519 | uid = login_basic_authentication(zIpAddr); |
| 1520 | + if( uid ) g.eAuthMethod = AUTH_HTTP; |
| 1516 | 1521 | } |
| 1517 | 1522 | |
| 1518 | 1523 | /* Check for magic query parameters "resid" (for the username) and |
| 1519 | 1524 | ** "token" for the password. Both values (if they exist) will be |
| 1520 | 1525 | ** obfuscated. |
| | @@ -1529,10 +1534,11 @@ |
| 1529 | 1534 | " WHERE login=%Q" |
| 1530 | 1535 | " AND (constant_time_cmp(pw,%Q)=0" |
| 1531 | 1536 | " OR constant_time_cmp(pw,%Q)=0)", |
| 1532 | 1537 | zUsr, zSha1Pw, zPW); |
| 1533 | 1538 | fossil_free(zSha1Pw); |
| 1539 | + if( uid ) g.eAuthMethod = AUTH_PW; |
| 1534 | 1540 | } |
| 1535 | 1541 | } |
| 1536 | 1542 | |
| 1537 | 1543 | /* If no user found yet, try to log in as "nobody" */ |
| 1538 | 1544 | if( uid==0 ){ |
| 1539 | 1545 | |