Added a mini http fetcher into webcit
authorArt Cancro <ajc@citadel.org>
Thu, 15 May 2008 17:00:35 +0000 (17:00 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 15 May 2008 17:00:35 +0000 (17:00 +0000)
15 files changed:
citadel/citadel.c
citadel/database_sleepycat.c
citadel/ical_dezonify.c
citadel/include/ctdl_module.h
citadel/mk_module_init.sh
citadel/modules/checkpoint/serv_checkpoint.c
citadel/modules/crypto/serv_crypto.c
citadel/sysdep_decls.h
citadel/threads.c
libcitadel/lib/libcitadel.h
webcit/Makefile.in
webcit/auth.c
webcit/static/openid_login.html
webcit/webcit.c
webcit/webcit.h

index ef8ca61f44498ac6d658b6f4875bfc551681f11f..64d4ca1d8783d0cbb9a0f3065b3e813cea7d3524 100644 (file)
@@ -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;
index 7197009ea7e3b94db31e2ff4a9f1156b9ad55f1b..731dc9133cacda5641c0ffb86c4cd8a00470a8af 100644 (file)
@@ -43,6 +43,7 @@
 #endif
 
 
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "citserver.h"
index 463af2f0cc2985280b37fbcb9173ab26e49ed98d..662840c41105b81548cf409a139da7a9f5227861 100644 (file)
@@ -17,6 +17,7 @@
 #include <string.h>
 #include <strings.h>
 #include <ical.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "citserver.h"
index 5dc418131b0aa86d392ddf61e4b2e3beda91c8cc..e554783f58cad5d5e208babd2d244223f098c60e 100644 (file)
@@ -3,6 +3,7 @@
 #ifndef CTDL_MODULE_H
 #define CTDL_MODULE_H
 
+#include <libcitadel.h>
 #include "server.h"
 #include "sysdep_decls.h"
 #include "msgbase.h"
index 96f3ee74baafc4a121c886fc519c3f439e359725..4969208d57340435469df0ed6d66bf66f75b9b64 100755 (executable)
@@ -64,11 +64,13 @@ cat <<EOF  >$U_FILE
 
 #include "sysdep.h"
 #include <stdlib.h>
+#include <unistd.h>
 #include <time.h>
 #include <ctype.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "modules_init.h"
 #include "sysdep_decls.h"
@@ -99,6 +101,7 @@ cat <<EOF  >$C_FILE
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "modules_init.h"
 #include "sysdep_decls.h"
index 074adeb60dd6b1fe58f69796a27d67b921257611..8c7176f0bf9ef8028c9d7ae9545a06e38ae981ca 100644 (file)
@@ -28,6 +28,8 @@
 #error Citadel requires Berkeley DB v4.1 or newer.  Please upgrade.
 #endif
 
+#include <libcitadel.h>
+
 #include "citadel.h"
 #include "server.h"
 #include "citserver.h"
index 4aae87270db84386203a34a875556b3686426a72..0fbf272828796a89cb9dcb891b0d0794da0182e4 100644 (file)
@@ -32,6 +32,7 @@
 #endif
 
 #include <stdio.h>
+#include <libcitadel.h>
 #include "server.h"
 #include "serv_crypto.h"
 #include "sysdep_decls.h"
index c45c67f2de77fdd4f07bfebbf10405bddc3efed2..8a16f7305beb4915dfea149328c4c428a234118e 100644 (file)
 #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
index a24e03289e74121b826d57856c09d63a2d17649c..2d8576e1d49e7b00dd262564a62065927b9bc656 100644 (file)
@@ -8,6 +8,9 @@
  *
  */
 
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
 #include <sys/types.h>
 #include <errno.h>
 #include <sys/socket.h>
@@ -26,6 +29,8 @@
 # endif
 #endif
 
+#include <libcitadel.h>
+
 #include "threads.h"
 #include "ctdl_module.h"
 #include "modules_init.h"
index 4bfea6f6fecc48c4f39e29c90dbe815f5d1cfb6b..8c90357a96da565551aaae23fe14f895c67c6c88 100644 (file)
@@ -4,6 +4,11 @@
  */
 
 
+/* protect against double includes */
+#ifndef LIBCITADEL_H
+#define LIBCITADEL_H
+
+
 /*
  * since we reference time_t...
  */
 #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
index 8d5bdc9f456c439fb2f15c9022c975d80ebd6916..cdb62ab34253c9ad9bba40cc941d8691a8da825b 100644 (file)
@@ -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:
index 5a0d14595946be77f85ef727d651c405d26f5cef..5ebe8e48618d7a52fe99d2b20fdca9a812bccc8a 100644 (file)
@@ -79,8 +79,14 @@ void display_login(char *mesg)
        }
 
 #ifdef TECH_PREVIEW
-               svprintf(HKEY("OFFER_OPENID_LOGIN"), WCS_STRING, "<a href=\"display_openid_login\">%s</a>",
-                       "Click here to login with OpenID"       // FIXME localize when ready
+               svprintf(HKEY("OFFER_OPENID_LOGIN"), WCS_STRING,
+                       "<div align=center>"
+                       "<a href=\"display_openid_login\">"
+                       "<img src=\"static/openid-small.gif\" border=0 valign=middle>"
+                       "%s</a>"
+                       "</div>"
+                       ,
+                       "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,
+               "<div align=center>"
+               "<a href=\"display_login\">"
+               "%s</a>"
+               "</div>"
+               ,
+               "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.
  *
index f28dfad6646d5b0b595a094ab1a1beab5ae727f2..9c0f81155a0c465901b60aa84c78d03c8ef756c1 100644 (file)
@@ -12,6 +12,7 @@
         <br>
         </div>
 </form>
+<?OFFER_CONVENTIONAL_LOGIN>
 <div class="login_image"><img src="image&name=hello"></div>
 <div class="login_infos"><?LOGIN_INSTRUCTIONS></div>
 <?=endbox>
index 0ff603070d0d2332e00485e7328a6e7d0069fb52..f3d221229b3a979c1ff22aea2fc03734fa60da33 100644 (file)
@@ -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) {
index 21cd14e35dd3afd82b65c40c2e930d9243a126f9..94c4832fae7f30ff26774812b2853f4f7e1efd9a 100644 (file)
@@ -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