Fossil SCM

Support HTTP Basic Auth for sync operations

Closed

c46b0f7bb7241a0… · opened 14 years, 11 months ago

Type
Feature_Request
Priority
Severity
Severe
Resolution
Rejected
Subsystem
Created
April 13, 2011 7:29 p.m.

HTTP Basic Auth needs to be supported for sync operations in order to be compatible with any kind of user validation done by the web server hosting fossil.

A patch was provided (6 lines of code) by mightyhe on Sun, 27 Mar 2011 07:45:06 -0700 and may be accessed at:

http://www.mail-archive.com/[email protected]/msg04219.html

and for convenience is included here (NOTE: a fix for an incorrect line terminator on the Proxy-Authorization header is also mixed in with this patch):


Index: src/http.c
===================================================================
--- src/http.c
+++ src/http.c
@@ -105,11 +105,19 @@
   }else{
     zSep = "/";
   }
   blob_appendf(pHdr, "POST %s%sxfer/xfer HTTP/1.0\r\n", g.urlPath, zSep);
   if( g.urlProxyAuth ){
-    blob_appendf(pHdr, "Proxy-Authorization: %s\n", g.urlProxyAuth);
+    blob_appendf(pHdr, "Proxy-Authorization: %s\r\n", g.urlProxyAuth);
+  }
+  // Basic HTTP Authorization
+  if( g.urlUser && g.urlUser[0] && g.urlPasswd ){
+      char *zpw = mprintf("%s:%s", g.urlUser, g.urlPasswd);
+      char *zpw64 = encode64(zpw, strlen(zpw));
+      free(zpw);
+      blob_appendf(pHdr, "Authorization: Basic %s\r\n", zpw64);
+      free(zpw64);
   }
   blob_appendf(pHdr, "Host: %s\r\n", g.urlHostname);
   blob_appendf(pHdr, "User-Agent: Fossil/" MANIFEST_VERSION "\r\n");
   if( g.fHttpTrace ){
     blob_appendf(pHdr, "Content-Type: application/x-fossil-debug\r\n");

Comments (1)

system 2 years, 2 months ago

Closing as part of periodic cleanup.

Keyboard Shortcuts

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