Fossil SCM

Add the https-login setting which forces a switch to HTTPS for any non-anonymous login.

drh 2011-03-22 17:00 trunk
Commit be0e8041307397bc30ebc5aa4f6391cd21b7418d
+4
--- src/db.c
+++ src/db.c
@@ -1636,10 +1636,11 @@
16361636
{ "diff-command", 0, 16, "" },
16371637
{ "dont-push", 0, 0, "off" },
16381638
{ "editor", 0, 16, "" },
16391639
{ "gdiff-command", 0, 16, "gdiff" },
16401640
{ "gmerge-command",0, 40, "" },
1641
+ { "https-login", 0, 0, "off" },
16411642
{ "ignore-glob", 0, 40, "" },
16421643
{ "http-port", 0, 16, "8080" },
16431644
{ "localauth", 0, 0, "off" },
16441645
{ "main-branch", 0, 40, "trunk" },
16451646
{ "manifest", 0, 0, "off" },
@@ -1714,10 +1715,13 @@
17141715
** Ex: xxdiff "%original" "%baseline" "%merge" -M "%output"
17151716
** Ex: meld "%baseline" "%original" "%merge" "%output"
17161717
**
17171718
** http-port The TCP/IP port number to use by the "server"
17181719
** and "ui" commands. Default: 8080
1720
+**
1721
+** https-login Send login creditials using HTTPS instead of HTTP
1722
+** even if the login page request came via HTTP.
17191723
**
17201724
** ignore-glob The VALUE is a comma-separated list of GLOB patterns
17211725
** specifying files that the "extra" command will ignore.
17221726
** Example: *.o,*.obj,*.exe
17231727
**
17241728
--- src/db.c
+++ src/db.c
@@ -1636,10 +1636,11 @@
1636 { "diff-command", 0, 16, "" },
1637 { "dont-push", 0, 0, "off" },
1638 { "editor", 0, 16, "" },
1639 { "gdiff-command", 0, 16, "gdiff" },
1640 { "gmerge-command",0, 40, "" },
 
1641 { "ignore-glob", 0, 40, "" },
1642 { "http-port", 0, 16, "8080" },
1643 { "localauth", 0, 0, "off" },
1644 { "main-branch", 0, 40, "trunk" },
1645 { "manifest", 0, 0, "off" },
@@ -1714,10 +1715,13 @@
1714 ** Ex: xxdiff "%original" "%baseline" "%merge" -M "%output"
1715 ** Ex: meld "%baseline" "%original" "%merge" "%output"
1716 **
1717 ** http-port The TCP/IP port number to use by the "server"
1718 ** and "ui" commands. Default: 8080
 
 
 
1719 **
1720 ** ignore-glob The VALUE is a comma-separated list of GLOB patterns
1721 ** specifying files that the "extra" command will ignore.
1722 ** Example: *.o,*.obj,*.exe
1723 **
1724
--- src/db.c
+++ src/db.c
@@ -1636,10 +1636,11 @@
1636 { "diff-command", 0, 16, "" },
1637 { "dont-push", 0, 0, "off" },
1638 { "editor", 0, 16, "" },
1639 { "gdiff-command", 0, 16, "gdiff" },
1640 { "gmerge-command",0, 40, "" },
1641 { "https-login", 0, 0, "off" },
1642 { "ignore-glob", 0, 40, "" },
1643 { "http-port", 0, 16, "8080" },
1644 { "localauth", 0, 0, "off" },
1645 { "main-branch", 0, 40, "trunk" },
1646 { "manifest", 0, 0, "off" },
@@ -1714,10 +1715,13 @@
1715 ** Ex: xxdiff "%original" "%baseline" "%merge" -M "%output"
1716 ** Ex: meld "%baseline" "%original" "%merge" "%output"
1717 **
1718 ** http-port The TCP/IP port number to use by the "server"
1719 ** and "ui" commands. Default: 8080
1720 **
1721 ** https-login Send login creditials using HTTPS instead of HTTP
1722 ** even if the login page request came via HTTP.
1723 **
1724 ** ignore-glob The VALUE is a comma-separated list of GLOB patterns
1725 ** specifying files that the "extra" command will ignore.
1726 ** Example: *.o,*.obj,*.exe
1727 **
1728
+16 -2
--- src/login.c
+++ src/login.c
@@ -286,14 +286,28 @@
286286
" WHERE login='anonymous'"
287287
" AND cap!=''");
288288
}
289289
@ <tr>
290290
@ <td></td>
291
- @ <td><input type="submit" name="in" value="Login" /></td>
291
+ @ <td><input type="submit" name="in" value="Login"
292
+ @ onClick="chngAction(this.form)" /></td>
292293
@ </tr>
293294
@ </table>
294
- @ <script type="text/JavaScript">document.getElementById('u').focus()</script>
295
+ @ <script type="text/JavaScript">
296
+ @ document.getElementById('u').focus()
297
+ @ function chngAction(form){
298
+ if( g.sslNotAvailable==0
299
+ && memcmp(g.zBaseURL,"https:",6)!=0
300
+ && db_get_boolean("https-login",0)
301
+ ){
302
+ char *zSSL = mprintf("https:%s", &g.zBaseURL[5]);
303
+ @ if( form.u.value!="anonymous" ){
304
+ @ form.action = "%h(zSSL)/login";
305
+ @ }
306
+ }
307
+ @ }
308
+ @ </script>
295309
if( g.zLogin==0 ){
296310
@ <p>Enter
297311
}else{
298312
@ <p>You are currently logged in as <b>%h(g.zLogin)</b></p>
299313
@ <p>To change your login to a different user, enter
300314
--- src/login.c
+++ src/login.c
@@ -286,14 +286,28 @@
286 " WHERE login='anonymous'"
287 " AND cap!=''");
288 }
289 @ <tr>
290 @ <td></td>
291 @ <td><input type="submit" name="in" value="Login" /></td>
 
292 @ </tr>
293 @ </table>
294 @ <script type="text/JavaScript">document.getElementById('u').focus()</script>
 
 
 
 
 
 
 
 
 
 
 
 
 
295 if( g.zLogin==0 ){
296 @ <p>Enter
297 }else{
298 @ <p>You are currently logged in as <b>%h(g.zLogin)</b></p>
299 @ <p>To change your login to a different user, enter
300
--- src/login.c
+++ src/login.c
@@ -286,14 +286,28 @@
286 " WHERE login='anonymous'"
287 " AND cap!=''");
288 }
289 @ <tr>
290 @ <td></td>
291 @ <td><input type="submit" name="in" value="Login"
292 @ onClick="chngAction(this.form)" /></td>
293 @ </tr>
294 @ </table>
295 @ <script type="text/JavaScript">
296 @ document.getElementById('u').focus()
297 @ function chngAction(form){
298 if( g.sslNotAvailable==0
299 && memcmp(g.zBaseURL,"https:",6)!=0
300 && db_get_boolean("https-login",0)
301 ){
302 char *zSSL = mprintf("https:%s", &g.zBaseURL[5]);
303 @ if( form.u.value!="anonymous" ){
304 @ form.action = "%h(zSSL)/login";
305 @ }
306 }
307 @ }
308 @ </script>
309 if( g.zLogin==0 ){
310 @ <p>Enter
311 }else{
312 @ <p>You are currently logged in as <b>%h(g.zLogin)</b></p>
313 @ <p>To change your login to a different user, enter
314
+6
--- src/main.c
+++ src/main.c
@@ -73,10 +73,11 @@
7373
char *zBaseURL; /* Full text of the URL being served */
7474
char *zTop; /* Parent directory of zPath */
7575
const char *zContentType; /* The content type of the input HTTP request */
7676
int iErrPriority; /* Priority of current error message */
7777
char *zErrMsg; /* Text of an error message */
78
+ int sslNotAvailable; /* SSL is not available. Do not redirect to https: */
7879
Blob cgiIn; /* Input to an xfer www method */
7980
int cgiOutput; /* Write error and status messages to CGI */
8081
int xferPanic; /* Write error messages in XFER protocol */
8182
int fullHttpReply; /* True for full HTTP reply. False for CGI reply */
8283
Th_Interp *interp; /* The TH1 interpreter */
@@ -1146,17 +1147,21 @@
11461147
** Other options:
11471148
**
11481149
** --localauth Password signin is not required if this is true and
11491150
** the input comes from 127.0.0.1 and the "localauth"
11501151
** setting is not disabled.
1152
+**
1153
+** --nossl SSL connections are not available so do not
1154
+** redirect from http: to https:.
11511155
*/
11521156
void cmd_http(void){
11531157
const char *zIpAddr;
11541158
const char *zNotFound;
11551159
const char *zHost;
11561160
zNotFound = find_option("notfound", 0, 1);
11571161
g.useLocalauth = find_option("localauth", 0, 0)!=0;
1162
+ g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
11581163
if( find_option("https",0,0)!=0 ) cgi_replace_parameter("HTTPS","on");
11591164
zHost = find_option("host", 0, 1);
11601165
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
11611166
g.cgiOutput = 1;
11621167
if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
@@ -1305,10 +1310,11 @@
13051310
}
13061311
db_close(1);
13071312
if( cgi_http_server(iPort, mxPort, zBrowserCmd, flags) ){
13081313
fossil_fatal("unable to listen on TCP socket %d", iPort);
13091314
}
1315
+ g.sslNotAvailable = 1;
13101316
g.httpIn = stdin;
13111317
g.httpOut = stdout;
13121318
if( g.fHttpTrace || g.fSqlTrace ){
13131319
fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
13141320
}
13151321
--- src/main.c
+++ src/main.c
@@ -73,10 +73,11 @@
73 char *zBaseURL; /* Full text of the URL being served */
74 char *zTop; /* Parent directory of zPath */
75 const char *zContentType; /* The content type of the input HTTP request */
76 int iErrPriority; /* Priority of current error message */
77 char *zErrMsg; /* Text of an error message */
 
78 Blob cgiIn; /* Input to an xfer www method */
79 int cgiOutput; /* Write error and status messages to CGI */
80 int xferPanic; /* Write error messages in XFER protocol */
81 int fullHttpReply; /* True for full HTTP reply. False for CGI reply */
82 Th_Interp *interp; /* The TH1 interpreter */
@@ -1146,17 +1147,21 @@
1146 ** Other options:
1147 **
1148 ** --localauth Password signin is not required if this is true and
1149 ** the input comes from 127.0.0.1 and the "localauth"
1150 ** setting is not disabled.
 
 
 
1151 */
1152 void cmd_http(void){
1153 const char *zIpAddr;
1154 const char *zNotFound;
1155 const char *zHost;
1156 zNotFound = find_option("notfound", 0, 1);
1157 g.useLocalauth = find_option("localauth", 0, 0)!=0;
 
1158 if( find_option("https",0,0)!=0 ) cgi_replace_parameter("HTTPS","on");
1159 zHost = find_option("host", 0, 1);
1160 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
1161 g.cgiOutput = 1;
1162 if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
@@ -1305,10 +1310,11 @@
1305 }
1306 db_close(1);
1307 if( cgi_http_server(iPort, mxPort, zBrowserCmd, flags) ){
1308 fossil_fatal("unable to listen on TCP socket %d", iPort);
1309 }
 
1310 g.httpIn = stdin;
1311 g.httpOut = stdout;
1312 if( g.fHttpTrace || g.fSqlTrace ){
1313 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
1314 }
1315
--- src/main.c
+++ src/main.c
@@ -73,10 +73,11 @@
73 char *zBaseURL; /* Full text of the URL being served */
74 char *zTop; /* Parent directory of zPath */
75 const char *zContentType; /* The content type of the input HTTP request */
76 int iErrPriority; /* Priority of current error message */
77 char *zErrMsg; /* Text of an error message */
78 int sslNotAvailable; /* SSL is not available. Do not redirect to https: */
79 Blob cgiIn; /* Input to an xfer www method */
80 int cgiOutput; /* Write error and status messages to CGI */
81 int xferPanic; /* Write error messages in XFER protocol */
82 int fullHttpReply; /* True for full HTTP reply. False for CGI reply */
83 Th_Interp *interp; /* The TH1 interpreter */
@@ -1146,17 +1147,21 @@
1147 ** Other options:
1148 **
1149 ** --localauth Password signin is not required if this is true and
1150 ** the input comes from 127.0.0.1 and the "localauth"
1151 ** setting is not disabled.
1152 **
1153 ** --nossl SSL connections are not available so do not
1154 ** redirect from http: to https:.
1155 */
1156 void cmd_http(void){
1157 const char *zIpAddr;
1158 const char *zNotFound;
1159 const char *zHost;
1160 zNotFound = find_option("notfound", 0, 1);
1161 g.useLocalauth = find_option("localauth", 0, 0)!=0;
1162 g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
1163 if( find_option("https",0,0)!=0 ) cgi_replace_parameter("HTTPS","on");
1164 zHost = find_option("host", 0, 1);
1165 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
1166 g.cgiOutput = 1;
1167 if( g.argc!=2 && g.argc!=3 && g.argc!=6 ){
@@ -1305,10 +1310,11 @@
1310 }
1311 db_close(1);
1312 if( cgi_http_server(iPort, mxPort, zBrowserCmd, flags) ){
1313 fossil_fatal("unable to listen on TCP socket %d", iPort);
1314 }
1315 g.sslNotAvailable = 1;
1316 g.httpIn = stdin;
1317 g.httpOut = stdout;
1318 if( g.fHttpTrace || g.fSqlTrace ){
1319 fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
1320 }
1321
+1 -1
--- src/winhttp.c
+++ src/winhttp.c
@@ -107,11 +107,11 @@
107107
}
108108
wanted -= got;
109109
}
110110
fclose(out);
111111
out = 0;
112
- sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s%s",
112
+ sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
113113
fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
114114
inet_ntoa(p->addr.sin_addr), p->zOptions
115115
);
116116
fossil_system(zCmd);
117117
in = fopen(zReplyFName, "rb");
118118
--- src/winhttp.c
+++ src/winhttp.c
@@ -107,11 +107,11 @@
107 }
108 wanted -= got;
109 }
110 fclose(out);
111 out = 0;
112 sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s%s",
113 fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
114 inet_ntoa(p->addr.sin_addr), p->zOptions
115 );
116 fossil_system(zCmd);
117 in = fopen(zReplyFName, "rb");
118
--- src/winhttp.c
+++ src/winhttp.c
@@ -107,11 +107,11 @@
107 }
108 wanted -= got;
109 }
110 fclose(out);
111 out = 0;
112 sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http \"%s\" %s %s %s --nossl%s",
113 fossil_nameofexe(), g.zRepositoryName, zRequestFName, zReplyFName,
114 inet_ntoa(p->addr.sin_addr), p->zOptions
115 );
116 fossil_system(zCmd);
117 in = fopen(zReplyFName, "rb");
118

Keyboard Shortcuts

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