long len;
void *Value;
const char *Key;
+ long usernum = 0L;
keys = NewHash(1, NULL);
if (!keys) return;
cdb_rewind(CDB_OPENID);
while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) {
if (cdboi->len > sizeof(long)) {
- if (((long)*(cdboi->ptr)) == usbuf->usernum) {
+ memcpy(&usernum, cdboi->ptr, sizeof(long));
+ if (usernum == usbuf->usernum) {
deleteme = strdup(cdboi->ptr + sizeof(long)),
Put(keys, deleteme, strlen(deleteme), deleteme, generic_free_handler);
}
*/
void cmd_oidl(char *argbuf) {
struct cdbdata *cdboi;
+ long usernum = 0L;
if (CtdlAccessCheck(ac_logged_in)) return;
cdb_rewind(CDB_OPENID);
while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) {
if (cdboi->len > sizeof(long)) {
- if (((long)*(cdboi->ptr)) == CC->user.usernum) {
+ memcpy(&usernum, cdboi->ptr, sizeof(long));
+ if (usernum == CC->user.usernum) {
cprintf("%s\n", cdboi->ptr + sizeof(long));
}
}
}
+/*
+ * List ALL OpenIDs in the database
+ */
+void cmd_oida(char *argbuf) {
+ struct cdbdata *cdboi;
+ long usernum;
+ struct ctdluser usbuf;
+
+ if (CtdlAccessCheck(ac_aide)) return;
+ cdb_rewind(CDB_OPENID);
+ cprintf("%d List of all OpenIDs in the database:\n", LISTING_FOLLOWS);
+
+ 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) {
+ usbuf.fullname[0] = 0;
+ }
+ cprintf("%s|%ld|%s\n",
+ cdboi->ptr + sizeof(long),
+ usernum,
+ usbuf.fullname
+ );
+ }
+ cdb_free(cdboi);
+ }
+ cprintf("000\n");
+}
+
+
/*
* Attempt to register (populate the vCard) the currently-logged-in user
* using the data from Simple Registration Extension, if present.
void cmd_oidc(char *argbuf) {
struct ctdl_openid *oiddata = (struct ctdl_openid *) CC->openid_data;
+ if (!oiddata) {
+ cprintf("%d You have not verified an OpenID yet.\n", ERROR);
+ return;
+ }
+
if (!oiddata->verified) {
cprintf("%d You have not verified an OpenID yet.\n", ERROR);
return;
struct cdbdata *cdboi;
char id_to_detach[1024];
int this_is_mine = 0;
+ long usernum = 0L;
if (CtdlAccessCheck(ac_logged_in)) return;
extract_token(id_to_detach, argbuf, 0, '|', sizeof id_to_detach);
cdb_rewind(CDB_OPENID);
while (cdboi = cdb_next_item(CDB_OPENID), cdboi != NULL) {
if (cdboi->len > sizeof(long)) {
- if (((long)*(cdboi->ptr)) == CC->user.usernum) {
+ memcpy(&usernum, cdboi->ptr, sizeof(long));
+ if (usernum == CC->user.usernum) {
this_is_mine = 1;
}
}
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, fh_callback);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errmsg);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
+#ifdef CURLOPT_HTTP_CONTENT_DECODING
curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 1);
curl_easy_setopt(curl, CURLOPT_ENCODING, "");
+#endif
curl_easy_setopt(curl, CURLOPT_USERAGENT, CITADEL);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180); /* die after 180 seconds */
if (!IsEmptyStr(config.c_ip_addr)) {
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errmsg);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
+#ifdef CURLOPT_HTTP_CONTENT_DECODING
curl_easy_setopt(curl, CURLOPT_HTTP_CONTENT_DECODING, 1);
curl_easy_setopt(curl, CURLOPT_ENCODING, "");
+#endif
curl_easy_setopt(curl, CURLOPT_USERAGENT, CITADEL);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 180); /* die after 180 seconds */
if (!IsEmptyStr(config.c_ip_addr)) {
if (CC->logged_in) {
if (attach_openid(&CC->user, oiddata->claimed_id) == 0) {
cprintf("attach\n");
+ CtdlLogPrintf(CTDL_DEBUG, "OpenID attach succeeded\n");
}
else {
cprintf("fail\n");
+ CtdlLogPrintf(CTDL_DEBUG, "OpenID attach failed\n");
}
}
if (login_via_openid(oiddata->claimed_id) == 0) {
cprintf("authenticate\n%s\n%s\n", CC->user.fullname, CC->user.password);
logged_in_response();
+ CtdlLogPrintf(CTDL_DEBUG, "Logged in using previously claimed OpenID\n");
}
/*
*/
else if (config.c_disable_newu) {
cprintf("fail\n");
+ CtdlLogPrintf(CTDL_DEBUG, "Creating user failed due to local policy\n");
}
/*
else if (openid_create_user_via_sreg(oiddata->claimed_id, keys) == 0) {
cprintf("authenticate\n%s\n%s\n", CC->user.fullname, CC->user.password);
logged_in_response();
+ CtdlLogPrintf(CTDL_DEBUG, "Successfully auto-created new user\n");
}
/*
else {
cprintf("\n");
}
+ CtdlLogPrintf(CTDL_DEBUG, "The desired Simple Registration name is already taken.\n");
}
}
}
CtdlRegisterProtoHook(cmd_oidl, "OIDL", "List OpenIDs associated with an account");
CtdlRegisterProtoHook(cmd_oidd, "OIDD", "Detach an OpenID from an account");
CtdlRegisterProtoHook(cmd_oidc, "OIDC", "Create new user after validating OpenID");
+ CtdlRegisterProtoHook(cmd_oida, "OIDA", "List all OpenIDs in the database");
}
CtdlRegisterSessionHook(openid_cleanup_function, EVT_LOGOUT);
CtdlRegisterUserHook(openid_purge, EVT_PURGEUSER);