Created
June 9, 2016 02:08
-
-
Save kamiyn/c15b4204d7299e7ca9464cd3aea2af3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://id.smt.docomo.ne.jp/src/dlogin/pc/developer.html にある docomo ログイン I/F仕様書 の内容に沿って | |
ASP.NET MVC5 で ClaimedIdentifier が取れるまでを実装した。 | |
NuGetで入れたパッケージは | |
<package id="DotNetOpenAuth.Mvc5" version="4.3.4.13329" targetFramework="net452" /> | |
<package id="DotNetOpenAuth.OpenId.RelyingParty" version="4.3.4.13329" targetFramework="net452" /> | |
の2つ。 | |
HomeController.cs に以下のコードを実装した。 | |
public ActionResult Index() | |
{ | |
Response.AddHeader("X-XRDS-Location", Url.Action("Xrds", "Home", null, "https")); // Yadisプロトコルの RP Discovery 対応 | |
return View(); | |
} | |
public ActionResult Xrds() | |
{ | |
const string xrds = | |
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xrds:XRDS\n xmlns:xrds=\"xri://$xrds\"\n xmlns:openid=\"http://openid.net/xmlns/1.0\"\n xmlns=\"xri://$xrd*($v*2.0)\">\n<XRD>\n<Service priority=\"0\">\n<Type>http://specs.openid.net/auth/2.0/return_to</Type>\n<URI>{0}</URI>\n</Service>\n</XRD>\n</xrds:XRDS>\n"; | |
var ret = String.Format(xrds, Url.Action("DocomoLogin", "Home", null, "https")); | |
return Content(ret, "application/xrds+xml"); | |
} | |
public ActionResult DocomoLogin() | |
{ | |
var docomo_op_identifier = "https://i.mydocomo.com"; | |
var openid = new OpenIdRelyingParty(); | |
var response = openid.GetResponse(); | |
if (response == null) | |
{ | |
var request = openid.CreateRequest(docomo_op_identifier, | |
Url.Action("Index", "Home", null, "https"), // このページが X-XRDS-Location ヘッダーを返すようにする | |
Request.Url | |
); | |
return request.RedirectingResponse.AsActionResultMvc5(); | |
} | |
else | |
{ | |
// この時点で response.ClaimedIdentifier が取れるのでなんとかする | |
throw new NotImplementedException(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment