Skip to content

Commit

Permalink
Rename count_error to inc_error_callback (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpaquet authored Jul 22, 2024
1 parent a7f4c76 commit 7438fe8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion neurow/lib/neurow/internal_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Neurow.InternalApi do
verbose_authentication_errors:
&Neurow.Configuration.internal_api_verbose_authentication_errors/0,
max_lifetime: &Neurow.Configuration.internal_api_jwt_max_lifetime/0,
count_error: &Stats.inc_jwt_errors_internal/0,
inc_error_callback: &Stats.inc_jwt_errors_internal/0,
exclude_path_prefixes: ["/ping", "/nodes", "/cluster_size_above"]
)

Expand Down
6 changes: 3 additions & 3 deletions neurow/lib/neurow/jwt_auth_plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Neurow.JwtAuthPlug do
:jwk_provider,
:audience,
:max_lifetime,
:count_error,
:inc_error_callback,
allowed_algorithm: "HS256",
verbose_authentication_errors: false,
exclude_path_prefixes: []
Expand Down Expand Up @@ -57,11 +57,11 @@ defmodule Neurow.JwtAuthPlug do
conn |> assign(:jwt_payload, payload.fields)
else
{:error, code, message} ->
options.count_error.()
options.inc_error_callback.()
conn |> forbidden(code, message, options)

_ ->
options.count_error.()
options.inc_error_callback.()
conn |> forbidden(:authentication_error, "Authentication error", options)
end

Expand Down
2 changes: 1 addition & 1 deletion neurow/lib/neurow/public_api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Neurow.PublicApi do
verbose_authentication_errors:
&Neurow.Configuration.public_api_verbose_authentication_errors/0,
max_lifetime: &Neurow.Configuration.public_api_jwt_max_lifetime/0,
count_error: &Stats.inc_jwt_errors_public/0
inc_error_callback: &Stats.inc_jwt_errors_public/0
)

plug(:match)
Expand Down
2 changes: 1 addition & 1 deletion neurow/test/neurow/jwt_auth_plug_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule Neurow.JwtAuthPlugTest do
_ -> nil
end
end,
count_error: fn -> :ok end,
inc_error_callback: fn -> :ok end,
exclude_path_prefixes: ["/excluded_path"]
})}
end
Expand Down

0 comments on commit 7438fe8

Please sign in to comment.