2011-12-10 114 views
0

我是OpenID概念的新手,最近嘗試使用JanRain PHP 5系統爲CodeIgniter實施OpenID Library。但是遇到了一些問題,而來自谷歌和雅虎網站檢索簡單的數據...Codeigniter OpenID身份驗證

對OpenID的圖書館我的配置文件看起來像這樣:

<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); 
    $config['openid_storepath'] = 'tmp'; 
    $config['openid_policy'] = 'test/policy'; 
    $config['openid_required'] = array('email'); 
    $config['openid_optional'] = array('fullname'); 
    $config['openid_request_to'] = 'test/check'; 
?> 

然而,我無法獲得任何的'email'或'fullname'的值。我嘗試填寫其他字段(比如「暱稱」),但那也沒有產生結果。此外,JanRain docs中指定的許多其他選項(例如'verifiedEmail'和'preferredUsername')僅導致了SREG錯誤。

驗證成功,因爲它們返回成功消息,但我如何訪問我請求的信息?

編輯:這裏是返回URL:

http://www.{Site}.net/v2/test/check?janrain_nonce=2011-12-10T05:53:01ZFXVT02&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.return_to=http%3A%2F%2Fwww.{Site}.net%2Fv2%2Ftest%2Fcheck%3Fjanrain_nonce%3D2011-12-10T05%3A53%3A01ZFXVT02&openid.claimed_id=https%3A%2F%2Fme.yahoo.com%2Fa%2F{Token}%23df6f7&openid.identity=https%3A%2F%2Fme.yahoo.com%2Fa%2F{Token}&openid.assoc_handle={Handle}&openid.realm=http%3A%2F%2Fwww.{Site}.net%2Fv2%2F&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.response_nonce=2011-12-10T05%3A53%3{Nonce Token}&openid.signed=assoc_handle%2Cclaimed_id%2Cidentity%2Cmode%2Cns%2Cop_endpoint%2Cresponse_nonce%2Creturn_to%2Csigned%2Cpape.auth_level.nist&openid.op_endpoint=https%3A%2F%2Fopen.login.yahooapis.com%2Fopenid%2Fop%2Fauth&openid.pape.auth_level.nist=0&openid.sig=CUa39ZjhGE8nWc7TMvbS8UFlwjQ%3D 

謝謝!

+0

請參閱此。 http://thinkmoult.com/2009/02/22/use-codeigniter-openid-library-to-integrate-openid/ –

+0

@RohanPatil我一直在關注該指南並閱讀一些評論,但尚未找到解決方案... – drfranks3

+0

@DFranks我假設你已經將用戶重定向到yahoo/google,並且他們已經登錄並被重定向回到你的application.if是這種情況你能顯示URL和它的參數嗎? –

回答

0

我不能幫你在PHP中,但可以告訴你的代碼,我的,而我對雅虎這一創建AuthenticationUrl()其工作雅虎

用Java開發的是我在做什麼

StringBuilder sb = new StringBuilder(1024); 
     sb.append(endpoint.getUrl()) 
      .append(endpoint.getUrl().contains("?") ? '&' : '?') 
      .append(getAuthQuery(endpoint.getAlias())) 
      .append("&openid.return_to=") 
      .append(returnToUrlEncode) 
      .append("&openid.assoc_handle=") 

這裏是我的getAuthQuery功能

String getAuthQuery(String axa) { 
     if (authQuery!=null) 
      return authQuery; 
     List<String> list = new ArrayList<String>(); 
     list.add("openid.ns=http://specs.openid.net/auth/2.0"); 
     list.add("openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select"); 
     list.add("openid.identity=http://specs.openid.net/auth/2.0/identifier_select"); 
     list.add("openid.mode=checkid_setup"); 
     list.add("openid.ns." + axa + "=http://openid.net/srv/ax/1.0"); 
     list.add("openid." + axa + ".mode=fetch_request"); 
     list.add("openid." + axa + ".type.email=http://axschema.org/contact/email"); 
     list.add("openid." + axa + ".type.fullname=http://axschema.org/namePerson"); 
     list.add("openid." + axa + ".type.language=http://axschema.org/pref/language"); 
     list.add("openid." + axa + ".type.firstname=http://axschema.org/namePerson/first"); 
     list.add("openid." + axa + ".type.lastname=http://axschema.org/namePerson/last"); 
     list.add("openid." + axa + ".type.gender=http://axschema.org/person/gender"); 
     list.add("openid." + axa + ".required=email,fullname,language,firstname,lastname,gender"); 
     String query = Utils.buildQuery(list); 
     authQuery = query; 
     return query; 
    } 

希望這會給你知道如何使用屬性交換。

+0

非常感謝!除了你的代碼,這[替換](http://codeigniter.com/wiki/A3M_Account_Authentication_and_Authorization)幫助解決了我的問題。 :) – drfranks3