Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch restricted-self-registration Excluding Merge-Ins
This is equivalent to a diff from 15e15298f8 to 6faaa91b37
|
2020-04-24
| ||
| 05:21 | Add the ability to restrict subscriptions to specific email domains selected by GLOB patterns, and to require email verification before self-registration becomes effective. check-in: c00e9123cb user: drh tags: trunk | |
| 05:10 | Improvements to the wording on the setup options related to self-registration. Closed-Leaf check-in: 6faaa91b37 user: drh tags: restricted-self-registration | |
| 02:17 | Add a new setting to disallow anonymous subscriptions. Anonymous subscriptions are enabled by default. check-in: d048d86d0d user: drh tags: restricted-self-registration | |
|
2020-04-23
| ||
| 23:00 | Merge the /subscribe fix from trunk. check-in: fb38b92501 user: drh tags: restricted-self-registration | |
| 22:17 | Fix bugs in the /subscribe page that could allow an attacker to subscribe and verify without actually having a working email address. check-in: 15e15298f8 user: drh tags: trunk | |
| 18:49 | Bug fix: Allow new subscribers the option to select "Forum Edits", though it still defaults to "off". check-in: ea81b30ddf user: drh tags: trunk | |
Changes to src/alerts.c.
| ︙ | |||
1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 | 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 | + + + + + + + + + - + + + + + |
){
const char *zEAddr;
int i, j, n;
char c;
*peErr = 0;
*pzErr = 0;
/* Verify the captcha first */
if( needCaptcha ){
if( !captcha_is_correct(1) ){
*peErr = 2;
*pzErr = mprintf("incorrect security code");
return 0;
}
}
/* Check the validity of the email address.
**
** (1) Exactly one '@' character.
** (2) No other characters besides [a-zA-Z0-9._+-]
**
** The local part is currently more restrictive than RFC 5322 allows:
** https://stackoverflow.com/a/2049510/142454 We will expand this as
** necessary.
*/
zEAddr = P("e");
|
| ︙ | |||
1247 1248 1249 1250 1251 1252 1253 | 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 | - + - - - + + |
}
if( n>i-5 ){
*peErr = 1;
*pzErr = mprintf("email domain too short");
return 0;
}
|
| ︙ | |||
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 | 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 | + + + + |
style_submenu_element("My Subscription","%R/alerts");
}else{
/* Everybody else jumps to the page to administer their own
** account only. */
cgi_redirectf("%R/alerts");
return;
}
}
if( !g.perm.Admin && !db_get_boolean("anon-subscribe",1) ){
register_page();
return;
}
alert_submenu_common();
needCaptcha = !login_is_individual();
if( P("submit")
&& cgi_csrf_safe(1)
&& subscribe_error_check(&eErr,&zErr,needCaptcha)
){
|
| ︙ | |||
1413 1414 1415 1416 1417 1418 1419 | 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 | - + |
@ <p>The following internal error was encountered while trying
@ to send the confirmation email:
@ <blockquote><pre>
@ %h(pSender->zErr)
@ </pre></blockquote>
}else{
@ <p>An email has been sent to "%h(zEAddr)". That email contains a
|
| ︙ | |||
1445 1446 1447 1448 1449 1450 1451 | 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 | + + + + + - + + - + |
@ <td><input type="text" name="e" value="%h(PD("e",""))" size="30"></td>
@ <tr>
if( eErr==1 ){
@ <tr><td><td><span class='loginError'>↑ %h(zErr)</span></td></tr>
}
@ </tr>
if( needCaptcha ){
const char *zInit = "";
if( P("captchaseed")!=0 && eErr!=2 ){
uSeed = strtoul(P("captchaseed"),0,10);
zInit = P("captcha");
}else{
|
| ︙ | |||
1601 1602 1603 1604 1605 1606 1607 | 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 | + - + + + + + - + + - + | const char *sctime; /* Time subscription created */ int eErr = 0; /* Type of error */ char *zErr = 0; /* Error message text */ int sid = 0; /* Subscriber ID */ int nName; /* Length of zName in bytes */ char *zHalfCode; /* prefix of subscriberCode */ db_begin_transaction(); |
| ︙ | |||
1688 1689 1690 1691 1692 1693 1694 | 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 | + - + + - + |
if( P("delete")!=0 && cgi_csrf_safe(1) ){
if( !PB("dodelete") ){
eErr = 9;
zErr = mprintf("Select this checkbox and press \"Unsubscribe\" again to"
" unsubscribe");
}else{
alert_unsubscribe(sid);
db_commit_transaction();
|
| ︙ | |||
1731 1732 1733 1734 1735 1736 1737 | 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 | - - + + + + + + + + + + + + + + + |
sw = strchr(ssub,'w')!=0;
sx = strchr(ssub,'x')!=0;
smip = db_column_text(&q, 5);
mtime = db_column_text(&q, 7);
sctime = db_column_text(&q, 8);
if( !g.perm.Admin && !sverified ){
if( nName==64 ){
|
| ︙ | |||
1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 | 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 | + + | @ <input type="submit" name="delete" value="Unsubscribe"> @ </tr> @ </table> @ </form> fossil_free(zErr); db_finalize(&q); style_footer(); db_commit_transaction(); return; } /* This is the message that gets sent to describe how to change ** or modify a subscription */ static const char zUnsubMsg[] = @ To changes your subscription settings at %s visit this link: |
| ︙ |
Changes to src/capabilities.c.
| ︙ | |||
364 365 366 367 368 369 370 | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | - + |
void capability_summary(void){
Stmt q;
CapabilityString *pCap;
char *zSelfCap;
char *zPubPages = db_get("public-pages",0);
int hasPubPages = zPubPages && zPubPages[0];
|
| ︙ |
Changes to src/login.c.
| ︙ | |||
479 480 481 482 483 484 485 | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | - + |
** to self-registered users.
*/
int login_self_register_available(const char *zNeeded){
CapabilityString *pCap;
int rc;
if( !db_get_boolean("self-register",0) ) return 0;
if( zNeeded==0 ) return 1;
|
| ︙ | |||
1126 1127 1128 1129 1130 1131 1132 | 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 | - + |
*/
zPublicPages = db_get("public-pages",0);
if( zPublicPages!=0 ){
Glob *pGlob = glob_create(zPublicPages);
const char *zUri = PD("REQUEST_URI","");
zUri += (int)strlen(g.zTop);
if( glob_match(pGlob, zUri) ){
|
| ︙ | |||
1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 | 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + - + + + + |
"SELECT 1 FROM user WHERE login=%Q "
"UNION ALL "
"SELECT 1 FROM event WHERE user=%Q OR euser=%Q",
zUserID, zUserID, zUserID
);
return rc;
}
/*
** Check an email address and confirm that it is valid for self-registration.
** The email address is known already to be well-formed. Return true
** if the email address is on the allowed list.
**
** The default behavior is that any valid email address is accepted.
** But if the "auth-sub-email" setting exists and is not empty, then
** it is a comma-separated list of GLOB patterns for email addresses
** that are authorized to self-register.
*/
int authorized_subscription_email(const char *zEAddr){
char *zGlob = db_get("auth-sub-email",0);
Glob *pGlob;
char *zAddr;
int rc;
if( zGlob==0 || zGlob[0]==0 ) return 1;
zGlob = fossil_strtolwr(fossil_strdup(zGlob));
pGlob = glob_create(zGlob);
fossil_free(zGlob);
zAddr = fossil_strtolwr(fossil_strdup(zEAddr));
rc = glob_match(pGlob, zAddr);
fossil_free(zAddr);
glob_free(pGlob);
return rc!=0;
}
/*
** WEBPAGE: register
**
** Page to allow users to self-register. The "self-register" setting
** must be enabled for this page to operate.
*/
void register_page(void){
const char *zUserID, *zPasswd, *zConfirm, *zEAddr;
const char *zDName;
unsigned int uSeed;
const char *zDecoded;
|
| ︙ | |||
1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 | 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 | + + + + + + + + - + |
zErr = "This email address is already claimed by another user";
}else{
/* If all of the tests above have passed, that means that the submitted
** form contains valid data and we can proceed to create the new login */
Blob sql;
int uid;
char *zPass = sha1_shared_secret(zPasswd, zUserID, 0);
const char *zStartPerms = zPerms;
if( db_get_boolean("selfreg-verify",0) ){
/* If email verification is required for self-registration, initalize
** the new user capabilities to just "7" (Sign up for email). The
** full "default-perms" permissions will be added when they click
** the verification link on the email they are sent. */
zStartPerms = "7";
}
blob_init(&sql, 0, 0);
blob_append_sql(&sql,
"INSERT INTO user(login,pw,cap,info,mtime)\n"
"VALUES(%Q,%Q,%Q,"
"'%q <%q>\nself-register from ip %q on '||datetime('now'),now())",
|
| ︙ | |||
1618 1619 1620 1621 1622 1623 1624 | 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 | - + - + + + - + + |
@ <p>The following internal error was encountered while trying
@ to send the confirmation email:
@ <blockquote><pre>
@ %h(pSender->zErr)
@ </pre></blockquote>
}else{
@ <p>An email has been sent to "%h(zEAddr)". That email contains a
|
| ︙ | |||
1691 1692 1693 1694 1695 1696 1697 | 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 | - + + |
@ <td><input type="password" name="cp" value="%h(zConfirm)" size="30"></td>
@ </tr>
if( iErrLine==5 ){
@ <tr><td><td><span class='loginError'>↑ %h(zErr)</span></td></tr>
}
@ <tr>
@ <td class="form_label" align="right">Captcha:</td>
|
| ︙ |
Changes to src/main.c.
| ︙ | |||
2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 | 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 | + + - - + + + + + + |
**
** COMMAND: test-http
**
** Works like the http command but gives setup permission to all users.
**
** Options:
** --th-trace trace TH1 execution (for debugging purposes)
** --usercap CAP user capability string. (Default: "sx")
**
*/
void cmd_test_http(void){
const char *zIpAddr; /* IP address of remote client */
const char *zUserCap;
Th_InitTraceLog();
|
| ︙ |
Changes to src/security_audit.c.
| ︙ | |||
120 121 122 123 124 125 126 | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | - + |
** though some content may be accessible anonymously.
*/
zAnonCap = db_text("", "SELECT fullcap(NULL)");
zDevCap = db_text("", "SELECT fullcap('v')");
zReadCap = db_text("", "SELECT fullcap('u')");
zPubPages = db_get("public-pages",0);
hasSelfReg = db_get_boolean("self-register",0);
|
| ︙ |
Changes to src/setup.c.
| ︙ | |||
498 499 500 501 502 503 504 | 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + |
@ latest version of the embedded documentation in the www/ folder without
@ allowing them to see the rest of the source code.
@ (Property: "public-pages")
@ </p>
@ <hr />
onoff_attribute("Allow users to register themselves",
|
| ︙ |
Changes to src/setupuser.c.
| ︙ | |||
551 552 553 554 555 556 557 | 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | - + |
}else{
@ <td><input type="text" name="login" value="%h(zLogin)" />\
if( alert_tables_exist() ){
int sid;
sid = db_int(0, "SELECT subscriberId FROM subscriber"
" WHERE suname=%Q", zLogin);
if( sid>0 ){
|
| ︙ |
Changes to src/url.c.
| ︙ | |||
64 65 66 67 68 69 70 | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | - - - - - - - - - - | int useProxy; /* Used to remember that a proxy is in use */ char *proxyUrlPath; int proxyOrigPort; /* Tunneled port number for https through proxy */ }; #endif /* INTERFACE */ |
| ︙ | |||
175 176 177 178 179 180 181 | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | - + |
n = strlen(pUrlData->name);
if( pUrlData->name[0]=='[' && n>2 && pUrlData->name[n-1]==']' ){
pUrlData->name++;
pUrlData->name[n-2] = 0;
}
zLogin = mprintf("");
}
|
| ︙ |
Changes to src/util.c.
| ︙ | |||
138 139 140 141 142 143 144 145 146 147 148 149 150 151 | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | + + + + + + + + + + + + + + + |
if( munmap(p, n) ){
fossil_panic("munmap failed: %d\n", errno);
}
#else
fossil_free(p);
#endif
}
/*
** Translate every upper-case character in the input string into
** its equivalent lower-case.
*/
char *fossil_strtolwr(char *zIn){
char *zStart = zIn;
if( zIn ){
while( *zIn ){
*zIn = fossil_tolower(*zIn);
zIn++;
}
}
return zStart;
}
/*
** This function implements a cross-platform "system()" interface.
*/
int fossil_system(const char *zOrigCmd){
int rc;
#if defined(_WIN32)
|
| ︙ |