« Blogging via Flickr is failed. | Main | 今日は一日半袖でした。 »

04 March 2008

OpenID Authentication 2.0 について少し

OpenID Hack-a-thonCodeReposのOpenID対応builder techday などで実装レベルにおける OpenID 2.0 対応が少しずつ身近なものになってきました。OpenID 1.1OpenID 2.0 の違いについては、id:ZIGOROuさんの @IT の記事builder techday での Lightning Talk が参考になると思います。

OpenID 1.1 と OpenID 2.0 の違いを簡単にいえば、

  • Identifier に URL と XRI が使えるようになった
  • Discovery の方式が変わった

といった辺りがポイントでしょうか。


Identifier に URL と XRI が使えるようになった

XRI (EXtensive Resource Identifier) については OpenID 2.0 の仕様書の Normative Reference にあります、[XRIResolution2.0] と [XRISyntax2.0] を参考にすると XRI の仕様が分かります。[XRIResolution2.0] で XRDS (EXtensive Resource Descripter Sequence) 文書を含む XRI を取り囲む仕様が、 [XRISyntax2.0] では XRI のシンタックスについての仕様が書かれています。XML関係で標準化を進める団体 OASIS の下で作成されました。XRI も URL と同様にあるリソースをユニークにするものです。なので、Identifier として利用することが出来るわけです。XRI については仕様をよく読めば理解できるかなと思います。


Discovery の方式が変わった

これは大きな変化です。例えば、fastladder.com で yahoo.com の OpenID を使おうとしたときに(すでに 「Sign in with Yahoo! ID」ボタンがあるのでアレなんですけど)、「yahoo.com」と入力しただけでOpenID プロバイダの認証ページにリダイレクトされるようになります。OpenID 1.1 のころですと、comewalk.livejournal.com のように長い URL の入力が必要でしたが、ドメインだけで充分になっています。OpenID 1.1 のころは comewalk.livejournal.com ならば以下のような Link Discovery が HTML ページのHEAD セクションにありました。

<link rel="openid.server" href="http://www.livejournal.com/openid/server.bml"/><link rel="openid.delegate" href="http://comewalk.livejournal.com/"/>

これが大きく変わります。OpenID 2.0 の仕様の 7.3 Discovery が参考になります。

1. If the identifier is an XRI, [XRI_Resolution_2.0] (Wachob, G., Reed, D., Chasen, L., Tan, W., and S. Churchill, "Extensible Resource Identifier (XRI) Resolution V2.0 - Committee Draft 02," .) will yield an XRDS document that contains the necessary information. It should also be noted that Relying Parties can take advantage of XRI Proxy Resolvers, such as the one provided by XDI.org at http://www.xri.net. This will remove the need for the RPs to perform XRI Resolution locally. 2. If it is a URL, the Yadis protocol (Miller, J., "Yadis Specification 1.0," .) [Yadis] SHALL be first attempted. If it succeeds, the result is again an XRDS document. 3. If the Yadis protocol fails and no valid XRDS document is retrieved, or no Service Elements (OpenID Service Elements) are found in the XRDS document, the URL is retrieved and HTML-Based discovery (HTML-Based Discovery) SHALL be attempted.

意訳すると、1.XRIが入力されたならばXRI Resolutionに従ってXRDS文書を探します。2.URLが入力されたならばYadisプロトコルでXRDS文書を探します。3.Yadisもダメ、XRDS文書もinvalidで、サービス要素である<xsd:Service>もない。ならば、HTMLのlink要素をみてみます。という具合です。

さらに以下の記述も変わります。

<link rel="openid.server" href="http://www.livejournal.com/openid/server.bml" /><link rel="openid.delegate" href="http://comewalk.livejournal.com/" />

OpenID 2.0 対応では次のようになります。サンプルが仕様書にあります。

<link rel="openid2.provider" href="http://www.livejournal.com/openid/server.bml" ><link rel="openid2.local_id" href="http://comewalk.livejournal.com/" />

OpenID 1.1 と OpenID 2.0 を共存させるには、rel属性に両方を書きます。

<link rel="openid2.provider openid.server" href="http://www.livejournal.com/openid/server.bml" /><link rel="openid2.local_id openid.delegate" href="http://comewalk.livejournal.com/" />

ところで、www.yahoo.com の HTML を見ても、OpenID の Discovery らしきものは見当たりません。Yadis の仕様書を見たらこんな記述がありました。

