summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2007-05-02 09:10:36 +0000
committerpixel <pixel>2007-05-02 09:10:36 +0000
commit976f094b10a8a95348f02cc5049000228babe7a2 (patch)
tree658856d6ce433ac0c1a9c97325bcfaeed98b4c66
parent739bdeb0fb248ef53da5b2f61b99d804c7dac900 (diff)
Adding basic auth support.
-rw-r--r--lib/HttpServ.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc
index 1559efd..5c9a8aa 100644
--- a/lib/HttpServ.cc
+++ b/lib/HttpServ.cc
@@ -8,6 +8,7 @@
#include "ReadJob.h"
#include "CopyJob.h"
#include "Task.h"
+#include "Base64.h"
#include "gettext.h"
String endhl = "\r\n", endnl = "\n";
@@ -35,7 +36,7 @@ class ProcessRequest : public Task {
Action * p;
Socket s;
- String name, host, gvars;
+ String name, host, gvars, login, password;
Variables * Vars, * Heads;
bool bad, hasvars, post;
};
@@ -82,6 +83,18 @@ int ProcessRequest::Do() throw(GeneralException) {
if (t.strstr("Host: ") == 0) {
host = t.extract(6);
}
+ if (t.strstr("Authorization: Basic ") == 0) {
+ char * credentials = (char *) Base64::decode(t.extract(21), 0);
+ char * p = strchr(credentials, ':');
+
+ if (p) {
+ *p = 0;
+ login = credentials;
+ password = p + 1;
+ }
+
+ free(credentials);
+ }
if ((p = t.strchr(':')) >= 0) {
String s = t.extract(0, p - 1);