Test of branch
[citadel.git] / citadel / modules / openid / serv_openid_rp.c
index 5171399efb14442933f44d4494430e90628cecf6..71bb0b93ae23b9bf698699755c1768894c7a9b0d 100644 (file)
@@ -1,5 +1,9 @@
 /*
  * This is an implementation of OpenID 2.0 RELYING PARTY SUPPORT CURRENTLY B0RKEN AND BEING DEVEL0PZ0RED
+
+
+                       OPENID2 BRANCH
+
  *
  * Copyright (c) 2007-2011 by the citadel.org team
  *
@@ -739,7 +743,6 @@ int perform_openid2_discovery(StrBuf *YadisURL) {
        char errmsg[1024] = "";
        struct curl_slist *my_headers = NULL;
        StrBuf *x_xrds_location = NULL;
-       ctdl_openid *oiddata = (ctdl_openid *) CC->openid_data;
 
        if (YadisURL == NULL) return(0);
        syslog(LOG_DEBUG, "perform_openid2_discovery(%s)", ChrPtr(YadisURL));
@@ -807,10 +810,12 @@ int perform_openid2_discovery(StrBuf *YadisURL) {
         */
        if (return_value == 0) {
                syslog(LOG_DEBUG, "Attempting HTML discovery");
-               extract_link(oiddata->server, HKEY("openid2.provider"), ReplyBuf);
-               if (StrLength(oiddata->server) > 0) {
-                       syslog(LOG_DEBUG, "\033[31mHTML DISCO PROVIDER: %s\033[0m", ChrPtr(oiddata->server));
+               StrBuf *foo = NewStrBuf();
+               extract_link(foo, HKEY("openid2.provider"), ReplyBuf);
+               if (StrLength(foo) > 0) {
+                       syslog(LOG_DEBUG, "\033[31mHTML DISCO PROVIDER: %s\033[0m", ChrPtr(foo));
                }
+               FreeStrBuf(&foo);
        }
 
        if (ReplyBuf != NULL) {
@@ -824,6 +829,7 @@ int perform_openid2_discovery(StrBuf *YadisURL) {
  * Setup an OpenID authentication
  */
 void cmd_oids(char *argbuf) {
+       struct CitContext *CCC = CC;    /* CachedCitContext - performance boost */
        const char *Pos = NULL;
        StrBuf *ArgBuf = NULL;
        StrBuf *ReplyBuf = NULL;
@@ -831,8 +837,8 @@ void cmd_oids(char *argbuf) {
        StrBuf *trust_root = NULL;
        StrBuf *openid_delegate = NULL;
        StrBuf *RedirectUrl = NULL;
-       struct CitContext *CCC = CC;    /* CachedCitContext - performance boost */
        ctdl_openid *oiddata;
+       int discovery_succeeded = 0;
 
        Free_ctdl_openid ((ctdl_openid**)&CCC->openid_data);
 
@@ -867,15 +873,13 @@ void cmd_oids(char *argbuf) {
 
        /* Attempt section 7.3.2 (Yadis discovery) and section 7.3.3 (HTML discovery);
         */
-       int yadis_succeeded = perform_openid2_discovery(oiddata->claimed_id);
+       discovery_succeeded = perform_openid2_discovery(oiddata->claimed_id);
 
 
 
+       /************ OPENID 1.1 **********/
 
-#if 0
-       /* old openid 1.1 implementation ... not ready to break things yet */
-       if (    (yadis_succeeded == 0)
-               && (fetch_http(oiddata->claimed_id, &ReplyBuf) > 0)
+       if (    (fetch_http(oiddata->claimed_id, &ReplyBuf) > 0)
                && (StrLength(ReplyBuf) > 0)
        ) {
                openid_delegate = NewStrBuf();
@@ -927,7 +931,6 @@ void cmd_oids(char *argbuf) {
 
                return;
        }
-#endif /* 0 */
 
        FreeStrBuf(&ArgBuf);
        FreeStrBuf(&ReplyBuf);