4 * WebcitAuth; Handles authentication of users to a Citadel server.
6 * Copyright (c) 1996-2010 by the citadel.org team
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "webserver.h"
27 extern uint32_t hashlittle( const void *key, size_t length, uint32_t initval);
29 void display_reg(int during_login);
32 * Access level definitions. This is initialized from a function rather than a
33 * static array so that the strings may be localized.
37 void initialize_axdefs(void) {
38 axdefs[0] = _("Deleted"); /* an erased user */
39 axdefs[1] = _("New User"); /* a new user */
40 axdefs[2] = _("Problem User"); /* a trouble maker */
41 axdefs[3] = _("Local User"); /* user with normal privileges */
42 axdefs[4] = _("Network User"); /* a user that may access network resources */
43 axdefs[5] = _("Preferred User");/* a moderator */
44 axdefs[6] = _("Aide"); /* chief */
50 * Display the login screen
51 * mesg = the error message if last attempt failed.
53 void display_login(void)
56 output_headers(1, 0, 0, 0, 1, 0);
57 do_template("login", NULL);
65 * Display the openid-enabled login screen
66 * mesg = the error message if last attempt failed.
68 void display_openid_login(char *mesg)
71 output_headers(1, 0, 0, 0, 1, 0);
72 do_template("openid_login", NULL);
77 void display_openid_name_request(const StrBuf *claimed_id, const StrBuf *username)
81 output_headers(1, 1, 2, 0, 0, 0);
82 wc_printf("<div id=\"login_screen\">\n");
84 Buf = NewStrBufPlain(NULL, StrLength(claimed_id));
85 StrEscAppend(Buf, claimed_id, NULL, 0, 0);
86 svprintf(HKEY("VERIFIED"), WCS_STRING, _("Your OpenID <tt>%s</tt> was successfully verified."),
88 SVPutBuf("CLAIMED_ID", Buf, 0);
91 if (StrLength(username) > 0) {
92 Buf = NewStrBufPlain(NULL, StrLength(username));
93 StrEscAppend(Buf, username, NULL, 0, 0);
94 svprintf(HKEY("REASON"), WCS_STRING,
95 _("However, the user name '%s' conflicts with an existing user."),
100 svput("REASON", WCS_STRING, "");
103 svput("ACTION_REQUESTED", WCS_STRING, _("Please specify the user name you would like to use."));
105 svput("USERNAME_BOX", WCS_STRING, _("User name:"));
106 svput("NEWUSER_BUTTON", WCS_STRING, _("New User"));
107 svput("EXIT_BUTTON", WCS_STRING, _("Exit"));
109 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by <a href=\"http://www.citadel.org\">Citadel</a>"),
110 ChrPtr(WC->serv_info->serv_humannode));
112 do_template("openid_manual_create", NULL);
118 /* Initialize the session
120 * This function needs to get called whenever the session changes from
121 * not-logged-in to logged-in, either by an explicit login by the user or
122 * by a timed-out session automatically re-establishing with a little help
123 * from the browser cookie. Either way, we need to load access controls and
124 * preferences from the server.
128 * serv_response The parameters returned from a Citadel USER or NEWU command
130 void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response)
138 if (WCC->wc_fullname == NULL)
139 WCC->wc_fullname = NewStrBufPlain(NULL, StrLength(serv_response));
140 StrBufExtract_token(WCC->wc_fullname, serv_response, 0, '|');
141 StrBufCutLeft(WCC->wc_fullname, 4 );
143 if (WCC->wc_username == NULL)
144 WCC->wc_username = NewStrBufDup(user);
146 FlushStrBuf(WCC->wc_username);
147 StrBufAppendBuf(WCC->wc_username, user, 0);
150 if (WCC->wc_password == NULL)
151 WCC->wc_password = NewStrBufDup(pass);
153 FlushStrBuf(WCC->wc_password);
154 StrBufAppendBuf(WCC->wc_password, pass, 0);
157 WCC->axlevel = StrBufExtract_int(serv_response, 1, '|');
158 if (WCC->axlevel >= 6) { /* TODO: make this a define, else it might trick us later */
166 StrBuf_ServGetln(Buf);
167 if (GetServerStatus(Buf, NULL) == 2) {
170 pch = ChrPtr(Buf) + 4;
171 WCC->new_mail = StrBufExtractNext_long(Buf, &pch, '|');
172 WCC->need_regi = StrBufExtractNext_long(Buf, &pch, '|');
173 WCC->need_vali = StrBufExtractNext_long(Buf, &pch, '|');
174 if (WCC->cs_inet_email == NULL)
175 WCC->cs_inet_email = NewStrBuf();
176 StrBufExtract_NextToken(WCC->cs_inet_email, Buf, &pch, '|');
178 get_preference("floordiv_expanded", &FloorDiv);
179 WCC->floordiv_expanded = FloorDiv;
185 * Perform authentication using a user name and password
192 if (havebstr("language")) {
193 set_selected_language(bstr("language"));
194 go_selected_language();
197 if (havebstr("exit_action")) {
202 if (havebstr("login_action")) {
203 serv_printf("USER %s", bstr("name"));
204 StrBuf_ServGetln(Buf);
205 if (GetServerStatus(Buf, NULL) == 3) {
206 serv_printf("PASS %s", bstr("pass"));
207 StrBuf_ServGetln(Buf);
208 if (GetServerStatus(Buf, NULL) == 2) {
209 become_logged_in(sbstr("name"), sbstr("pass"), Buf);
211 snprintf(WCC->ImportantMessage,
212 sizeof (WCC->ImportantMessage),
220 snprintf(WCC->ImportantMessage,
221 sizeof (WCC->ImportantMessage),
229 if (havebstr("newuser_action")) {
230 if (!havebstr("pass")) {
231 snprintf(WCC->ImportantMessage,
232 sizeof (WCC->ImportantMessage),
234 _("Blank passwords are not allowed."));
239 serv_printf("NEWU %s", bstr("name"));
240 StrBuf_ServGetln(Buf);
241 if (GetServerStatus(Buf, NULL) == 2) {
242 become_logged_in(sbstr("name"), sbstr("pass"), Buf);
243 serv_printf("SETP %s", bstr("pass"));
244 StrBuf_ServGetln(Buf); /* Don't care? */
246 snprintf(WCC->ImportantMessage,
247 sizeof (WCC->ImportantMessage),
255 if (WCC->logged_in) {
256 if (WCC->need_regi) {
258 } else if (WCC->need_vali) {
264 snprintf(WCC->ImportantMessage,
265 sizeof (WCC->ImportantMessage),
267 _("Your password was not accepted."));
274 * Try to create an account manually after an OpenID was verified
276 void openid_manual_create(void)
280 if (havebstr("exit_action")) {
285 if (havebstr("newuser_action")) {
287 serv_printf("OIDC %s", bstr("name"));
288 StrBuf_ServGetln(Buf);
289 if (GetServerStatus(Buf, NULL) == 2) {
293 serv_puts("SETP GENERATE_RANDOM_PASSWORD");
294 StrBuf_ServGetln(gpass);
295 StrBufCutLeft(gpass, 4);
296 become_logged_in(sbstr("name"), gpass, Buf);
305 } else if (WC->need_vali) {
311 display_openid_name_request(sbstr("openid_url"), sbstr("name"));
318 * Perform authentication using OpenID
319 * assemble the checkid_setup request and then redirect to the user's identity provider
321 void do_openid_login(void)
326 if (havebstr("language")) {
327 set_selected_language(bstr("language"));
328 go_selected_language();
331 if (havebstr("exit_action")) {
335 if (havebstr("login_action")) {
336 snprintf(buf, sizeof buf,
337 "OIDS %s|%s://%s/finalize_openid_login|%s://%s",
339 (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host),
340 (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->HR.http_host)
344 serv_getln(buf, sizeof buf);
346 lprintf(CTDL_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
347 http_redirect(&buf[4]);
351 display_openid_login(&buf[4]);
356 /* If we get to this point then something failed. */
357 display_openid_login(_("Your password was not accepted."));
361 * Complete the authentication using OpenID
362 * This function handles the positive or negative assertion from the user's Identity Provider
364 void finalize_openid_login(void)
368 int already_logged_in = (WCC->logged_in) ;
370 StrBuf *result = NULL;
371 StrBuf *username = NULL;
372 StrBuf *password = NULL;
373 StrBuf *logged_in_response = NULL;
374 StrBuf *claimed_id = NULL;
376 if (havebstr("openid.mode")) {
377 if (!strcasecmp(bstr("openid.mode"), "id_res")) {
380 StrBuf_ServGetln(Buf);
381 if (GetServerStatus(Buf, NULL) == 8) {
389 Cursor = GetNewHashPos (WCC->Hdr->urlstrings, 0);
390 while (GetNextHashPos(WCC->Hdr->urlstrings, Cursor, &HKLen, &HKey, &U)) {
392 if (!strncasecmp(u->url_key, "openid.", 7)) {
393 serv_printf("%s|%s", &u->url_key[7], ChrPtr(u->url_data));
400 while (len = StrBuf_ServGetln(Buf),
402 ((len != 3) || strcmp(ChrPtr(Buf), "000") )))
404 if (linecount == 0) result = NewStrBufDup(Buf);
405 if (!strcasecmp(ChrPtr(result), "authenticate")) {
406 if (linecount == 1) {
407 username = NewStrBufDup(Buf);
409 else if (linecount == 2) {
410 password = NewStrBufDup(Buf);
412 else if (linecount == 3) {
413 logged_in_response = NewStrBufDup(Buf);
416 else if (!strcasecmp(ChrPtr(result), "verify_only")) {
417 if (linecount == 1) {
418 claimed_id = NewStrBufDup(Buf);
420 if (linecount == 2) {
421 username = NewStrBufDup(Buf);
431 /* If we were already logged in, this was an attempt to associate an OpenID account */
432 if (already_logged_in) {
435 FreeStrBuf(&username);
436 FreeStrBuf(&password);
437 FreeStrBuf(&claimed_id);
438 FreeStrBuf(&logged_in_response);
442 /* If this operation logged us in, either by connecting with an existing account or by
443 * auto-creating one using Simple Registration Extension, we're already on our way.
445 if (!strcasecmp(ChrPtr(result), "authenticate")) {
446 become_logged_in(username, password, logged_in_response);
449 /* The specified OpenID was verified but the desired user name was either not specified via SRI
450 * or conflicts with an existing user. Either way the user will need to specify a new name.
453 else if (!strcasecmp(ChrPtr(result), "verify_only")) {
454 display_openid_name_request(claimed_id, username);
457 /* Did we manage to log in? If so, continue with the normal flow... */
465 display_openid_login(_("Your password was not accepted."));
469 FreeStrBuf(&username);
470 FreeStrBuf(&password);
471 FreeStrBuf(&claimed_id);
472 FreeStrBuf(&logged_in_response);
477 * Display a welcome screen to the user.
479 * If this is the first time login, and the web based setup is enabled,
480 * lead the user through the setup routines
482 void do_welcome(void)
485 #ifdef XXX_NOT_FINISHED_YET_XXX
490 * See if we have to run the first-time setup wizard
495 sprintf(wizard_filename, "setupwiz.%s.%s",
497 len = strlen(wizard_filename);
498 for (i=0; i<len; ++i) {
499 if ( (wizard_filename[i]==' ')
500 || (wizard_filename[i] == '/')
502 wizard_filename[i] = '_';
506 fp = fopen(wizard_filename, "r");
508 fgets(buf, sizeof buf, fp);
509 buf[strlen(buf)-1] = 0;
511 if (atoi(buf) == serv_info.serv_rev_level) {
512 setup_wizard = 1; /**< already run */
518 http_redirect("setup_wizard");
524 * Go to the user's preferred start page
526 if (!get_preference("startpage", &Buf)) {
528 StrBufPrintf(Buf, "dotskip?room=_BASEROOM_");
529 set_preference("startpage", Buf, 1);
531 if (ChrPtr(Buf)[0] == '/') {
532 StrBufCutLeft(Buf, 1);
534 if (StrLength(Buf) == 0) {
535 StrBufAppendBufPlain(Buf, "dotgoto?room=_BASEROOM_", -1, 0);
537 lprintf(9, "Redirecting to user's start page: %s\n", ChrPtr(Buf));
538 http_redirect(ChrPtr(Buf));
543 * Disconnect from the Citadel server, and end this WebCit session
545 void end_webcit_session(void) {
549 /* close() of citadel socket will be done by do_housekeeping() */
560 FlushStrBuf(WCC->wc_username);
561 FlushStrBuf(WCC->wc_password);
562 FlushStrBuf(WCC->CurRoom.name);
563 FlushStrBuf(WCC->wc_fullname);
565 /* FIXME: this is to suppress the iconbar displaying, because we aren't
566 actually logged out yet */
569 /** Calling output_headers() this way causes the cookies to be un-set */
570 output_headers(1, 1, 0, 1, 0, 0);
572 wc_printf("<div id=\"logout_screen\">");
573 wc_printf("<div class=\"box\">");
574 wc_printf("<div class=\"boxlabel\">");
575 wc_printf(_("Log off"));
576 wc_printf("</div><div class=\"boxcontent\">");
577 serv_puts("MESG goodbye");
578 serv_getln(buf, sizeof buf);
580 if (WCC->serv_sock >= 0) {
584 wc_printf("Goodbye\n");
588 wc_printf(_("This program was unable to connect or stay "
589 "connected to the Citadel server. Please report "
590 "this problem to your system administrator.")
592 wc_printf("<a href=\"http://www.citadel.org/doku.php/"
593 "faq:mastering_your_os:net#netstat\">%s</a>",
597 wc_printf("<hr /><div class=\"buttons\"> "
598 "<span class=\"button_link\"><a href=\".\">");
599 wc_printf(_("Log in again"));
600 wc_printf("</a></span>");
602 /* The "close window" link is commented out because some browsers don't
605 wc_printf(" <span class=\"button_link\">"
606 "<a href=\"javascript:window.close();\">");
607 wc_printf(_("Close window"));
608 wc_printf("</a></span>");
611 wc_printf("</div></div></div></div>\n");
613 end_webcit_session();
627 output_headers(1, 1, 2, 0, 0, 0);
628 wc_printf("<div id=\"banner\">\n");
630 wc_printf(_("Validate new users"));
632 wc_printf("</div>\n");
634 wc_printf("<div id=\"content\" class=\"service\">\n");
636 /* If the user just submitted a validation, process it... */
637 safestrncpy(buf, bstr("user"), sizeof buf);
638 if (!IsEmptyStr(buf)) {
639 if (havebstr("axlevel")) {
640 serv_printf("VALI %s|%s", buf, bstr("axlevel"));
641 serv_getln(buf, sizeof buf);
643 wc_printf("<b>%s</b><br>\n", &buf[4]);
648 /* Now see if any more users require validation. */
650 serv_getln(buf, sizeof buf);
653 wc_printf(_("No users require validation at this time."));
654 wc_printf("</b><br>\n");
659 wc_printf("<b>%s</b><br>\n", &buf[4]);
664 wc_printf("<div class=\"fix_scrollbar_bug\">"
665 "<table class=\"auth_validate\"><tr><td>\n");
666 wc_printf("<div id=\"validate\">");
668 safestrncpy(user, &buf[4], sizeof user);
669 serv_printf("GREG %s", user);
670 serv_getln(cmd, sizeof cmd);
674 serv_getln(buf, sizeof buf);
677 wc_printf("#%s<br><H1>%s</H1>",
686 while (!IsEmptyStr(pch))
690 else if (isalpha(*pch))
704 pch = _("very weak");
717 wc_printf("PW: %s<br>\n", pch);
720 wc_printf("%s<br>\n", buf);
722 wc_printf("%s<br>\n", buf);
724 wc_printf("%s, ", buf);
726 wc_printf("%s ", buf);
728 wc_printf("%s<br>\n", buf);
730 wc_printf("%s<br>\n", buf);
732 wc_printf(_("Current access level: %d (%s)\n"),
733 atoi(buf), axdefs[atoi(buf)]);
734 } while (strcmp(buf, "000"));
736 wc_printf("<H1>%s</H1>%s<br />\n", user, &cmd[4]);
740 wc_printf(_("Select access level for this user:"));
741 wc_printf("<br />\n");
742 for (a = 0; a <= 6; ++a) {
743 wc_printf("<a href=\"validate?nonce=%d?user=", WC->nonce);
745 wc_printf("&axlevel=%d\">%s</A> \n",
748 wc_printf("<br />\n");
750 wc_printf("</div>\n");
751 wc_printf("</td></tr></table></div>\n");
758 * Display form for registration.
760 * (Set during_login to 1 if this registration is being performed during
761 * new user login and will require chaining to the proper screen.)
763 void display_reg(int during_login)
767 message_summary *VCMsg = NULL;
768 wc_mime_attachment *VCAtt = NULL;
772 memset(&Room, 0, sizeof(folder));
773 if (goto_config_room(Buf, &Room) != 0) {
774 lprintf(9, "display_reg() exiting because goto_config_room() failed\n");
788 vcard_msgnum = locate_user_vcard_in_this_room(&VCMsg, &VCAtt);
789 if (vcard_msgnum < 0L) {
790 lprintf(9, "display_reg() exiting because locate_user_vcard_in_this_room() failed\n");
801 do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "do_welcome", USERCONFIGROOM);
805 ReturnTo = NewStrBufPlain(HKEY("display_main_menu?gotofirst="));
806 StrBufAppendBuf(ReturnTo, WC->CurRoom.name, 0);
807 do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, ChrPtr(ReturnTo), USERCONFIGROOM);
808 FreeStrBuf(&ReturnTo);
811 /* FIXME - don't we have to free VCMsg and VCAtt ?? */
818 * display form for changing your password
820 void display_changepw(void)
822 WCTemplputParams SubTP;
825 output_headers(1, 1, 1, 0, 0, 0);
827 Buf = NewStrBufPlain(_("Change your password"), -1);
828 memset(&SubTP, 0, sizeof(WCTemplputParams));
829 SubTP.Filter.ContextType = CTX_STRBUF;
831 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
835 if (!IsEmptyStr(WC->ImportantMessage)) {
836 wc_printf("<span class=\"errormsg\">"
837 "%s</span><br />\n", WC->ImportantMessage);
838 safestrncpy(WC->ImportantMessage, "", sizeof WC->ImportantMessage);
841 serv_puts("MESG changepw");
842 serv_getln(buf, sizeof buf);
847 wc_printf("<form name=\"changepwform\" action=\"changepw\" method=\"post\">\n");
848 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
849 wc_printf("<table class=\"altern\" ");
850 wc_printf("<tr class=\"even\"><td>");
851 wc_printf(_("Enter new password:"));
852 wc_printf("</td><td>");
853 wc_printf("<input type=\"password\" name=\"newpass1\" value=\"\" maxlength=\"20\"></td></tr>\n");
854 wc_printf("<tr class=\"odd\"><td>");
855 wc_printf(_("Enter it again to confirm:"));
856 wc_printf("</td><td>");
857 wc_printf("<input type=\"password\" name=\"newpass2\" value=\"\" maxlength=\"20\"></td></tr>\n");
858 wc_printf("</table>\n");
860 wc_printf("<div class=\"buttons\">\n");
861 wc_printf("<input type=\"submit\" name=\"change_action\" value=\"%s\">", _("Change password"));
863 wc_printf("<input type=\"submit\" name=\"cancel_action\" value=\"%s\">\n", _("Cancel"));
864 wc_printf("</div>\n");
865 wc_printf("</form>\n");
867 do_template("endbox", NULL);
873 * if passwords match, propagate it to citserver.
878 char newpass1[32], newpass2[32];
880 if (!havebstr("change_action")) {
881 safestrncpy(WC->ImportantMessage,
882 _("Cancelled. Password was not changed."),
883 sizeof WC->ImportantMessage);
888 safestrncpy(newpass1, bstr("newpass1"), sizeof newpass1);
889 safestrncpy(newpass2, bstr("newpass2"), sizeof newpass2);
891 if (strcasecmp(newpass1, newpass2)) {
892 safestrncpy(WC->ImportantMessage,
893 _("They don't match. Password was not changed."),
894 sizeof WC->ImportantMessage);
899 if (IsEmptyStr(newpass1)) {
900 safestrncpy(WC->ImportantMessage,
901 _("Blank passwords are not allowed."),
902 sizeof WC->ImportantMessage);
907 serv_printf("SETP %s", newpass1);
908 serv_getln(buf, sizeof buf);
909 sprintf(WC->ImportantMessage, "%s", &buf[4]);
911 if (WC->wc_password == NULL)
912 WC->wc_password = NewStrBufPlain(buf, -1);
914 FlushStrBuf(WC->wc_password);
915 StrBufAppendBufPlain(WC->wc_password, buf, -1, 0);
924 int ConditionalAide(StrBuf *Target, WCTemplputParams *TP)
927 return (WCC != NULL)? (WC->is_aide == 0) : 0;
930 int ConditionalIsLoggedIn(StrBuf *Target, WCTemplputParams *TP)
933 return (WCC != NULL)? (WCC->logged_in == 0) : 0;
937 void _display_openid_login(void) {
938 display_openid_login(NULL);
942 void _display_reg(void) {
947 void Header_HandleAuth(StrBuf *Line, ParsedHttpHdrs *hdr)
949 if (hdr->HR.got_auth == NO_AUTH) /* don't override cookie auth... */
951 if (strncasecmp(ChrPtr(Line), "Basic", 5) == 0) {
952 StrBufCutLeft(Line, 6);
953 StrBufDecodeBase64(Line);
954 hdr->HR.plainauth = Line;
955 hdr->HR.got_auth = AUTH_BASIC;
958 lprintf(1, "Authentication scheme not supported! [%s]\n", ChrPtr(Line));
962 void CheckAuthBasic(ParsedHttpHdrs *hdr)
965 todo: enable this if we can have other sessions than authenticated ones.
966 if (hdr->DontNeedAuth)
969 StrBufAppendBufPlain(hdr->HR.plainauth, HKEY(":"), 0);
970 StrBufAppendBuf(hdr->HR.plainauth, hdr->HR.user_agent, 0);
971 hdr->HR.SessionKey = hashlittle(SKEY(hdr->HR.plainauth), 89479832);
973 lprintf(1, "CheckAuthBasic: calculated sessionkey %ld\n",
978 void GetAuthBasic(ParsedHttpHdrs *hdr)
980 const char *Pos = NULL;
981 if (hdr->c_username == NULL)
982 hdr->c_username = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
983 if (hdr->c_password == NULL)
984 hdr->c_password = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
985 StrBufExtract_NextToken(hdr->c_username, hdr->HR.plainauth, &Pos, ':');
986 StrBufExtract_NextToken(hdr->c_password, hdr->HR.plainauth, &Pos, ':');
989 void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
993 todo: enable this if we can have other sessions than authenticated ones.
994 if (hdr->DontNeedAuth)
997 pch = strstr(ChrPtr(Line), "webcit=");
1002 hdr->HR.RawCookie = Line;
1003 StrBufCutLeft(hdr->HR.RawCookie, (pch - ChrPtr(hdr->HR.RawCookie)) + 7);
1004 StrBufDecodeHex(hdr->HR.RawCookie);
1006 cookie_to_stuff(Line, &hdr->HR.desired_session,
1012 hdr->HR.got_auth = AUTH_COOKIE;
1017 (ParsedHttpHdrs *httpreq)
1019 httpreq->c_username = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
1020 httpreq->c_password = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
1021 httpreq->c_roomname = NewStrBuf();
1022 httpreq->c_language = NewStrBuf();
1025 HttpDetachModule_AUTH
1026 (ParsedHttpHdrs *httpreq)
1028 FLUSHStrBuf(httpreq->c_username);
1029 FLUSHStrBuf(httpreq->c_password);
1030 FLUSHStrBuf(httpreq->c_roomname);
1031 FLUSHStrBuf(httpreq->c_language);
1035 HttpDestroyModule_AUTH
1036 (ParsedHttpHdrs *httpreq)
1038 FreeStrBuf(&httpreq->c_username);
1039 FreeStrBuf(&httpreq->c_password);
1040 FreeStrBuf(&httpreq->c_roomname);
1041 FreeStrBuf(&httpreq->c_language);
1048 RegisterHeaderHandler(HKEY("COOKIE"), Header_HandleCookie);
1049 RegisterHeaderHandler(HKEY("AUTHORIZATION"), Header_HandleAuth);
1051 WebcitAddUrlHandler(HKEY(""), "", 0, do_welcome, ANONYMOUS|COOKIEUNNEEDED); /* no url pattern at all? Show login. */
1052 WebcitAddUrlHandler(HKEY("do_welcome"), "", 0, do_welcome, ANONYMOUS|COOKIEUNNEEDED);
1053 WebcitAddUrlHandler(HKEY("login"), "", 0, do_login, ANONYMOUS|COOKIEUNNEEDED);
1054 WebcitAddUrlHandler(HKEY("display_openid_login"), "", 0, _display_openid_login, ANONYMOUS);
1055 WebcitAddUrlHandler(HKEY("openid_login"), "", 0, do_openid_login, ANONYMOUS);
1056 WebcitAddUrlHandler(HKEY("finalize_openid_login"), "", 0, finalize_openid_login, ANONYMOUS);
1057 WebcitAddUrlHandler(HKEY("openid_manual_create"), "", 0, openid_manual_create, ANONYMOUS);
1058 WebcitAddUrlHandler(HKEY("do_logout"), "", 0, do_logout, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
1059 WebcitAddUrlHandler(HKEY("validate"), "", 0, validate, 0);
1060 WebcitAddUrlHandler(HKEY("display_reg"), "", 0, _display_reg, 0);
1061 WebcitAddUrlHandler(HKEY("display_changepw"), "", 0, display_changepw, 0);
1062 WebcitAddUrlHandler(HKEY("changepw"), "", 0, changepw, 0);
1063 WebcitAddUrlHandler(HKEY("termquit"), "", 0, do_logout, 0);
1065 RegisterConditional(HKEY("COND:AIDE"), 2, ConditionalAide, CTX_NONE);
1066 RegisterConditional(HKEY("COND:LOGGEDIN"), 2, ConditionalIsLoggedIn, CTX_NONE);
1073 SessionDestroyModule_AUTH
1076 FreeStrBuf(&sess->wc_username);
1077 FreeStrBuf(&sess->wc_fullname);
1078 FreeStrBuf(&sess->wc_password);
1079 FreeStrBuf(&sess->httpauth_pass);
1080 FreeStrBuf(&sess->cs_inet_email);