日向夏特殊応援部隊

俺様向けメモ

delegateとIdentifierの冗長性・ロードバランシング

今は delegate とは言わず OP-Local Identifier の方が妥当なのかな。

多くの人が既にご存知かと思いますが、実際の OP にある Identifier (つまり OP-Local Identifier) を Claimed Identifier とせずに、
自分が既に持っているドメインなどを Claimed Identifier として OP-Local Identifier に対して delegate を行う事が出来ます。

具体的に言えば、

Claimed Identifier
art-code.org
OP-Local Identifier
zigorou.myopenid.com

みたいにする。

Claimed Identifier は URL の場合は Yadis Protocol or HTML Based Discovery に則って OP EndPoint URL などの discovery が上手く行くように情報を定義しないとダメです。
で、Yadis Protocol を使った場合に、Service 要素の priority 属性を用いて、OP-Local Identifier を複数指定しつつ、肝心の Claimed Identifier に対して冗長性を持たせる事が出来るーなんて話がこないだの OpenID 勉強会であったのですが、本当にそういう事が出来るような仕様なのか気になってました。

Yadis Protocol

The OPTIONAL priority attribute MAY be used with the Service element, allowing the User to specify preferences for the service to be used.

Example:
The example document at 7.4 above indicates that the User prefers the OpenID protocol using the server www.myopenid.com/server, and that the last choice is LID version 1.0.

The OPTIONAL priority attribute MAY be used with the URI element, allowing the User to specify preferences for the URI to be used.

Note:
The LID SSO service elements in the document at 7.4 above do not contain a URI element because in LID SSO the LID URL itself is used to obtain LID services.

In keeping with the goal of ease of implementation, a Relying Party Agent MAY ignore priority attributes. A Relying Party Agent that recognizes and uses the priority attribute in one or more Service or URI elements MUST follow the specification of priority attributes in Clause 3.3.3 of the XRI Resolution 2.0 specification.

Note:
The XRI Resolution 2.0 specification provides that the User prefers first the element with the smallest number in the value of the priority attribute, then those with higher numbers in the order of that number, and prefers last those elements with no priority attribute.

とあって、基本的には優先度の話しかしてなくて、後は XRI Resolution 2.0 に丸投げしてますね。

XRI Resolution 2.0

3. If two or more instances of the same element type have identical priority attribute values (including the null value), the consuming application SHOULD select one of the instances at random. This consuming application SHOULD NOT simply choose the first instance that appears in XML document order.

priority属性が同じ値を持つ要素が複数ある場合は、ランダムに選択してくれと言ってますね。あと出現順で判断しちゃダメとも申してます。

IMPORTANT: It is vital that implementers observe the preceding rule in order to support intentional redundancy or load balancing semantics. At the same time, it is vital that XRDS authors understand that this rule can result in non-deterministic behavior if two or more of the same type of synonym elements or service endpoint elements are included with the same priority in an XRD but are NOT intended for redundancy or load balancing.

まぁ後はざっくり言って冗長性とかロードバランシングを行う上でランダムに選ぶってのがあるんだぜって解釈で良さそうですね。

まとめ

XRDS 文書のpriority属性を同じ値にしておくと delegate する OP-Local Identifier を複数指定出来て、RP 側のライブラリが親切ならばロードバランシングしてくれるよーって話でした。