ReckonJwt.Middleware (reckon_jwt v0.2.1)
View SourceJWT authentication middleware for Phoenix/Plug applications.
Provides authentication middleware that validates JWT tokens and sets authentication context in the connection.
Usage
# In your Phoenix router
pipeline :authenticated do
plug ReckonJwt.Middleware, required_scopes: ["read", "write"]
end
# Optional authentication
plug ReckonJwt.Middleware, optional: true
Summary
Functions
Callback implementation for Plug.call/2
.
Get the current account ID from the connection.
Check if the current user has the required scope.
Callback implementation for Plug.init/1
.
Get JWT claims from the connection.
Require specific scopes for a controller action.
Functions
Callback implementation for Plug.call/2
.
Get the current account ID from the connection.
Check if the current user has the required scope.
Callback implementation for Plug.init/1
.
Get JWT claims from the connection.
Require specific scopes for a controller action.
Returns {:ok, conn}
if the user has required scopes,
or {:error, conn}
with a 403 response if not.