diff options
author | pixel <pixel> | 2007-05-02 09:10:36 +0000 |
---|---|---|
committer | pixel <pixel> | 2007-05-02 09:10:36 +0000 |
commit | 976f094b10a8a95348f02cc5049000228babe7a2 (patch) | |
tree | 658856d6ce433ac0c1a9c97325bcfaeed98b4c66 /lib | |
parent | 739bdeb0fb248ef53da5b2f61b99d804c7dac900 (diff) |
Adding basic auth support.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/HttpServ.cc | 15 |
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); |