Fossil SCM

Add the 'verifyLogin' command to TH1.

mistachkin 2019-12-13 19:22 trunk merge
Commit a470d60355cd71cc070cd943091fc6a1c8ed03a4fadba71294d43ea8b284ac43
--- src/th_main.c
+++ src/th_main.c
@@ -529,10 +529,37 @@
529529
return Th_WrongNumArgs(interp, "verifyCsrf");
530530
}
531531
login_verify_csrf_secret();
532532
return TH_OK;
533533
}
534
+
535
+/*
536
+** TH1 command: verifyLogin
537
+**
538
+** Returns non-zero if the specified user name and password represent a
539
+** valid login for the repository.
540
+*/
541
+static int verifyLoginCmd(
542
+ Th_Interp *interp,
543
+ void *p,
544
+ int argc,
545
+ const char **argv,
546
+ int *argl
547
+){
548
+ const char *zUser;
549
+ const char *zPass;
550
+ int uid;
551
+ if( argc!=3 ){
552
+ return Th_WrongNumArgs(interp, "verifyLogin userName password");
553
+ }
554
+ zUser = argv[1];
555
+ zPass = argv[2];
556
+ uid = login_search_uid(&zUser, zPass);
557
+ Th_SetResultInt(interp, uid!=0);
558
+ if( uid==0 ) sqlite3_sleep(100);
559
+ return TH_OK;
560
+}
534561
535562
/*
536563
** TH1 command: markdown STRING
537564
**
538565
** Renders the input string as markdown. The result is a two-element list.
@@ -2111,10 +2138,11 @@
21112138
{"trace", traceCmd, 0},
21122139
{"stime", stimeCmd, 0},
21132140
{"unversioned", unversionedCmd, 0},
21142141
{"utime", utimeCmd, 0},
21152142
{"verifyCsrf", verifyCsrfCmd, 0},
2143
+ {"verifyLogin", verifyLoginCmd, 0},
21162144
{"wiki", wikiCmd, (void*)&aFlags[0]},
21172145
{0, 0, 0}
21182146
};
21192147
if( g.thTrace ){
21202148
Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
21212149
--- src/th_main.c
+++ src/th_main.c
@@ -529,10 +529,37 @@
529 return Th_WrongNumArgs(interp, "verifyCsrf");
530 }
531 login_verify_csrf_secret();
532 return TH_OK;
533 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
535 /*
536 ** TH1 command: markdown STRING
537 **
538 ** Renders the input string as markdown. The result is a two-element list.
@@ -2111,10 +2138,11 @@
2111 {"trace", traceCmd, 0},
2112 {"stime", stimeCmd, 0},
2113 {"unversioned", unversionedCmd, 0},
2114 {"utime", utimeCmd, 0},
2115 {"verifyCsrf", verifyCsrfCmd, 0},
 
2116 {"wiki", wikiCmd, (void*)&aFlags[0]},
2117 {0, 0, 0}
2118 };
2119 if( g.thTrace ){
2120 Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
2121
--- src/th_main.c
+++ src/th_main.c
@@ -529,10 +529,37 @@
529 return Th_WrongNumArgs(interp, "verifyCsrf");
530 }
531 login_verify_csrf_secret();
532 return TH_OK;
533 }
534
535 /*
536 ** TH1 command: verifyLogin
537 **
538 ** Returns non-zero if the specified user name and password represent a
539 ** valid login for the repository.
540 */
541 static int verifyLoginCmd(
542 Th_Interp *interp,
543 void *p,
544 int argc,
545 const char **argv,
546 int *argl
547 ){
548 const char *zUser;
549 const char *zPass;
550 int uid;
551 if( argc!=3 ){
552 return Th_WrongNumArgs(interp, "verifyLogin userName password");
553 }
554 zUser = argv[1];
555 zPass = argv[2];
556 uid = login_search_uid(&zUser, zPass);
557 Th_SetResultInt(interp, uid!=0);
558 if( uid==0 ) sqlite3_sleep(100);
559 return TH_OK;
560 }
561
562 /*
563 ** TH1 command: markdown STRING
564 **
565 ** Renders the input string as markdown. The result is a two-element list.
@@ -2111,10 +2138,11 @@
2138 {"trace", traceCmd, 0},
2139 {"stime", stimeCmd, 0},
2140 {"unversioned", unversionedCmd, 0},
2141 {"utime", utimeCmd, 0},
2142 {"verifyCsrf", verifyCsrfCmd, 0},
2143 {"verifyLogin", verifyLoginCmd, 0},
2144 {"wiki", wikiCmd, (void*)&aFlags[0]},
2145 {0, 0, 0}
2146 };
2147 if( g.thTrace ){
2148 Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
2149
+2 -1
--- test/th1.test
+++ test/th1.test
@@ -1041,11 +1041,12 @@
10411041
encode64 error expr for getParameter glob_match globalState hascap \
10421042
hasfeature html htmlize http httpize if info insertCsrf lindex linecount \
10431043
list llength lsearch markdown nonce proc puts query randhex redirect\
10441044
regexp reinitialize rename render repository return searchable set\
10451045
setParameter setting stime string styleFooter styleHeader styleScript\
1046
- tclReady trace unset unversioned uplevel upvar utime verifyCsrf wiki}
1046
+ tclReady trace unset unversioned uplevel upvar utime verifyCsrf\
1047
+ verifyLogin wiki}
10471048
set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
10481049
if {$th1Tcl} {
10491050
test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
10501051
} else {
10511052
test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
10521053
--- test/th1.test
+++ test/th1.test
@@ -1041,11 +1041,12 @@
1041 encode64 error expr for getParameter glob_match globalState hascap \
1042 hasfeature html htmlize http httpize if info insertCsrf lindex linecount \
1043 list llength lsearch markdown nonce proc puts query randhex redirect\
1044 regexp reinitialize rename render repository return searchable set\
1045 setParameter setting stime string styleFooter styleHeader styleScript\
1046 tclReady trace unset unversioned uplevel upvar utime verifyCsrf wiki}
 
1047 set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
1048 if {$th1Tcl} {
1049 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
1050 } else {
1051 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
1052
--- test/th1.test
+++ test/th1.test
@@ -1041,11 +1041,12 @@
1041 encode64 error expr for getParameter glob_match globalState hascap \
1042 hasfeature html htmlize http httpize if info insertCsrf lindex linecount \
1043 list llength lsearch markdown nonce proc puts query randhex redirect\
1044 regexp reinitialize rename render repository return searchable set\
1045 setParameter setting stime string styleFooter styleHeader styleScript\
1046 tclReady trace unset unversioned uplevel upvar utime verifyCsrf\
1047 verifyLogin wiki}
1048 set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
1049 if {$th1Tcl} {
1050 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands $tcl_commands"]}
1051 } else {
1052 test th1-info-commands-1 {$sorted_result eq [lsort "$base_commands"]}
1053
+9
--- www/th1.md
+++ www/th1.md
@@ -215,10 +215,11 @@
215215
* trace
216216
* unversioned content
217217
* unversioned list
218218
* utime
219219
* verifyCsrf
220
+ * verifyLogin
220221
* wiki
221222
222223
Each of the commands above is documented by a block comment above their
223224
implementation in the th\_main.c or th\_tcl.c source files.
224225
@@ -733,10 +734,18 @@
733734
Before using the results of a form, first call this command to verify
734735
that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
735736
is missing or is incorrect, that indicates a cross-site scripting attack.
736737
If the event of an attack is detected, an error message is generated and
737738
all further processing is aborted.
739
+
740
+<a name="verifyLogin"></a>TH1 verifyLogin Command
741
+-------------------------------------------------
742
+
743
+ * verifyLogin
744
+
745
+Returns non-zero if the specified user name and password represent a
746
+valid login for the repository.
738747
739748
<a name="wiki"></a>TH1 wiki Command
740749
-----------------------------------
741750
742751
* wiki STRING
743752
--- www/th1.md
+++ www/th1.md
@@ -215,10 +215,11 @@
215 * trace
216 * unversioned content
217 * unversioned list
218 * utime
219 * verifyCsrf
 
220 * wiki
221
222 Each of the commands above is documented by a block comment above their
223 implementation in the th\_main.c or th\_tcl.c source files.
224
@@ -733,10 +734,18 @@
733 Before using the results of a form, first call this command to verify
734 that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
735 is missing or is incorrect, that indicates a cross-site scripting attack.
736 If the event of an attack is detected, an error message is generated and
737 all further processing is aborted.
 
 
 
 
 
 
 
 
738
739 <a name="wiki"></a>TH1 wiki Command
740 -----------------------------------
741
742 * wiki STRING
743
--- www/th1.md
+++ www/th1.md
@@ -215,10 +215,11 @@
215 * trace
216 * unversioned content
217 * unversioned list
218 * utime
219 * verifyCsrf
220 * verifyLogin
221 * wiki
222
223 Each of the commands above is documented by a block comment above their
224 implementation in the th\_main.c or th\_tcl.c source files.
225
@@ -733,10 +734,18 @@
734 Before using the results of a form, first call this command to verify
735 that this Anti-CSRF token is present and is valid. If the Anti-CSRF token
736 is missing or is incorrect, that indicates a cross-site scripting attack.
737 If the event of an attack is detected, an error message is generated and
738 all further processing is aborted.
739
740 <a name="verifyLogin"></a>TH1 verifyLogin Command
741 -------------------------------------------------
742
743 * verifyLogin
744
745 Returns non-zero if the specified user name and password represent a
746 valid login for the repository.
747
748 <a name="wiki"></a>TH1 wiki Command
749 -----------------------------------
750
751 * wiki STRING
752

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button