Skip to content
Browse files

Set claimed identifier when doing HTML discovery

  • Loading branch information...
1 parent 25598b2 commit 40898791d9f1cfc76f10d805eb9f048bb4e4923d @andrewtj andrewtj committed
Showing with 14 additions and 14 deletions.
  1. +8 −8 src/openid.erl
  2. +1 −1 src/yadis.erl
  3. +4 −4 test/openid_test.erl
  4. +1 −1 test/yadis_test.erl
View
16 src/openid.erl
@@ -19,7 +19,7 @@
discover(Identifier) ->
Req = case yadis:retrieve(Identifier) of
- {none, Body} -> html_discovery(Body);
+ {none, NormalizedId, Body} -> html_discovery(NormalizedId, Body);
#openid_xrds{}=XRDS -> extract_authreq(XRDS);
{error, _Error} ->
%?DBG({error, Error}),
@@ -81,22 +81,22 @@ build_authReq(XRDS, Service, Version) ->
localID=Service#openid_xrdservice.localID}.
-html_discovery(Body) ->
- html_discovery(Body, [{"openid2.provider", "openid2.local_id", {2,0}},
- {"openid.server", "openid.delegate", {1,1}}]).
+html_discovery(Id, Body) ->
+ html_discovery(Id, Body, [{"openid2.provider", "openid2.local_id", {2,0}},
+ {"openid.server", "openid.delegate", {1,1}}]).
-html_discovery(_, []) ->
+html_discovery(_Id, _, []) ->
none;
-html_discovery(Body, [{ProviderRel, LocalIDRel, Version}|Rest]) ->
+html_discovery(Id, Body, [{ProviderRel, LocalIDRel, Version}|Rest]) ->
case openid_utils:get_tags(Body, "link", "rel", ProviderRel) of
[Tag|_] ->
case ?GVD("href", Tag, none) of
none -> html_discovery(Body, Rest);
URL ->
LocalID = html_local_id(Body, LocalIDRel),
- #openid_authreq{opURLs=[URL], version=Version, localID=LocalID}
+ #openid_authreq{opURLs=[URL], version=Version, localID=LocalID, claimedID=Id}
end;
- _ -> html_discovery(Body, Rest)
+ _ -> html_discovery(Id, Body, Rest)
end.
html_local_id(Body, RelName) ->
View
2 src/yadis.erl
@@ -40,7 +40,7 @@ retrieve(Identifier) ->
XRDS = handle_response(DescriptorURL, Headers, Body),
case XRDS of
none ->
- {none, Body};
+ {none, Normalized, Body};
#openid_xrds{} ->
% XXX Todo -- Normalize DescriptorURL as claimedID
View
8 test/openid_test.erl
@@ -16,8 +16,8 @@ discover2_test_() ->
{"http://flickr.com/exbrend",
#openid_authreq{opURLs = ["https://open.login.yahooapis.com/openid/op/auth"],
version = {2,0},
- claimedID = "http://specs.openid.net/auth/2.0/identifier_select",
- localID = "http://specs.openid.net/auth/2.0/identifier_select",
+ claimedID = "http://flickr.com/exbrend",
+ localID = "http://flickr.com/exbrend",
assoc = none}}
],
{setup, fun setup/0, [?_assertEqual(Result, openid:discover(URL))
@@ -27,8 +27,8 @@ discover1_test_() ->
Cases = [{"blog.paulbonser.com",
#openid_authreq{opURLs = ["http://www.livejournal.com/openid/server.bml"],
version = {1,1},
- claimedID = "http://specs.openid.net/auth/2.0/identifier_select",
- localID = "http://specs.openid.net/auth/2.0/identifier_select",
+ claimedID = "http://blog.paulbonser.com/",
+ localID = "http://misterpib.livejournal.com/",
assoc = none}}
],
{setup, fun setup/0, [?_assertEqual(Result, openid:discover(URL))
View
2 test/yadis_test.erl
@@ -28,5 +28,5 @@ retrieve_test_() ->
#openid_xrds{origID = "=brendonh",claimedID = "=brendonh",
canonicalID = none,isXRI = true,services = []}}
],
- {setup, fun setup/0, [?_assertEqual(Result, yadis:retrieve(URL))
+ {setup, fun setup/0, [?_test(?_assertEqual(Result, yadis:retrieve(URL)))
|| {URL, Result} <- Cases ]}.

0 comments on commit 4089879

Please sign in to comment.
Something went wrong with that request. Please try again.