2 * These functions handle authentication of users to a Citadel server.
4 * Copyright (c) 1996-2011 by the citadel.org team
6 * This program is open source software. You can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "webserver.h"
25 extern uint32_t hashlittle( const void *key, size_t length, uint32_t initval);
28 * Access level definitions. This is initialized from a function rather than a
29 * static array so that the strings may be localized.
33 void initialize_axdefs(void) {
36 axdefs[0] = _("Deleted");
39 axdefs[1] = _("New User");
42 axdefs[2] = _("Problem User");
44 /* user with normal privileges */
45 axdefs[3] = _("Local User");
47 /* a user that may access network resources */
48 axdefs[4] = _("Network User");
51 axdefs[5] = _("Preferred User");
54 axdefs[6] = _("Aide");
60 * Display the login screen
61 * mesg = the error message if last attempt failed.
63 void display_login(void)
66 output_headers(1, 0, 0, 0, 1, 0);
75 /* Initialize the session
77 * This function needs to get called whenever the session changes from
78 * not-logged-in to logged-in, either by an explicit login by the user or
79 * by a timed-out session automatically re-establishing with a little help
80 * from the browser cookie. Either way, we need to load access controls and
81 * preferences from the server.
85 * serv_response The parameters returned from a Citadel USER or NEWU command
87 void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response)
95 if (WCC->wc_fullname == NULL)
96 WCC->wc_fullname = NewStrBufPlain(NULL, StrLength(serv_response));
97 StrBufExtract_token(WCC->wc_fullname, serv_response, 0, '|');
98 StrBufCutLeft(WCC->wc_fullname, 4 );
100 if (WCC->wc_username == NULL)
101 WCC->wc_username = NewStrBufDup(user);
103 FlushStrBuf(WCC->wc_username);
104 StrBufAppendBuf(WCC->wc_username, user, 0);
107 if (WCC->wc_password == NULL)
108 WCC->wc_password = NewStrBufDup(pass);
110 FlushStrBuf(WCC->wc_password);
111 StrBufAppendBuf(WCC->wc_password, pass, 0);
114 WCC->axlevel = StrBufExtract_int(serv_response, 1, '|');
115 if (WCC->axlevel >= 6) {
123 StrBuf_ServGetln(Buf);
124 if (GetServerStatus(Buf, NULL) == 2) {
127 pch = ChrPtr(Buf) + 4;
128 /*WCC->new_mail =*/ StrBufExtractNext_long(Buf, &pch, '|');
129 WCC->need_regi = StrBufExtractNext_long(Buf, &pch, '|');
130 WCC->need_vali = StrBufExtractNext_long(Buf, &pch, '|');
131 if (WCC->cs_inet_email == NULL)
132 WCC->cs_inet_email = NewStrBuf();
133 StrBufExtract_NextToken(WCC->cs_inet_email, Buf, &pch, '|');
135 get_preference("floordiv_expanded", &FloorDiv);
136 WCC->floordiv_expanded = FloorDiv;
143 * modal/ajax version of 'login' (username and password)
145 void ajax_login_username_password(void) {
146 StrBuf *Buf = NewStrBuf();
148 serv_printf("USER %s", bstr("name"));
149 StrBuf_ServGetln(Buf);
150 if (GetServerStatus(Buf, NULL) == 3) {
151 serv_printf("PASS %s", bstr("pass"));
152 StrBuf_ServGetln(Buf);
153 if (GetServerStatus(Buf, NULL) == 2) {
154 become_logged_in(sbstr("name"), sbstr("pass"), Buf);
158 /* The client is expecting to read back a citadel protocol response */
159 wc_printf("%s", ChrPtr(Buf));
166 * modal/ajax version of 'new user' (username and password)
168 void ajax_login_newuser(void) {
169 StrBuf *NBuf = NewStrBuf();
170 StrBuf *SBuf = NewStrBuf();
172 serv_printf("NEWU %s", bstr("name"));
173 StrBuf_ServGetln(NBuf);
174 if (GetServerStatus(NBuf, NULL) == 2) {
175 become_logged_in(sbstr("name"), sbstr("pass"), NBuf);
176 serv_printf("SETP %s", bstr("pass"));
177 StrBuf_ServGetln(SBuf);
180 /* The client is expecting to read back a citadel protocol response */
181 wc_printf("%s", ChrPtr(NBuf));
189 * Try to create an account manually after an OpenID was verified
191 void openid_manual_create(void)
195 /* Did the user change his mind? Pack up and go home. */
196 if (havebstr("exit_action")) {
198 output_headers(1, 0, 0, 0, 1, 0);
199 do_template("authpopup_finished");
205 /* Ok, let's give this a try. Can we create the new user? */
208 serv_printf("OIDC %s", bstr("name"));
209 StrBuf_ServGetln(Buf);
210 if (GetServerStatus(Buf, NULL) == 2) {
214 serv_puts("SETP GENERATE_RANDOM_PASSWORD");
215 StrBuf_ServGetln(gpass);
216 StrBufCutLeft(gpass, 4);
217 become_logged_in(sbstr("name"), gpass, Buf);
222 /* Did we manage to log in? If so, continue with the normal flow... */
226 output_headers(1, 0, 0, 0, 1, 0);
227 do_template("authpopup_finished");
231 /* Still no good! Go back to teh dialog to select a username */
233 putbstr("__claimed_id", NewStrBufDup(sbstr("openid_url")));
235 if (StrLength(Buf) > 0)
236 putbstr("__username", NewStrBufDup(Buf));
238 output_headers(1, 0, 0, 0, 1, 0);
239 wc_printf("<html><body>");
240 do_template("openid_manual_create");
241 wc_printf("</body></html>");
249 * Perform authentication using OpenID
250 * assemble the checkid_setup request and then redirect to the user's identity provider
252 void do_openid_login(void)
256 snprintf(buf, sizeof buf,
257 "OIDS %s|%s/finalize_openid_login|%s",
264 serv_getln(buf, sizeof buf);
266 syslog(LOG_DEBUG, "OpenID server contacted; redirecting to %s\n", &buf[4]);
267 http_redirect(&buf[4]);
272 output_headers(1, 0, 0, 0, 1, 0);
273 wc_printf("<html><body>");
275 wc_printf("</body></html>");
281 * Complete the authentication using OpenID
282 * This function handles the positive or negative assertion from the user's Identity Provider
284 void finalize_openid_login(void)
289 StrBuf *result = NULL;
290 StrBuf *username = NULL;
291 StrBuf *password = NULL;
292 StrBuf *logged_in_response = NULL;
293 StrBuf *claimed_id = NULL;
295 if (havebstr("openid.mode")) {
296 if (!strcasecmp(bstr("openid.mode"), "id_res")) {
299 StrBuf_ServGetln(Buf);
300 if (GetServerStatus(Buf, NULL) == 8) {
308 Cursor = GetNewHashPos (WCC->Hdr->urlstrings, 0);
309 while (GetNextHashPos(WCC->Hdr->urlstrings, Cursor, &HKLen, &HKey, &U)) {
311 if (!strncasecmp(u->url_key, "openid.", 7)) {
312 serv_printf("%s|%s", &u->url_key[7], ChrPtr(u->url_data));
319 while (len = StrBuf_ServGetln(Buf),
321 ((len != 3) || strcmp(ChrPtr(Buf), "000") )))
323 if (linecount == 0) result = NewStrBufDup(Buf);
324 if (!strcasecmp(ChrPtr(result), "authenticate")) {
325 if (linecount == 1) {
326 username = NewStrBufDup(Buf);
328 else if (linecount == 2) {
329 password = NewStrBufDup(Buf);
331 else if (linecount == 3) {
332 logged_in_response = NewStrBufDup(Buf);
335 else if (!strcasecmp(ChrPtr(result), "verify_only")) {
336 if (linecount == 1) {
337 claimed_id = NewStrBufDup(Buf);
339 if (linecount == 2) {
340 username = NewStrBufDup(Buf);
351 * Is this an attempt to associate a new OpenID with an account that is already logged in?
353 if ( (WCC->logged_in) && (havebstr("attach_existing")) ) {
357 /* If this operation logged us in, either by connecting with an existing account or by
358 * auto-creating one using Simple Registration Extension, we're already on our way.
360 else if (!strcasecmp(ChrPtr(result), "authenticate")) {
361 become_logged_in(username, password, logged_in_response);
363 /* Did we manage to log in? If so, continue with the normal flow... */
366 output_headers(1, 0, 0, 0, 1, 0);
367 do_template("authpopup_finished");
371 output_headers(1, 0, 0, 0, 1, 0);
372 wc_printf("<html><body>");
373 wc_printf(_("An error has occurred."));
374 wc_printf("</body></html>");
379 /* The specified OpenID was verified but the desired user name was either not specified via SRE
380 * or conflicts with an existing user. Either way the user will need to specify a new name.
382 else if (!strcasecmp(ChrPtr(result), "verify_only")) {
383 putbstr("__claimed_id", claimed_id);
385 if (StrLength(username) > 0) {
386 putbstr("__username", username);
390 output_headers(1, 0, 0, 0, 1, 0);
391 wc_printf("<html><body>");
392 do_template("openid_manual_create");
393 wc_printf("</body></html>");
397 /* Something went VERY wrong if we get to this point */
399 syslog(1, "finalize_openid_login() failed to do anything. This is a code problem.\n");
401 output_headers(1, 0, 0, 0, 1, 0);
402 wc_printf("<html><body>");
403 wc_printf(_("An error has occurred."));
404 wc_printf("</body></html>");
409 FreeStrBuf(&username);
410 FreeStrBuf(&password);
411 FreeStrBuf(&claimed_id);
412 FreeStrBuf(&logged_in_response);
417 * Display a welcome screen to the user.
419 * If this is the first time login, and the web based setup is enabled,
420 * lead the user through the setup routines
422 void do_welcome(void)
425 #ifdef XXX_NOT_FINISHED_YET_XXX
430 * See if we have to run the first-time setup wizard
435 sprintf(wizard_filename, "setupwiz.%s.%s",
436 abs(HashLittle(ctdlhost, strlen(ctdlhost))),
437 abs(HashLittle(ctdlport, strlen(ctdlport)))
440 fp = fopen(wizard_filename, "r");
442 fgets(buf, sizeof buf, fp);
443 buf[strlen(buf)-1] = 0;
445 if (atoi(buf) == serv_info.serv_rev_level) {
446 setup_wizard = 1; /* already run */
452 http_redirect("setup_wizard");
458 * Go to the user's preferred start page
460 if (!get_preference("startpage", &Buf)) {
462 StrBufPrintf(Buf, "dotskip?room=_BASEROOM_");
463 set_preference("startpage", Buf, 1);
465 if (ChrPtr(Buf)[0] == '/') {
466 StrBufCutLeft(Buf, 1);
468 if (StrLength(Buf) == 0) {
469 StrBufAppendBufPlain(Buf, "dotgoto?room=_BASEROOM_", -1, 0);
471 syslog(9, "Redirecting to user's start page: %s\n", ChrPtr(Buf));
472 http_redirect(ChrPtr(Buf));
477 * Disconnect from the Citadel server, and end this WebCit session
479 void end_webcit_session(void) {
483 /* close() of citadel socket will be done by do_housekeeping() */
488 * Log out the session with the Citadel server
495 FlushStrBuf(WCC->wc_username);
496 FlushStrBuf(WCC->wc_password);
497 FlushStrBuf(WCC->wc_fullname);
501 serv_getln(buf, sizeof buf);
504 FlushStrBuf(WCC->CurRoom.name);
506 /* Calling output_headers() this way causes the cookies to be un-set */
507 output_headers(1, 1, 0, 1, 0, 0);
509 /* For sites in guest mode, redirect to the landing page after we're logged out */
510 if (WC->serv_info->serv_supports_guest) {
511 wc_printf(" <script type=\"text/javascript\"> "
512 " window.location='/'; "
517 wc_printf("<div id=\"logout_screen\">");
518 wc_printf("<div class=\"box\">");
519 wc_printf("<div class=\"boxlabel\">");
520 wc_printf(_("Log off"));
521 wc_printf("</div><div class=\"boxcontent\">");
522 serv_puts("MESG goodbye");
523 serv_getln(buf, sizeof buf);
525 if (WCC->serv_sock >= 0) {
529 wc_printf("Goodbye\n");
533 wc_printf(_("This program was unable to connect or stay "
534 "connected to the Citadel server. Please report "
535 "this problem to your system administrator.")
537 wc_printf("<a href=\"http://www.citadel.org/doku.php/"
538 "faq:mastering_your_os:net#netstat\">%s</a>",
542 wc_printf("<hr /><div class=\"buttons\"> "
543 "<span class=\"button_link\"><a href=\".\">");
544 wc_printf(_("Log in again"));
545 wc_printf("</a></span>");
546 wc_printf("</div></div></div>\n");
547 if (WC->serv_info->serv_supports_guest) {
548 display_default_landing_page();
553 end_webcit_session();
558 * Special page for monitoring scripts etc
562 output_headers(0, 0, 0, 0, 0, 0);
564 hprintf("Content-type: text/plain\r\n"
565 "Server: " PACKAGE_STRING "\r\n"
566 "Connection: close\r\n"
570 wc_printf("Connection to Citadel server at %s:%s : %s\r\n",
572 (WC->connected ? "SUCCESS" : "FAIL")
589 output_headers(1, 1, 1, 0, 0, 0);
591 do_template("box_begin_1");
592 StrBufAppendBufPlain(WC->WBuf, _("Validate new users"), -1, 0);
593 do_template("box_begin_2");
595 /* If the user just submitted a validation, process it... */
596 safestrncpy(buf, bstr("user"), sizeof buf);
597 if (!IsEmptyStr(buf)) {
598 if (havebstr("axlevel")) {
599 serv_printf("VALI %s|%s", buf, bstr("axlevel"));
600 serv_getln(buf, sizeof buf);
602 wc_printf("<b>%s</b><br>\n", &buf[4]);
607 /* Now see if any more users require validation. */
609 serv_getln(buf, sizeof buf);
612 wc_printf(_("No users require validation at this time."));
613 wc_printf("</b><br>\n");
618 wc_printf("<b>%s</b><br>\n", &buf[4]);
623 wc_printf("<table class=\"auth_validate\"><tr><td>\n");
624 wc_printf("<div id=\"validate\">");
626 safestrncpy(user, &buf[4], sizeof user);
627 serv_printf("GREG %s", user);
628 serv_getln(cmd, sizeof cmd);
632 serv_getln(buf, sizeof buf);
635 wc_printf("#%s<br><H1>%s</H1>",
644 while (!IsEmptyStr(pch))
648 else if (isalpha(*pch))
662 pch = _("very weak");
675 wc_printf("PW: %s<br>\n", pch);
678 wc_printf("%s<br>\n", buf);
680 wc_printf("%s<br>\n", buf);
682 wc_printf("%s, ", buf);
684 wc_printf("%s ", buf);
686 wc_printf("%s<br>\n", buf);
688 wc_printf("%s<br>\n", buf);
690 wc_printf(_("Current access level: %d (%s)\n"),
691 atoi(buf), axdefs[atoi(buf)]);
692 } while (strcmp(buf, "000"));
694 wc_printf("<H1>%s</H1>%s<br>\n", user, &cmd[4]);
698 wc_printf(_("Select access level for this user:"));
700 for (a = 0; a <= 6; ++a) {
701 wc_printf("<a href=\"validate?nonce=%d?user=", WC->nonce);
703 wc_printf("&axlevel=%d\">%s</A> \n",
708 wc_printf("</div>\n");
709 wc_printf("</td></tr></table>\n");
710 do_template("box_end");
716 * Display form for registration.
718 * (Set during_login to 1 if this registration is being performed during
719 * new user login and will require chaining to the proper screen.)
721 void display_reg(int during_login)
725 message_summary *VCMsg = NULL;
726 wc_mime_attachment *VCAtt = NULL;
730 memset(&Room, 0, sizeof(folder));
731 if (goto_config_room(Buf, &Room) != 0) {
732 syslog(9, "display_reg() exiting because goto_config_room() failed\n");
746 vcard_msgnum = locate_user_vcard_in_this_room(&VCMsg, &VCAtt);
747 if (vcard_msgnum < 0L) {
748 syslog(9, "display_reg() exiting because locate_user_vcard_in_this_room() failed\n");
759 do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "pop", USERCONFIGROOM);
763 ReturnTo = NewStrBufPlain(HKEY("display_main_menu?go="));
764 StrBufAppendBuf(ReturnTo, WC->CurRoom.name, 0);
765 do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, ChrPtr(ReturnTo), USERCONFIGROOM);
766 FreeStrBuf(&ReturnTo);
773 * display form for changing your password
775 void display_changepw(void)
778 WCTemplputParams SubTP;
781 output_headers(1, 1, 1, 0, 0, 0);
783 Buf = NewStrBufPlain(_("Change your password"), -1);
784 memset(&SubTP, 0, sizeof(WCTemplputParams));
785 SubTP.Filter.ContextType = CTX_STRBUF;
787 DoTemplate(HKEY("box_begin"), NULL, &SubTP);
791 if (StrLength(WCC->ImportantMsg) > 0) {
792 wc_printf("<span class=\"errormsg\">"
793 "%s</span><br>\n", ChrPtr(WCC->ImportantMsg));
794 FlushStrBuf(WCC->ImportantMsg);
797 serv_puts("MESG changepw");
798 serv_getln(buf, sizeof buf);
803 wc_printf("<form name=\"changepwform\" action=\"changepw\" method=\"post\">\n");
804 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
805 wc_printf("<table class=\"altern\" ");
806 wc_printf("<tr class=\"even\"><td>");
807 wc_printf(_("Enter new password:"));
808 wc_printf("</td><td>");
809 wc_printf("<input type=\"password\" name=\"newpass1\" value=\"\" maxlength=\"20\"></td></tr>\n");
810 wc_printf("<tr class=\"odd\"><td>");
811 wc_printf(_("Enter it again to confirm:"));
812 wc_printf("</td><td>");
813 wc_printf("<input type=\"password\" name=\"newpass2\" value=\"\" maxlength=\"20\"></td></tr>\n");
814 wc_printf("</table>\n");
816 wc_printf("<div class=\"buttons\">\n");
817 wc_printf("<input type=\"submit\" name=\"change_action\" value=\"%s\">", _("Change password"));
819 wc_printf("<input type=\"submit\" name=\"cancel_action\" value=\"%s\">\n", _("Cancel"));
820 wc_printf("</div>\n");
821 wc_printf("</form>\n");
823 do_template("box_end");
829 * if passwords match, propagate it to citserver.
834 char newpass1[32], newpass2[32];
836 if (!havebstr("change_action")) {
837 AppendImportantMessage(_("Cancelled. Password was not changed."), -1);
842 safestrncpy(newpass1, bstr("newpass1"), sizeof newpass1);
843 safestrncpy(newpass2, bstr("newpass2"), sizeof newpass2);
845 if (strcasecmp(newpass1, newpass2)) {
846 AppendImportantMessage(_("They don't match. Password was not changed."), -1);
851 if (IsEmptyStr(newpass1)) {
852 AppendImportantMessage(_("Blank passwords are not allowed."), -1);
858 serv_printf("SETP %s", newpass1);
859 StrBuf_ServGetln(Line);
860 if (GetServerStatusMsg(Line, NULL, 1, 0) == 2) {
861 if (WC->wc_password == NULL)
862 WC->wc_password = NewStrBufPlain(
864 StrLength(Line) - 4);
866 FlushStrBuf(WC->wc_password);
867 StrBufAppendBufPlain(WC->wc_password,
869 StrLength(Line) - 4, 0);
880 int ConditionalHaveAccessCreateRoom(StrBuf *Target, WCTemplputParams *TP)
886 StrBuf_ServGetln(Buf);
888 if (GetServerStatus(Buf, NULL) == 2) {
889 StrBufCutLeft(Buf, 4);
890 AppendImportantMessage(SKEY(Buf));
899 int ConditionalAide(StrBuf *Target, WCTemplputParams *TP)
902 return (WCC != NULL) ? ((WCC->logged_in == 0)||(WC->is_aide == 0)) : 0;
906 int ConditionalIsLoggedIn(StrBuf *Target, WCTemplputParams *TP)
909 return (WCC != NULL) ? (WCC->logged_in == 0) : 0;
915 * toggle the session over to a different language
917 void switch_language(void) {
918 set_selected_language(bstr("lang"));
923 void _display_reg(void) {
928 void Header_HandleAuth(StrBuf *Line, ParsedHttpHdrs *hdr)
930 if (hdr->HR.got_auth == NO_AUTH) /* don't override cookie auth... */
932 if (strncasecmp(ChrPtr(Line), "Basic", 5) == 0) {
933 StrBufCutLeft(Line, 6);
934 StrBufDecodeBase64(Line);
935 hdr->HR.plainauth = Line;
936 hdr->HR.got_auth = AUTH_BASIC;
939 syslog(1, "Authentication scheme not supported! [%s]\n", ChrPtr(Line));
944 void CheckAuthBasic(ParsedHttpHdrs *hdr)
947 todo: enable this if we can have other sessions than authenticated ones.
948 if (hdr->DontNeedAuth)
951 StrBufAppendBufPlain(hdr->HR.plainauth, HKEY(":"), 0);
952 StrBufAppendBuf(hdr->HR.plainauth, hdr->HR.user_agent, 0);
953 hdr->HR.SessionKey = hashlittle(SKEY(hdr->HR.plainauth), 89479832);
955 syslog(1, "CheckAuthBasic: calculated sessionkey %ld\n",
961 void GetAuthBasic(ParsedHttpHdrs *hdr)
963 const char *Pos = NULL;
964 if (hdr->c_username == NULL)
965 hdr->c_username = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
966 if (hdr->c_password == NULL)
967 hdr->c_password = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
968 StrBufExtract_NextToken(hdr->c_username, hdr->HR.plainauth, &Pos, ':');
969 StrBufExtract_NextToken(hdr->c_password, hdr->HR.plainauth, &Pos, ':');
973 void Header_HandleCookie(StrBuf *Line, ParsedHttpHdrs *hdr)
977 todo: enable this if we can have other sessions than authenticated ones.
978 if (hdr->DontNeedAuth)
981 pch = strstr(ChrPtr(Line), "webcit=");
986 hdr->HR.RawCookie = Line;
987 StrBufCutLeft(hdr->HR.RawCookie, (pch - ChrPtr(hdr->HR.RawCookie)) + 7);
988 StrBufDecodeHex(hdr->HR.RawCookie);
990 cookie_to_stuff(Line, &hdr->HR.desired_session,
996 hdr->HR.got_auth = AUTH_COOKIE;
1002 (ParsedHttpHdrs *httpreq)
1004 httpreq->c_username = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_USER));
1005 httpreq->c_password = NewStrBufPlain(HKEY(DEFAULT_HTTPAUTH_PASS));
1006 httpreq->c_roomname = NewStrBuf();
1007 httpreq->c_language = NewStrBuf();
1012 HttpDetachModule_AUTH
1013 (ParsedHttpHdrs *httpreq)
1015 FLUSHStrBuf(httpreq->c_username);
1016 FLUSHStrBuf(httpreq->c_password);
1017 FLUSHStrBuf(httpreq->c_roomname);
1018 FLUSHStrBuf(httpreq->c_language);
1023 HttpDestroyModule_AUTH
1024 (ParsedHttpHdrs *httpreq)
1026 FreeStrBuf(&httpreq->c_username);
1027 FreeStrBuf(&httpreq->c_password);
1028 FreeStrBuf(&httpreq->c_roomname);
1029 FreeStrBuf(&httpreq->c_language);
1037 initialize_axdefs();
1038 RegisterHeaderHandler(HKEY("COOKIE"), Header_HandleCookie);
1039 RegisterHeaderHandler(HKEY("AUTHORIZATION"), Header_HandleAuth);
1041 /* no url pattern at all? Show login. */
1042 WebcitAddUrlHandler(HKEY(""), "", 0, do_welcome, ANONYMOUS|COOKIEUNNEEDED);
1044 WebcitAddUrlHandler(HKEY("do_welcome"), "", 0, do_welcome, ANONYMOUS|COOKIEUNNEEDED);
1045 WebcitAddUrlHandler(HKEY("openid_login"), "", 0, do_openid_login, ANONYMOUS);
1046 WebcitAddUrlHandler(HKEY("finalize_openid_login"), "", 0, finalize_openid_login, ANONYMOUS);
1047 WebcitAddUrlHandler(HKEY("openid_manual_create"), "", 0, openid_manual_create, ANONYMOUS);
1048 WebcitAddUrlHandler(HKEY("validate"), "", 0, validate, 0);
1049 WebcitAddUrlHandler(HKEY("do_welcome"), "", 0, do_welcome, 0);
1050 WebcitAddUrlHandler(HKEY("display_reg"), "", 0, _display_reg, 0);
1051 WebcitAddUrlHandler(HKEY("display_changepw"), "", 0, display_changepw, 0);
1052 WebcitAddUrlHandler(HKEY("changepw"), "", 0, changepw, 0);
1053 WebcitAddUrlHandler(HKEY("termquit"), "", 0, do_logout, 0);
1054 WebcitAddUrlHandler(HKEY("do_logout"), "", 0, do_logout, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
1055 WebcitAddUrlHandler(HKEY("monitor"), "", 0, monitor, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
1056 WebcitAddUrlHandler(HKEY("ajax_login_username_password"), "", 0, ajax_login_username_password, AJAX|ANONYMOUS);
1057 WebcitAddUrlHandler(HKEY("ajax_login_newuser"), "", 0, ajax_login_newuser, AJAX|ANONYMOUS);
1058 WebcitAddUrlHandler(HKEY("switch_language"), "", 0, switch_language, ANONYMOUS);
1059 RegisterConditional(HKEY("COND:AIDE"), 2, ConditionalAide, CTX_NONE);
1060 RegisterConditional(HKEY("COND:LOGGEDIN"), 2, ConditionalIsLoggedIn, CTX_NONE);
1061 RegisterConditional(HKEY("COND:MAY_CREATE_ROOM"), 2, ConditionalHaveAccessCreateRoom, CTX_NONE);
1067 SessionDestroyModule_AUTH
1070 FreeStrBuf(&sess->wc_username);
1071 FreeStrBuf(&sess->wc_fullname);
1072 FreeStrBuf(&sess->wc_password);
1073 FreeStrBuf(&sess->httpauth_pass);
1074 FreeStrBuf(&sess->cs_inet_email);