4 * WebcitAuth; Handles authentication of users to a Citadel server.
11 extern uint32_t hashlittle( const void *key, size_t length, uint32_t initval);
13 void display_reg(int during_login);
16 * Access level definitions. This is initialized from a function rather than a
17 * static array so that the strings may be localized.
21 void initialize_axdefs(void) {
22 axdefs[0] = _("Deleted"); /* an erased user */
23 axdefs[1] = _("New User"); /* a new user */
24 axdefs[2] = _("Problem User"); /* a trouble maker */
25 axdefs[3] = _("Local User"); /* user with normal privileges */
26 axdefs[4] = _("Network User"); /* a user that may access network resources */
27 axdefs[5] = _("Preferred User");/* a moderator */
28 axdefs[6] = _("Aide"); /* chief */
31 int ReEstablish_Session(void)
33 StrBuf *Buf = NewStrBuf();
36 serv_printf("USER %s", ChrPtr(WCC->Hdr->c_username));
37 StrBuf_ServGetln(Buf);
38 if (GetServerStatus(Buf, NULL) == 3) {
39 serv_printf("PASS %s", ChrPtr(WCC->Hdr->c_password));
40 StrBuf_ServGetln(Buf);
41 if (GetServerStatus(Buf, NULL) == 2) {
42 become_logged_in(WCC->Hdr->c_username,
43 WCC->Hdr->c_password, Buf);
44 get_preference("default_header_charset", &WCC->DefaultCharset);
48 * If we don't have a current room, but a cookie specifying the
49 * current room is supplied, make an effort to go there.
51 if ((StrLength(WCC->wc_roomname) == 0) && (StrLength(WCC->Hdr->c_roomname) > 0)) {
52 serv_printf("GOTO %s",
53 ChrPtr(WCC->Hdr->c_roomname));
54 StrBuf_ServGetln(Buf);
55 if (GetServerStatus(Buf, NULL) == 2) {
56 if (WCC->wc_roomname == NULL) {
57 WCC->wc_roomname = NewStrBufDup(WCC->Hdr->c_roomname);
60 FlushStrBuf(WCC->wc_roomname);
61 StrBufAppendBuf(WCC->wc_roomname, WCC->Hdr->c_roomname, 0);
71 * Display the login screen
72 * mesg = the error message if last attempt failed.
74 void display_login(void)
77 output_headers(1, 0, 0, 0, 1, 0);
78 do_template("login", NULL);
86 * Display the openid-enabled login screen
87 * mesg = the error message if last attempt failed.
89 void display_openid_login(char *mesg)
92 output_headers(1, 0, 0, 0, 1, 0);
93 do_template("openid_login", NULL);
98 void display_openid_name_request(const StrBuf *claimed_id, const StrBuf *username)
102 output_headers(1, 1, 2, 0, 0, 0);
103 wprintf("<div id=\"login_screen\">\n");
105 Buf = NewStrBufPlain(NULL, StrLength(claimed_id));
106 StrEscAppend(Buf, claimed_id, NULL, 0, 0);
107 svprintf(HKEY("VERIFIED"), WCS_STRING, _("Your OpenID <tt>%s</tt> was successfully verified."),
109 SVPutBuf("CLAIMED_ID", Buf, 0);
112 if (StrLength(username) > 0) {
113 Buf = NewStrBufPlain(NULL, StrLength(username));
114 StrEscAppend(Buf, claimed_id, NULL, 0, 0);
115 svprintf(HKEY("REASON"), WCS_STRING,
116 _("However, the user name '%s' conflicts with an existing user."),
121 svput("REASON", WCS_STRING, "");
124 svput("ACTION_REQUESTED", WCS_STRING, _("Please specify the user name you would like to use."));
126 svput("USERNAME_BOX", WCS_STRING, _("User name:"));
127 svput("NEWUSER_BUTTON", WCS_STRING, _("New User"));
128 svput("EXIT_BUTTON", WCS_STRING, _("Exit"));
130 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("%s - powered by <a href=\"http://www.citadel.org\">Citadel</a>"),
131 ChrPtr(WC->serv_info->serv_humannode));
133 do_template("openid_manual_create", NULL);
139 /* Initialize the session
141 * This function needs to get called whenever the session changes from
142 * not-logged-in to logged-in, either by an explicit login by the user or
143 * by a timed-out session automatically re-establishing with a little help
144 * from the browser cookie. Either way, we need to load access controls and
145 * preferences from the server.
149 * serv_response The parameters returned from a Citadel USER or NEWU command
151 void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response)
156 StrBuf *Language = NULL;
160 if (WCC->wc_fullname == NULL)
161 WCC->wc_fullname = NewStrBufPlain(NULL, StrLength(serv_response));
162 StrBufExtract_token(WCC->wc_fullname, serv_response, 0, '|');
163 StrBufCutLeft(WCC->wc_fullname, 4 );
165 if (WCC->wc_username == NULL)
166 WCC->wc_username = NewStrBufDup(user);
168 FlushStrBuf(WCC->wc_username);
169 StrBufAppendBuf(WCC->wc_username, user, 0);
172 if (WCC->wc_password == NULL)
173 WCC->wc_password = NewStrBufDup(pass);
175 FlushStrBuf(WCC->wc_password);
176 StrBufAppendBuf(WCC->wc_password, pass, 0);
179 WCC->axlevel = StrBufExtract_int(serv_response, 1, '|');
180 if (WCC->axlevel >= 6) { /* TODO: make this a define, else it might trick us later */
188 StrBuf_ServGetln(Buf);
189 if (GetServerStatus(Buf, NULL) == 2) {
192 pch = ChrPtr(Buf) + 4;
193 WCC->new_mail = StrBufExtractNext_long(Buf, &pch, '|');
194 WCC->need_regi = StrBufExtractNext_long(Buf, &pch, '|');
195 WCC->need_vali = StrBufExtractNext_long(Buf, &pch, '|');
196 if (WCC->cs_inet_email == NULL)
197 WCC->cs_inet_email = NewStrBuf();
198 StrBufExtract_NextToken(WCC->cs_inet_email, Buf, &pch, '|');
200 if (havebstr("language"))
201 set_preference("language", NewStrBufDup(SBSTR("language")), 1);
203 get_preference("language", &Language);
204 if (Language != NULL) {
205 set_selected_language(ChrPtr(Language));
206 go_selected_language(); /* set locale */
209 get_preference("floordiv_expanded", &FloorDiv);
210 WCC->floordiv_expanded = FloorDiv;
216 * Perform authentication using a user name and password
223 if (havebstr("language")) {
224 set_selected_language(bstr("language"));
225 go_selected_language();
228 if (havebstr("exit_action")) {
233 if (havebstr("login_action")) {
234 serv_printf("USER %s", bstr("name"));
235 StrBuf_ServGetln(Buf);
236 if (GetServerStatus(Buf, NULL) == 3) {
237 serv_printf("PASS %s", bstr("pass"));
238 StrBuf_ServGetln(Buf);
239 if (GetServerStatus(Buf, NULL) == 2) {
240 become_logged_in(sbstr("name"), sbstr("pass"), Buf);
242 snprintf(WCC->ImportantMessage,
243 sizeof (WCC->ImportantMessage),
251 snprintf(WCC->ImportantMessage,
252 sizeof (WCC->ImportantMessage),
260 if (havebstr("newuser_action")) {
261 if (!havebstr("pass")) {
262 snprintf(WCC->ImportantMessage,
263 sizeof (WCC->ImportantMessage),
265 _("Blank passwords are not allowed."));
270 serv_printf("NEWU %s", bstr("name"));
271 StrBuf_ServGetln(Buf);
272 if (GetServerStatus(Buf, NULL) == 2) {
273 become_logged_in(sbstr("name"), sbstr("pass"), Buf);
274 serv_printf("SETP %s", bstr("pass"));
275 StrBuf_ServGetln(Buf); /* Don't care? */
277 snprintf(WCC->ImportantMessage,
278 sizeof (WCC->ImportantMessage),
286 if (WCC->logged_in) {
287 if (WCC->need_regi) {
289 } else if (WCC->need_vali) {
295 snprintf(WCC->ImportantMessage,
296 sizeof (WCC->ImportantMessage),
298 _("Your password was not accepted."));
305 * Try to create an account manually after an OpenID was verified
307 void openid_manual_create(void)
311 if (havebstr("exit_action")) {
316 if (havebstr("newuser_action")) {
318 serv_printf("OIDC %s", bstr("name"));
319 StrBuf_ServGetln(Buf);
320 if (GetServerStatus(Buf, NULL) == 2) {
324 serv_puts("SETP GENERATE_RANDOM_PASSWORD");
325 StrBuf_ServGetln(gpass);
326 StrBufCutLeft(gpass, 4);
327 become_logged_in(sbstr("name"), gpass, Buf);
336 } else if (WC->need_vali) {
342 display_openid_name_request(sbstr("openid_url"), sbstr("name"));
349 * Perform authentication using OpenID
350 * assemble the checkid_setup request and then redirect to the user's identity provider
352 void do_openid_login(void)
357 if (havebstr("language")) {
358 set_selected_language(bstr("language"));
359 go_selected_language();
362 if (havebstr("exit_action")) {
366 if (havebstr("login_action")) {
367 snprintf(buf, sizeof buf,
368 "OIDS %s|%s://%s/finalize_openid_login|%s://%s",
370 (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->http_host),
371 (is_https ? "https" : "http"), ChrPtr(WCC->Hdr->http_host)
375 serv_getln(buf, sizeof buf);
377 lprintf(CTDL_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
378 http_redirect(&buf[4]);
382 display_openid_login(&buf[4]);
387 /* If we get to this point then something failed. */
388 display_openid_login(_("Your password was not accepted."));
392 * Complete the authentication using OpenID
393 * This function handles the positive or negative assertion from the user's Identity Provider
395 void finalize_openid_login(void)
399 int already_logged_in = (WCC->logged_in) ;
401 StrBuf *result = NULL;
402 StrBuf *username = NULL;
403 StrBuf *password = NULL;
404 StrBuf *logged_in_response = NULL;
405 StrBuf *claimed_id = NULL;
407 if (havebstr("openid.mode")) {
408 if (!strcasecmp(bstr("openid.mode"), "id_res")) {
411 StrBuf_ServGetln(Buf);
412 if (GetServerStatus(Buf, NULL) == 8) {
419 Cursor = GetNewHashPos (WCC->Hdr->urlstrings, 0);
420 while (GetNextHashPos(WCC->Hdr->urlstrings, Cursor, &HKLen, &HKey, &U)) {
422 if (!strncasecmp(u->url_key, "openid.", 7)) {
423 serv_printf("%s|%s", &u->url_key[7], ChrPtr(u->url_data));
430 while (StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000"))
432 if (linecount == 0) result = NewStrBufDup(Buf);
433 if (!strcasecmp(ChrPtr(result), "authenticate")) {
434 if (linecount == 1) {
435 username = NewStrBufDup(Buf);
437 else if (linecount == 2) {
438 password = NewStrBufDup(Buf);
440 else if (linecount == 3) {
441 logged_in_response = NewStrBufDup(Buf);
444 else if (!strcasecmp(ChrPtr(result), "verify_only")) {
445 if (linecount == 1) {
446 claimed_id = NewStrBufDup(Buf);
448 if (linecount == 2) {
449 username = NewStrBufDup(Buf);
459 /* If we were already logged in, this was an attempt to associate an OpenID account */
460 if (already_logged_in) {
463 FreeStrBuf(&username);
464 FreeStrBuf(&password);
465 FreeStrBuf(&claimed_id);
466 FreeStrBuf(&logged_in_response);
470 /* If this operation logged us in, either by connecting with an existing account or by
471 * auto-creating one using Simple Registration Extension, we're already on our way.
473 if (!strcasecmp(ChrPtr(result), "authenticate")) {
474 become_logged_in(username, password, logged_in_response);
477 /* The specified OpenID was verified but the desired user name was either not specified via SRI
478 * or conflicts with an existing user. Either way the user will need to specify a new name.
481 else if (!strcasecmp(ChrPtr(result), "verify_only")) {
482 display_openid_name_request(claimed_id, username);
485 /* Did we manage to log in? If so, continue with the normal flow... */
493 display_openid_login(_("Your password was not accepted."));
497 FreeStrBuf(&username);
498 FreeStrBuf(&password);
499 FreeStrBuf(&claimed_id);
500 FreeStrBuf(&logged_in_response);
505 * Display a welcome screen to the user.
507 * If this is the first time login, and the web based setup is enabled,
508 * lead the user through the setup routines
510 void do_welcome(void)
513 #ifdef XXX_NOT_FINISHED_YET_XXX
518 * See if we have to run the first-time setup wizard
523 sprintf(wizard_filename, "setupwiz.%s.%s",
525 len = strlen(wizard_filename);
526 for (i=0; i<len; ++i) {
527 if ( (wizard_filename[i]==' ')
528 || (wizard_filename[i] == '/')
530 wizard_filename[i] = '_';
534 fp = fopen(wizard_filename, "r");
536 fgets(buf, sizeof buf, fp);
537 buf[strlen(buf)-1] = 0;
539 if (atoi(buf) == serv_info.serv_rev_level) {
540 setup_wizard = 1; /**< already run */
546 http_redirect("setup_wizard");
552 * Go to the user's preferred start page
554 if (!get_preference("startpage", &Buf)) {
556 StrBufPrintf(Buf, "dotskip&room=_BASEROOM_");
557 set_preference("startpage", Buf, 1);
559 if (ChrPtr(Buf)[0] == '/') {
560 StrBufCutLeft(Buf, 1);
562 if (StrLength(Buf) == 0)
563 StrBufAppendBufPlain(Buf, "dotgoto?room=_BASEROOM_", -1, 0);
564 http_redirect(ChrPtr(Buf));
569 * Disconnect from the Citadel server, and end this WebCit session
571 void end_webcit_session(void) {
575 /* close() of citadel socket will be done by do_housekeeping() */
586 FlushStrBuf(WCC->wc_username);
587 FlushStrBuf(WCC->wc_password);
588 FlushStrBuf(WCC->wc_roomname);
589 FlushStrBuf(WCC->wc_fullname);
591 /* FIXME: this is to suppress the iconbar displaying, because we aren't
592 actually logged out yet */
595 /** Calling output_headers() this way causes the cookies to be un-set */
596 output_headers(1, 1, 0, 1, 0, 0);
598 wprintf("<div id=\"logout_screen\">");
599 wprintf("<div class=\"box\">");
600 wprintf("<div class=\"boxlabel\">");
601 wprintf(_("Log off"));
602 wprintf("</div><div class=\"boxcontent\">");
603 serv_puts("MESG goodbye");
604 serv_getln(buf, sizeof buf);
606 if (WCC->serv_sock >= 0) {
610 wprintf("Goodbye\n");
614 wprintf(_("This program was unable to connect or stay "
615 "connected to the Citadel server. Please report "
616 "this problem to your system administrator.")
618 wprintf("<a href=\"http://www.citadel.org/doku.php/"
619 "faq:mastering_your_os:net#netstat\">%s</a>",
623 wprintf("<hr /><div class=\"buttons\"> "
624 "<span class=\"button_link\"><a href=\".\">");
625 wprintf(_("Log in again"));
626 wprintf("</a></span>");
628 /* The "close window" link is commented out because some browsers don't
631 wprintf(" <span class=\"button_link\">"
632 "<a href=\"javascript:window.close();\">");
633 wprintf(_("Close window"));
634 wprintf("</a></span>");
637 wprintf("</div></div></div></div>\n");
639 end_webcit_session();
653 output_headers(1, 1, 2, 0, 0, 0);
654 wprintf("<div id=\"banner\">\n");
656 wprintf(_("Validate new users"));
660 wprintf("<div id=\"content\" class=\"service\">\n");
662 /* If the user just submitted a validation, process it... */
663 safestrncpy(buf, bstr("user"), sizeof buf);
664 if (!IsEmptyStr(buf)) {
665 if (havebstr("axlevel")) {
666 serv_printf("VALI %s|%s", buf, bstr("axlevel"));
667 serv_getln(buf, sizeof buf);
669 wprintf("<b>%s</b><br>\n", &buf[4]);
674 /* Now see if any more users require validation. */
676 serv_getln(buf, sizeof buf);
679 wprintf(_("No users require validation at this time."));
680 wprintf("</b><br>\n");
685 wprintf("<b>%s</b><br>\n", &buf[4]);
690 wprintf("<div class=\"fix_scrollbar_bug\">"
691 "<table class=\"auth_validate\"><tr><td>\n");
692 wprintf("<div id=\"validate\">");
694 safestrncpy(user, &buf[4], sizeof user);
695 serv_printf("GREG %s", user);
696 serv_getln(cmd, sizeof cmd);
700 serv_getln(buf, sizeof buf);
703 wprintf("#%s<br><H1>%s</H1>",
712 while (!IsEmptyStr(pch))
716 else if (isalpha(*pch))
727 pch = _("very weak");
740 wprintf("PW: %s<br>\n", pch);
743 wprintf("%s<br>\n", buf);
745 wprintf("%s<br>\n", buf);
747 wprintf("%s, ", buf);
751 wprintf("%s<br>\n", buf);
753 wprintf("%s<br>\n", buf);
755 wprintf(_("Current access level: %d (%s)\n"),
756 atoi(buf), axdefs[atoi(buf)]);
757 } while (strcmp(buf, "000"));
759 wprintf("<H1>%s</H1>%s<br />\n", user, &cmd[4]);
763 wprintf(_("Select access level for this user:"));
765 for (a = 0; a <= 6; ++a) {
766 wprintf("<a href=\"validate?nonce=%d?user=", WC->nonce);
768 wprintf("&axlevel=%d\">%s</A> \n",
774 wprintf("</td></tr></table></div>\n");
781 * Display form for registration.
783 * (Set during_login to 1 if this registration is being performed during
784 * new user login and will require chaining to the proper screen.)
786 void display_reg(int during_login)
789 message_summary *VCMsg;
790 wc_mime_attachment *VCAtt;
794 if (goto_config_room(Buf) != 0) {
795 if (during_login) do_welcome();
796 else display_main_menu();
802 vcard_msgnum = locate_user_vcard_in_this_room(&VCMsg, &VCAtt);
803 if (vcard_msgnum < 0L) {
804 if (during_login) do_welcome();
805 else display_main_menu();
810 do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "do_welcome", USERCONFIGROOM);
813 do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "display_main_menu", USERCONFIGROOM);
822 * display form for changing your password
824 void display_changepw(void)
826 WCTemplputParams SubTP;
829 output_headers(1, 1, 1, 0, 0, 0);
831 Buf = NewStrBufPlain(_("Change your password"), -1);
832 memset(&SubTP, 0, sizeof(WCTemplputParams));
833 SubTP.Filter.ContextType = CTX_STRBUF;
835 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
839 if (!IsEmptyStr(WC->ImportantMessage)) {
840 wprintf("<span class=\"errormsg\">"
841 "%s</span><br />\n", WC->ImportantMessage);
842 safestrncpy(WC->ImportantMessage, "", sizeof WC->ImportantMessage);
845 serv_puts("MESG changepw");
846 serv_getln(buf, sizeof buf);
851 wprintf("<form name=\"changepwform\" action=\"changepw\" method=\"post\">\n");
852 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
853 wprintf("<table class=\"altern\" ");
854 wprintf("<tr class=\"even\"><td>");
855 wprintf(_("Enter new password:"));
856 wprintf("</td><td>");
857 wprintf("<input type=\"password\" name=\"newpass1\" value=\"\" maxlength=\"20\"></td></tr>\n");
858 wprintf("<tr class=\"odd\"><td>");
859 wprintf(_("Enter it again to confirm:"));
860 wprintf("</td><td>");
861 wprintf("<input type=\"password\" name=\"newpass2\" value=\"\" maxlength=\"20\"></td></tr>\n");
862 wprintf("</table>\n");
864 wprintf("<div class=\"buttons\">\n");
865 wprintf("<input type=\"submit\" name=\"change_action\" value=\"%s\">", _("Change password"));
867 wprintf("<input type=\"submit\" name=\"cancel_action\" value=\"%s\">\n", _("Cancel"));
869 wprintf("</form>\n");
871 do_template("endbox", NULL);
877 * if passwords match, propagate it to citserver.
882 char newpass1[32], newpass2[32];
884 if (!havebstr("change_action")) {
885 safestrncpy(WC->ImportantMessage,
886 _("Cancelled. Password was not changed."),
887 sizeof WC->ImportantMessage);
892 safestrncpy(newpass1, bstr("newpass1"), sizeof newpass1);
893 safestrncpy(newpass2, bstr("newpass2"), sizeof newpass2);
895 if (strcasecmp(newpass1, newpass2)) {
896 safestrncpy(WC->ImportantMessage,
897 _("They don't match. Password was not changed."),
898 sizeof WC->ImportantMessage);
903 if (IsEmptyStr(newpass1)) {
904 safestrncpy(WC->ImportantMessage,
905 _("Blank passwords are not allowed."),
906 sizeof WC->ImportantMessage);
911 serv_printf("SETP %s", newpass1);
912 serv_getln(buf, sizeof buf);
913 sprintf(WC->ImportantMessage, "%s", &buf[4]);
915 if (WC->wc_password == NULL)
916 WC->wc_password = NewStrBufPlain(buf, -1);
918 FlushStrBuf(WC->wc_password);
919 StrBufAppendBufPlain(WC->wc_password, buf, -1, 0);
928 int ConditionalAide(StrBuf *Target, WCTemplputParams *TP)
930 return (WC->is_aide == 0);
933 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
935 return (WC->is_room_aide == 0);
938 int ConditionalIsLoggedIn(StrBuf *Target, WCTemplputParams *TP) {
939 return (WC->logged_in == 0);
941 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
944 return ( (WCC->is_room_aide) || (WCC->is_mailbox) || (WCC->room_flags2 & QR2_COLLABDEL) );
949 void _display_openid_login(void) {display_openid_login(NULL);}
950 void _display_reg(void) {display_reg(0);}
952 void Header_HandleAuth(StrBuf *Line, ParsedHttpHdrs *hdr)
954 if (hdr->got_auth == NO_AUTH) /* don't override cookie auth... */
956 if (strncasecmp(ChrPtr(Line), "Basic", 5) == 0) {
957 StrBufCutLeft(Line, 6);
958 StrBufDecodeBase64(Line);
959 hdr->plainauth = Line;
960 hdr->got_auth = AUTH_BASIC;
963 lprintf(1, "Authentication scheme not supported! [%s]\n", ChrPtr(Line));
967 void CheckAuthBasic(ParsedHttpHdrs *hdr)
970 todo: enable this if we can have other sessions than authenticated ones.
971 if (hdr->DontNeedAuth)
974 StrBufAppendBufPlain(hdr->plainauth, HKEY(":"), 0);
975 StrBufAppendBuf(hdr->plainauth, hdr->user_agent, 0);
976 hdr->SessionKey = hashlittle(SKEY(hdr->plainauth), 89479832);
980 void GetAuthBasic(ParsedHttpHdrs *hdr)
982 const char *Pos = NULL;
983 if (hdr->c_username == NULL)
984 hdr->c_username = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
985 if (hdr->c_password == NULL)
986 hdr->c_password = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
987 StrBufExtract_NextToken(hdr->c_username, hdr->plainauth, &Pos, ':');
988 StrBufExtract_NextToken(hdr->c_password, hdr->plainauth, &Pos, ':');
991 void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
995 todo: enable this if we can have other sessions than authenticated ones.
996 if (hdr->DontNeedAuth)
999 pch = strstr(ChrPtr(Line), "webcit=");
1004 hdr->RawCookie = Line;
1005 StrBufCutLeft(hdr->RawCookie, (pch - ChrPtr(hdr->RawCookie)) + 7);
1006 StrBufDecodeHex(hdr->RawCookie);
1008 if (hdr->c_username == NULL)
1009 hdr->c_username = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
1010 if (hdr->c_password == NULL)
1011 hdr->c_password = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
1012 if (hdr->c_roomname == NULL)
1013 hdr->c_roomname = NewStrBuf();
1014 cookie_to_stuff(Line, &hdr->desired_session,
1018 hdr->got_auth = AUTH_COOKIE;
1027 RegisterHeaderHandler(HKEY("COOKIE"), Header_HandleCookie);
1028 RegisterHeaderHandler(HKEY("AUTHORIZATION"), Header_HandleAuth);
1030 WebcitAddUrlHandler(HKEY(""), do_welcome, ANONYMOUS|COOKIEUNNEEDED); /* no url pattern at all? Show login. */
1031 WebcitAddUrlHandler(HKEY("do_welcome"), do_welcome, ANONYMOUS|COOKIEUNNEEDED);
1032 WebcitAddUrlHandler(HKEY("login"), do_login, ANONYMOUS|COOKIEUNNEEDED);
1033 WebcitAddUrlHandler(HKEY("display_openid_login"), _display_openid_login, ANONYMOUS);
1034 WebcitAddUrlHandler(HKEY("openid_login"), do_openid_login, ANONYMOUS);
1035 WebcitAddUrlHandler(HKEY("finalize_openid_login"), finalize_openid_login, ANONYMOUS);
1036 WebcitAddUrlHandler(HKEY("openid_manual_create"), openid_manual_create, ANONYMOUS);
1037 WebcitAddUrlHandler(HKEY("do_logout"), do_logout, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
1038 WebcitAddUrlHandler(HKEY("validate"), validate, 0);
1039 WebcitAddUrlHandler(HKEY("display_reg"), _display_reg, 0);
1040 WebcitAddUrlHandler(HKEY("display_changepw"), display_changepw, 0);
1041 WebcitAddUrlHandler(HKEY("changepw"), changepw, 0);
1042 WebcitAddUrlHandler(HKEY("termquit"), do_logout, 0);
1044 RegisterConditional(HKEY("COND:AIDE"), 2, ConditionalAide, CTX_NONE);
1045 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
1046 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
1047 RegisterConditional(HKEY("COND:LOGGEDIN"), 2, ConditionalIsLoggedIn, CTX_NONE);
1054 SessionDestroyModule_AUTH
1057 FreeStrBuf(&sess->wc_username);
1058 FreeStrBuf(&sess->wc_fullname);
1059 FreeStrBuf(&sess->wc_password);
1060 FreeStrBuf(&sess->wc_roomname);
1061 FreeStrBuf(&sess->httpauth_pass);
1062 FreeStrBuf(&sess->cs_inet_email);