mushu8
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,
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Hello
I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
al2o3cr
There’s prior discussion of this on the Guardian issue tracker:
https://github.com/ueberauth/guardian/issues/565
The issue appears to be that the generated
available_permissionsfunction declares a return type ofGuardian.Permission.t()but the code that sets@available_permissionsreturns a map with a different shape:https://github.com/ueberauth/guardian/blob/ef1b52e831eaaa5589cd54da32aa8ec4e0c57d80/lib/guardian/permissions.ex#L370-L375
Changing the spec on
available_permissionstoGuardian.Permission.input_permissionswould likely fix the error.The comments on the issue up top that mention “running Dialyzer on
master” are a red herring - this code will only cause Dialyzer errors when it’s used in a module, and Dialyzer doesn’t checkexsfiles like tests…mushu8
Thank you for your answer.
I was trying to remove an annoying warning and i’ve finally decided to implement authorization without help of Guardian.