From: Art Cancro Date: Mon, 24 Jan 2005 03:37:48 +0000 (+0000) Subject: * Began laying the groundwork for http-authenticated GroupDAV sessions. X-Git-Tag: v7.86~5119 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=78a0794cedb500b2ac89ad1b6cd7ba82515dac80;p=citadel.git * Began laying the groundwork for http-authenticated GroupDAV sessions. --- diff --git a/webcit/ChangeLog b/webcit/ChangeLog index bfab41350..370883887 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,7 @@ $Log$ +Revision 528.17 2005/01/24 03:37:48 ajc +* Began laying the groundwork for http-authenticated GroupDAV sessions. + Revision 528.16 2005/01/22 22:50:51 ajc * removed descriptions in non-main menus @@ -2212,3 +2215,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/Makefile.in b/webcit/Makefile.in index b75b1a66a..1edcdf108 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -37,6 +37,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \ mime_parser.o graphics.o netconf.o siteconfig.o subst.o \ calendar.o calendar_tools.o calendar_view.o event.o \ availability.o iconbar.o crypto.o inetconf.o notes.o \ + groupdav_main.o \ $(LIBOBJS) $(CC) webserver.o context_loop.o tools.o cookie_conversion.o \ webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \ @@ -45,6 +46,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \ mime_parser.o graphics.o netconf.o preferences.o html2html.o \ summary.o calendar.o calendar_tools.o calendar_view.o event.o \ availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \ + groupdav_main.o \ $(LIBOBJS) $(LIBS) $(LDFLAGS) -o webserver .c.o: diff --git a/webcit/context_loop.c b/webcit/context_loop.c index e9ea3772a..9667c7d08 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -327,6 +327,7 @@ void context_loop(int sock) && (strncasecmp(buf, "/listsub", 8)) && (strncasecmp(buf, "/freebusy", 9)) && (strncasecmp(buf, "/do_logout", 10)) + && (strncasecmp(buf, "/groupdav", 9)) && (got_cookie == 0)) { strcpy(req->line, "GET /static/nocookies.html" "?force_close_session=yes HTTP/1.0"); diff --git a/webcit/groupdav_main.c b/webcit/groupdav_main.c new file mode 100644 index 000000000..bd7d51d32 --- /dev/null +++ b/webcit/groupdav_main.c @@ -0,0 +1,42 @@ +/* + * $Id$ + * + * Entry point for GroupDAV functions + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "webcit.h" +#include "webserver.h" + +void groupdav_main(char *cmd) { + + if (!WC->logged_in) { + wprintf( + "HTTP/1.1 401 Authorization Required\n" + "WWW-Authenticate: Basic realm=\"GroupDAV\"\n" + "Connection: close\n" + ); + output_headers(0, 0, 0, 0, 0, 0, 0); + wprintf("Content-Type: text/plain\n"); + wprintf("\n"); + wprintf("GroupDAV sessions require HTTP authentication.\n"); + wDumpContent(0); + } + + output_static("smiley.gif"); /* FIXME */ +} diff --git a/webcit/webcit.c b/webcit/webcit.c index 3206e503e..8de092148 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -815,6 +815,7 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp, void session_loop(struct httprequest *req) { char cmd[SIZ]; + char method[SIZ]; char action[SIZ]; char buf[SIZ]; int a, b; @@ -851,6 +852,7 @@ void session_loop(struct httprequest *req) strcpy(cmd, hptr->line); hptr = hptr->next; + extract_token(method, cmd, 0, ' '); extract_action(action, cmd); while (hptr != NULL) { @@ -888,18 +890,9 @@ void session_loop(struct httprequest *req) ContentType, ContentLength); body_start = strlen(content); -/***** old version - BytesRead = 0; - while (BytesRead < ContentLength) { - a=read(WC->http_sock, &content[BytesRead+body_start], - ContentLength - BytesRead); - if (a <= 0) BytesRead = ContentLength; - else BytesRead += a; - } -*******/ - - /* Now we're daring and read it all at once. */ - client_read(WC->http_sock, &content[BytesRead+body_start], ContentLength); + /* Be daring and read it all at once. */ + client_read(WC->http_sock, &content[BytesRead+body_start], + ContentLength); if (!strncasecmp(ContentType, "application/x-www-form-urlencoded", 33)) { @@ -993,6 +986,14 @@ void session_loop(struct httprequest *req) goto SKIP_ALL_THIS_CRAP; } #endif + /* + * The GroupDAV stuff relies on HTTP authentication instead of + * our session's authentication. + */ + if (!strncasecmp(action, "groupdav", 8)) { + groupdav_main(cmd); + goto SKIP_ALL_THIS_CRAP; + } check_for_instant_messages(); diff --git a/webcit/webcit.h b/webcit/webcit.h index 82301a26d..c131e9b81 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -228,6 +228,8 @@ struct wcsession { char ImportantMessage[SIZ]; char last_chat_user[SIZ]; int ctdl_pid; /* Session ID on the Citadel server */ + char httpauth_user[SIZ]; /* only for GroupDAV sessions */ + char httpauth_pass[SIZ]; /* only for GroupDAV sessions */ }; #define extract(dest,source,parmnum) extract_token(dest,source,parmnum,'|') @@ -494,3 +496,5 @@ extern char *ascmonths[]; #define VIEW_CALENDAR 3 /* Calendar view */ #define VIEW_TASKS 4 /* Tasks view */ #define VIEW_NOTES 5 /* Notes view */ + +void groupdav_main(char *);