diff --git a/lib/plug_jwt.ex b/lib/plug_jwt.ex index 03663a1..86d6f59 100644 --- a/lib/plug_jwt.ex +++ b/lib/plug_jwt.ex @@ -20,6 +20,7 @@ defmodule PlugJwt do secret = Keyword.fetch!(opts, :secret) json_module = Keyword.fetch!(opts, :json_module) claims = Keyword.get(opts, :claims, %{}) + algorithm = Application.get_env(:joken, :algorithm, :HS256) {secret, json_module, claims} end @@ -28,8 +29,8 @@ defmodule PlugJwt do parse_auth(conn, get_req_header(conn, "authorization"), config) end - defp parse_auth(conn, ["Bearer " <> token], {secret, json_module, claims}) do - case Joken.Token.decode(secret, json_module, token, claims) do + defp parse_auth(conn, ["Bearer " <> token], {secret, json_module, algorithm, claims}) do + case Joken.Token.decode(secret, json_module, token, algorithm, claims) do {:error, error} -> create_401_response(conn, error, json_module) {:ok, payload} ->