improvement: validate signing secret is a string (#163)

This commit is contained in:
Zach Daniel 2023-01-29 19:18:15 -05:00 committed by GitHub
parent dc010ec610
commit 53e6497ab9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -126,7 +126,7 @@ defmodule AshAuthentication.Jwt.Config do
with :error <- Keyword.fetch(opts, :signing_secret),
{:ok, {secret_module, secret_opts}} <-
Info.authentication_tokens_signing_secret(resource),
{:ok, secret} <-
{:ok, secret} when is_binary(secret) <-
secret_module.secret_for(
~w[authentication tokens signing_secret]a,
resource,
@ -137,6 +137,9 @@ defmodule AshAuthentication.Jwt.Config do
{:ok, secret} when is_binary(secret) ->
secret
{:ok, secret} when not is_binary(secret) ->
raise "Invalid JWT signing secret: #{inspect(secret)}. Please see the documentation for `AshAuthentication.Jwt` for details"
_ ->
raise "Missing JWT signing secret. Please see the documentation for `AshAuthentication.Jwt` for details"
end