6.2.4 InitiationThe Yadis Protocol is initiated by the Relying Party Agent with an initial HTTP request using theYadis URL.This request MUST be either a GET or a HEAD request.A GET or HEAD request MAY include an HTTP Accept request-header (HTTP 14.1) specifying MIMEmedia type, application/xrds+xml.

GETかHEADで取ると。必要であれば Accept: application/xrds+xml を付けようと。

で試してみました。

comewalk:~ takatsugu$ telnet www.yahoo.com 80Trying 209.131.36.158...Connected to www.yahoo-ht3.akadns.net.Escape character is '^]'.HEAD / HTTP/1.1Host: www.yahoo.comAccept: applilcation/xrds+xmlHTTP/1.1 200 OKDate: Tue, 04 Mar 2008 15:31:02 GMTP3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV"Cache-Control: privateVary: User-AgentX-XRDS-Location: http://open.login.yahooapis.com/openid20/www.yahoo.com/xrdsLast-Modified: Tue, 04 Mar 2008 15:22:48 GMTAccept-Ranges: bytesContent-Length: 9533Connection: closeContent-Type: text/html; charset=utf-8

X-XRDS-Location: http://open.login.yahooapis.com/openid20/www.yahoo.com/xrds

というのがかえってきました。yahoo.com は HEAD で取得できるようですね。で、http://open.login.yahooapis.com/openid20/www.yahoo.com/xrds というファイルが XRDS文書なのです。見ると

<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns:openid="http://openid.net/xmlns/1.0" xmlns="xri://$xrd*($v*2.0)"> <xrd>  <Service priority="0">   <Type>http://specs.openid.net/auth/2.0/server</Type>   <Type>http://specs.openid.net/extensions/pape/1.0</Type>   <uri>https://open.login.yahooapis.com/openid/op/auth</uri>  </Service> </xrd></xrds:XRDS>

となっていて XPath でいうと /XRD/Service/URIなところにURLがありますね。そこが OpenID Provider の URL なのです。HTML の link要素から取得しないあたりがもう全然違っていて、面白いですね。これでやっと OpenID 2.0 の Discovery が理解できてきたのでアレをああしてこうできそうです。


まとめ

bradfitzやDavid Recordon、miyagawaさんやkazeburoさんなどのおかげで Net::OpenID::Consumer と Net::OpenID::Server が OpenID 2.0 に対応し、Six Apart の subversion repository から入手することができます。

svn co http://code.sixapart.com/svn/openid/branches/openid2/perl/ openid2

OpenIDの入力が簡単になった。Yahoo! など大手が OpenID Provider になった。あとは開発者の皆さんがご自分のプロダクトで OpenID 対応をすすめることが OpenID が広まるポイントだと思います。さあ、OpenID 2.0 対応をすすめていきましょう。

TrackBack

TrackBack URL for this entry:
http://bb.lekumo.jp/t/trackback/517129/31023125

Listed below are links to weblogs that reference OpenID Authentication 2.0 について少し:

Comments

I think this site has got some very great info for everyone. "As we grow oldthe beauty steals inward." by Ralph Waldo Emerson.

Some of these newer super-bright LED light products will light up on voltages ranging from 10 volts DC to 30 volts DC, while others will run on as little as 8 volts. The contacts are arranged in alphabetical order making it hassle-free going over the contact list. The LED light provides more light and less energy use.

It's really very complicated in this busy life to listen news on TV, thus I just use the web for that purpose, and take the most up-to-date information. you can certainly buying twitter followers, Myspace fans/likes in addition to Metacafe landscapes and reviews. Attract more Site visitors by buy twitter followers (http://pagesfriends.com/index.php?do=/blog/229398/prime-some-great-things-about-obtaining-twitter-followers) for your User profile efficient means. facebook advertising, free followers

I am not sure where you're getting your information, but good topic. I needs to spend some time learning more or understanding more. Thanks for great information I was looking for this info for my mission.

Write more, thats all I havve to say. Literally, it seems as though you relied on the video to mzke yur point. You obviously know what youre talking about, why waste your intelligence on just posting vireos to your site when you could be giving us something informative to read?

Hi there!I know this is kinda off topic but I was wondering iff you knew where I could find a captcha plugin for mmy commeent form?I'm using the same blog platform as yours and I'm having difficulty finding one? Thanks a lot!

Post a comment

Access Ranking

Powered by Six Apart
Sponsored links