forked from DockYard/openid_connect
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not crash when userinfo endpoint is not implemented by the issuer
- Loading branch information
1 parent
d743020
commit c3ab295
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -627,6 +627,29 @@ defmodule OpenIDConnectTest do | |
assert {"authorization", "Bearer #{token}"} in headers | ||
end | ||
|
||
test "returns error when userinfo endpoint is not defined by discovery document" do | ||
{jwks, []} = Code.eval_file("test/fixtures/jwks/jwk.exs") | ||
jwk = JOSE.JWK.from(jwks) | ||
{_, jwk_pubkey} = JOSE.JWK.to_public_map(jwk) | ||
|
||
{_bypass, uri} = | ||
start_fixture("vault", %{ | ||
"jwks" => jwk_pubkey, | ||
"userinfo_endpoint" => nil | ||
}) | ||
|
||
config = %{@config | discovery_document_uri: uri} | ||
|
||
claims = %{"email" => "[email protected]"} | ||
|
||
{_alg, token} = | ||
jwk | ||
|> JOSE.JWS.sign(Jason.encode!(claims), %{"alg" => "RS256"}) | ||
|> JOSE.JWS.compact() | ||
|
||
assert fetch_userinfo(config, token) == {:error, :userinfo_endpoint_is_not_implemented} | ||
end | ||
|
||
test "returns error when userinfo endpoint is not available" do | ||
bypass = Bypass.open() | ||
userinfo_endpoint = "http://localhost:#{bypass.port}/userinfo" | ||
|