Hi,
I followed some tutorials and read Hex documentation on Guardian authorization but i get a warning on a basic implementation :
The @spec for the function does not match the success typing of the function.
Function:
CTAPI.Guardian.available_permissions/0
Success typing:
@spec available_permissions() :: %{:default => [:read_users | :write_users, ...]}
Here is my implementation :
defmodule CTAPI.Guardian do
@moduledoc """
Integration with Guardian
"""
use Guardian, otp_app: :ct_api
use Guardian.Permissions, encoding: Guardian.Permissions.BitwiseEncoding # <- warning on this line
def subject_for_token(%{id: id}, _claims) do
{:ok, to_string(id)}
end
def subject_for_token(_, _) do
{:error, :no_resource_id}
end
def resource_from_claims(%{"sub" => sub}) do
{:ok, CTAPI.Account.get_user!(sub)}
end
def resource_from_claims(_claims) do
{:error, :no_claims_sub}
end
def build_claims(claims, _resource, opts) do
claims =
claims
|> encode_permissions_into_claims!(Keyword.get(opts, :permissions))
{:ok, claims}
end
end
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:6:6] [ds:6:6:10] [async-threads:1] [hipe] [dtrace]
Elixir 1.10.3 (compiled with Erlang/OTP 22)
Can someone at least tell me if i have to fork and fix Gardian for this version of elixir or if i can fix my code please ?
Best regards,