]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/openid/serv_openid_rp.c
* cmd_oidf(): if we don't have ha Server to authenticate against, bail with ILLEGAL_VALUE
[citadel.git] / citadel / modules / openid / serv_openid_rp.c
index cfd85cd4722dfb7d0b1efdf5be6d92fed0f961d2..16f189e0d2f58e2f04591bd14a8b226db709d12d 100644 (file)
@@ -3,6 +3,21 @@
  *
  * This is an implementation of OpenID 1.1 Relying Party support, in stateless mode.
  *
+ * Copyright (c) 2007-2009 by the citadel.org team
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
 #include "sysdep.h"
@@ -114,7 +129,7 @@ int attach_openid(struct ctdluser *who, char *claimed_id)
 
        snprintf(buf, sizeof buf, "User <%s> (#%ld) has claimed the OpenID URL %s\n",
                who->fullname, who->usernum, claimed_id);
-       aide_message(buf, "OpenID claim");
+       CtdlAideMessage(buf, "OpenID claim");
        CtdlLogPrintf(CTDL_INFO, "%s", buf);
        return(0);
 }
@@ -204,7 +219,7 @@ void cmd_oida(char *argbuf) {
        while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) {
                if (cdboi->len > sizeof(long)) {
                        memcpy(&usernum, cdboi->ptr, sizeof(long));
-                       if (getuserbynumber(&usbuf, usernum) != 0) {
+                       if (CtdlGetUserByNumber(&usbuf, usernum) != 0) {
                                usbuf.fullname[0] = 0;
                        } 
                        cprintf("%s|%ld|%s\n",
@@ -389,7 +404,7 @@ int openid_create_user_via_sreg(char *claimed_id, HashList *sreg_keys)
 
        CtdlLogPrintf(CTDL_DEBUG, "The desired account name is <%s>\n", desired_name);
 
-       if (!getuser(&CC->user, desired_name)) {
+       if (!CtdlGetUser(&CC->user, desired_name)) {
                CtdlLogPrintf(CTDL_DEBUG, "<%s> is already taken by another user.\n", desired_name);
                memset(&CC->user, 0, sizeof(struct ctdluser));
                return(5);
@@ -423,7 +438,7 @@ int login_via_openid(char *claimed_id)
        memcpy(&usernum, cdboi->ptr, sizeof(long));
        cdb_free(cdboi);
 
-       if (!getuserbynumber(&CC->user, usernum)) {
+       if (!CtdlGetUserByNumber(&CC->user, usernum)) {
                /* Now become the user we just created */
                safestrncpy(CC->curr_user, CC->user.fullname, sizeof CC->curr_user);
                do_login();
@@ -450,7 +465,7 @@ int login_via_openid(char *claimed_id)
  */
 void extract_link(char *target_buf, int target_size, char *rel, char *source_buf)
 {
-       char *ptr = source_buf;
+       const char *ptr = source_buf;
 
        if (!target_buf) return;
        if (!rel) return;
@@ -478,7 +493,7 @@ void extract_link(char *target_buf, int target_size, char *rel, char *source_buf
                        if (len > sizeof work_buffer) len = sizeof work_buffer;
                        memcpy(work_buffer, link_tag_start, len);
                
-                       char *rel_start = NULL;
+                       const char *rel_start = NULL;
                        char *rel_end = NULL;
                        rel_start = bmstrcasestr(work_buffer, "rel=");
                        if (rel_start) {
@@ -708,6 +723,10 @@ void cmd_oidf(char *argbuf) {
                cprintf("%d NewHash() failed\n", ERROR + INTERNAL_ERROR);
                return;
        }
+       if (IsEmptyStr(oiddata->server)){
+               cprintf("%d need a remote server to authenticate against\n", ERROR + ILLEGAL_VALUE);
+               return;
+       }
        
        cprintf("%d Transmit OpenID data now\n", START_CHAT_MODE);