From 85a7e6b84462d72e14a287d4bbdbd3e41c97e76d Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Thu, 15 May 2008 17:00:35 +0000 Subject: [PATCH] Added a mini http fetcher into webcit --- citadel/citadel.c | 1 - citadel/database_sleepycat.c | 1 + citadel/ical_dezonify.c | 1 + citadel/include/ctdl_module.h | 1 + citadel/mk_module_init.sh | 3 + citadel/modules/checkpoint/serv_checkpoint.c | 2 + citadel/modules/crypto/serv_crypto.c | 1 + citadel/sysdep_decls.h | 21 ------- citadel/threads.c | 5 ++ libcitadel/lib/libcitadel.h | 29 +++++++++ webcit/Makefile.in | 4 +- webcit/auth.c | 63 ++++++++++++++++++-- webcit/static/openid_login.html | 1 + webcit/webcit.c | 2 + webcit/webcit.h | 2 + 15 files changed, 109 insertions(+), 28 deletions(-) diff --git a/citadel/citadel.c b/citadel/citadel.c index ef8ca61f4..64d4ca1d8 100644 --- a/citadel/citadel.c +++ b/citadel/citadel.c @@ -117,7 +117,6 @@ int enable_syslog = 0; * simple here to have the same * symbols in the client. */ -enum LogLevel {CTDL_EMERG}; void CtdlLogPrintf(enum LogLevel loglevel, const char *format, ...) { va_list arg_ptr; diff --git a/citadel/database_sleepycat.c b/citadel/database_sleepycat.c index 7197009ea..731dc9133 100644 --- a/citadel/database_sleepycat.c +++ b/citadel/database_sleepycat.c @@ -43,6 +43,7 @@ #endif +#include #include "citadel.h" #include "server.h" #include "citserver.h" diff --git a/citadel/ical_dezonify.c b/citadel/ical_dezonify.c index 463af2f0c..662840c41 100644 --- a/citadel/ical_dezonify.c +++ b/citadel/ical_dezonify.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "citadel.h" #include "server.h" #include "citserver.h" diff --git a/citadel/include/ctdl_module.h b/citadel/include/ctdl_module.h index 5dc418131..e554783f5 100644 --- a/citadel/include/ctdl_module.h +++ b/citadel/include/ctdl_module.h @@ -3,6 +3,7 @@ #ifndef CTDL_MODULE_H #define CTDL_MODULE_H +#include #include "server.h" #include "sysdep_decls.h" #include "msgbase.h" diff --git a/citadel/mk_module_init.sh b/citadel/mk_module_init.sh index 96f3ee74b..4969208d5 100755 --- a/citadel/mk_module_init.sh +++ b/citadel/mk_module_init.sh @@ -64,11 +64,13 @@ cat <$U_FILE #include "sysdep.h" #include +#include #include #include #include #include #include +#include #include "citadel.h" #include "modules_init.h" #include "sysdep_decls.h" @@ -99,6 +101,7 @@ cat <$C_FILE #include #include #include +#include #include "citadel.h" #include "modules_init.h" #include "sysdep_decls.h" diff --git a/citadel/modules/checkpoint/serv_checkpoint.c b/citadel/modules/checkpoint/serv_checkpoint.c index 074adeb60..8c7176f0b 100644 --- a/citadel/modules/checkpoint/serv_checkpoint.c +++ b/citadel/modules/checkpoint/serv_checkpoint.c @@ -28,6 +28,8 @@ #error Citadel requires Berkeley DB v4.1 or newer. Please upgrade. #endif +#include + #include "citadel.h" #include "server.h" #include "citserver.h" diff --git a/citadel/modules/crypto/serv_crypto.c b/citadel/modules/crypto/serv_crypto.c index 4aae87270..0fbf27282 100644 --- a/citadel/modules/crypto/serv_crypto.c +++ b/citadel/modules/crypto/serv_crypto.c @@ -32,6 +32,7 @@ #endif #include +#include #include "server.h" #include "serv_crypto.h" #include "sysdep_decls.h" diff --git a/citadel/sysdep_decls.h b/citadel/sysdep_decls.h index c45c67f2d..8a16f7305 100644 --- a/citadel/sysdep_decls.h +++ b/citadel/sysdep_decls.h @@ -40,27 +40,6 @@ #define SIZE_T_FMT "%ld" #endif - -/* Logging levels - correspond to syslog(3) */ -enum LogLevel { - /* When about to exit the server for an unrecoverable error */ - CTDL_EMERG, /* system is unusable */ - /* Manual intervention is required to avoid an abnormal exit */ - CTDL_ALERT, /* action must be taken immediately */ - /* The server can continue to run with degraded functionality */ - CTDL_CRIT, /* critical conditions */ - /* An error occurs but the server continues to run normally */ - CTDL_ERR, /* error conditions */ - /* An abnormal condition was detected; server will continue normally */ - CTDL_WARNING, /* warning conditions */ - /* Normal messages (login/out, activity, etc.) */ - CTDL_NOTICE, /* normal but significant condition */ - /* Unimportant progress messages, etc. */ - CTDL_INFO, /* informational */ - /* Debugging messages */ - CTDL_DEBUG /* debug-level messages */ -}; - #ifdef __GNUC__ void cprintf (const char *format, ...) __attribute__((__format__(__printf__,1,2))); #else diff --git a/citadel/threads.c b/citadel/threads.c index a24e03289..2d8576e1d 100644 --- a/citadel/threads.c +++ b/citadel/threads.c @@ -8,6 +8,9 @@ * */ +#include +#include +#include #include #include #include @@ -26,6 +29,8 @@ # endif #endif +#include + #include "threads.h" #include "ctdl_module.h" #include "modules_init.h" diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index 4bfea6f6f..8c90357a9 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -4,6 +4,11 @@ */ +/* protect against double includes */ +#ifndef LIBCITADEL_H +#define LIBCITADEL_H + + /* * since we reference time_t... */ @@ -19,6 +24,27 @@ #endif +/* Logging levels - correspond to syslog(3) */ +enum LogLevel { + /* When about to exit the server for an unrecoverable error */ + CTDL_EMERG, /* system is unusable */ + /* Manual intervention is required to avoid an abnormal exit */ + CTDL_ALERT, /* action must be taken immediately */ + /* The server can continue to run with degraded functionality */ + CTDL_CRIT, /* critical conditions */ + /* An error occurs but the server continues to run normally */ + CTDL_ERR, /* error conditions */ + /* An abnormal condition was detected; server will continue normally */ + CTDL_WARNING, /* warning conditions */ + /* Normal messages (login/out, activity, etc.) */ + CTDL_NOTICE, /* normal but significant condition */ + /* Unimportant progress messages, etc. */ + CTDL_INFO, /* informational */ + /* Debugging messages */ + CTDL_DEBUG /* debug-level messages */ +}; + + /* * View definitions. * Note that not all views are implemented in all clients. @@ -324,3 +350,6 @@ struct vnote *vnote_new_from_str(char *s); void vnote_free(struct vnote *v); char *vnote_serialize(struct vnote *v); void vnote_serialize_output_field(char *append_to, char *field, char *label); + + +#endif // LIBCITADEL_H diff --git a/webcit/Makefile.in b/webcit/Makefile.in index 8d5bdc9f4..cdb62ab34 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -51,7 +51,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \ groupdav_main.o groupdav_get.o groupdav_propfind.o fmt_date.o \ groupdav_options.o autocompletion.o gettext.o tabs.o sieve.o \ groupdav_delete.o groupdav_put.o http_datestring.o setup_wizard.o \ - downloads.o addressbook_popup.o pushemail.o sysdep.o \ + downloads.o addressbook_popup.o pushemail.o sysdep.o httpfetch.o \ $(LIBOBJS) $(CC) webserver.o context_loop.o cookie_conversion.o \ webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \ @@ -63,7 +63,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \ groupdav_main.o groupdav_get.o groupdav_propfind.o groupdav_delete.o \ groupdav_options.o autocompletion.o tabs.o smtpqueue.o sieve.o \ groupdav_put.o http_datestring.o setup_wizard.o fmt_date.o \ - gettext.o downloads.o addressbook_popup.o pushemail.o sysdep.o \ + gettext.o downloads.o addressbook_popup.o pushemail.o sysdep.o httpfetch.o \ $(LIBOBJS) $(LIBS) $(LDFLAGS) -o webcit .c.o: diff --git a/webcit/auth.c b/webcit/auth.c index 5a0d14595..5ebe8e486 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -79,8 +79,14 @@ void display_login(char *mesg) } #ifdef TECH_PREVIEW - svprintf(HKEY("OFFER_OPENID_LOGIN"), WCS_STRING, "%s", - "Click here to login with OpenID" // FIXME localize when ready + svprintf(HKEY("OFFER_OPENID_LOGIN"), WCS_STRING, + "
" + "" + "" + "%s" + "
" + , + "Log in using OpenID" ); #else svput("OFFER_OPENID_LOGIN", WCS_STRING, ""); @@ -131,6 +137,15 @@ void display_openid_login(char *mesg) serv_info.serv_humannode); svcallback("DO_LANGUAGE_BOX", offer_languages); + svprintf(HKEY("OFFER_CONVENTIONAL_LOGIN"), WCS_STRING, + "
" + "" + "%s" + "
" + , + "Log in using a user name and password" + ); + do_template("openid_login"); wDumpContent(2); } @@ -182,8 +197,7 @@ void become_logged_in(char *user, char *pass, char *serv_response) /* - * Login Checks - * the logic to detect invalid passwords not to get on citservers nerves + * Perform authentication using a user name and password */ void do_login(void) { @@ -244,6 +258,47 @@ void do_login(void) } + + + +/* + * Perform authentication using OpenID + */ +void do_openid_login(void) +{ + if (havebstr("language")) { + set_selected_language(bstr("language")); + go_selected_language(); + } + + if (havebstr("exit_action")) { + do_logout(); + return; + } + if (havebstr("login_action")) { + + fetch_http(bstr("openid_url")); // FIXME + + } + if (WC->logged_in) { + if (WC->need_regi) { + display_reg(1); + } else { + do_welcome(); + } + } else { + display_openid_login(_("Your password was not accepted.")); + } + +} + + + + + + + + /* * display the user a welcome screen. * diff --git a/webcit/static/openid_login.html b/webcit/static/openid_login.html index f28dfad66..9c0f81155 100644 --- a/webcit/static/openid_login.html +++ b/webcit/static/openid_login.html @@ -12,6 +12,7 @@
+ diff --git a/webcit/webcit.c b/webcit/webcit.c index 0ff603070..f3d221229 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -1715,6 +1715,8 @@ void session_loop(struct httprequest *req) */ } else if ((!WC->logged_in) && (!strcasecmp(action, "login"))) { do_login(); + } else if ((!WC->logged_in) && (!strcasecmp(action, "openid_login"))) { + do_openid_login(); } else if ((!WC->logged_in) && (!strcasecmp(action, "display_openid_login"))) { display_openid_login(NULL); } else if (!WC->logged_in) { diff --git a/webcit/webcit.h b/webcit/webcit.h index 21cd14e35..94c4832fa 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -484,6 +484,7 @@ void cookie_to_stuff(char *cookie, int *session, void locate_host(char *, int); void become_logged_in(char *, char *, char *); void do_login(void); +void do_openid_login(void); void display_login(char *mesg); void display_openid_login(char *mesg); void do_welcome(void); @@ -806,6 +807,7 @@ void display_wiki_page(void); int get_time_format_cached (void); int xtoi(char *in, size_t len); void webcit_fmt_date(char *buf, time_t thetime, int brief); +void fetch_http(char *url); #ifdef HAVE_ICONV -- 2.30.2