Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: small fixes for DPoP #332

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/oidcc/token/access.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,26 @@ defmodule Oidcc.Token.Access do
endpoint :: String.t(),
client_context :: ClientContext.t()
) :: %{String.t() => String.t()}
@spec authorization_headers(
access_token :: t(),
method :: :get | :post,
endpoint :: String.t(),
client_context :: ClientContext.t(),
opts :: %{optional(:dpop_nonce) => binary()}
) :: %{String.t() => String.t()}
def authorization_headers(
access_token,
method,
endpoint,
client_context
client_context,
opts \\ %{}
),
do:
:oidcc_token.authorization_headers(
struct_to_record(access_token),
method,
endpoint,
ClientContext.struct_to_record(client_context)
ClientContext.struct_to_record(client_context),
opts
)
end
2 changes: 1 addition & 1 deletion src/oidcc_http_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ extract_successful_response({{_HttpVersion, StatusCode, _HttpStatusName}, Header
end,
case proplists:lookup("dpop-nonce", Headers) of
{"dpop-nonce", DpopNonce} ->
{error, {use_dpop_nonce, DpopNonce, Body}};
{error, {use_dpop_nonce, iolist_to_binary(DpopNonce), Body}};
_ ->
{error, {http_error, StatusCode, Body}}
end.
Expand Down
5 changes: 4 additions & 1 deletion test/oidcc_token_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,10 @@ auth_method_private_key_jwt_with_dpop_and_nonce_test() ->
_ ->
{ok, {
{"HTTP/1.1", 400, "OK"},
[{"content-type", "application/json"}, {"dpop-nonce", DpopNonce}],
[
{"content-type", "application/json"},
{"dpop-nonce", binary_to_list(DpopNonce)}
],
DpopNonceError
}}
end
Expand Down
7 changes: 5 additions & 2 deletions test/oidcc_userinfo_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,10 @@ dpop_proof_with_nonce_test() ->
_ ->
{ok, {
{"HTTP/1.1", 400, "Bad Request"},
[{"content-type", "application/json"}, {"dpop-nonce", DpopNonce}],
[
{"content-type", "application/json"},
{"dpop-nonce", binary_to_list(DpopNonce)}
],
DpopNonceError
}}
end
Expand Down Expand Up @@ -936,7 +939,7 @@ dpop_proof_with_invalid_nonce_test() ->
fun(get, _UrlHeader, _HttpOpts, _Opts, _Profile) ->
{ok, {
{"HTTP/1.1", 400, "Bad Request"},
[{"content-type", "application/json"}, {"dpop-nonce", DpopNonce}],
[{"content-type", "application/json"}, {"dpop-nonce", binary_to_list(DpopNonce)}],
DpopNonceError
}}
end,
Expand Down