rbac v0.4.0 RBAC
Documentation for Rbac
.
Link to this section Summary
Functions
get_approles/2
fetches the roles for the app
`get_role_from_cache/1 retrieves a role from ets cache
`has_role/2 confirms if the person has the given role e.g: has_role(conn, "home_admin") > true has_role(conn, "potus") > false
`init_roles/2 fetches the list of roles for an app from the auth app (auth_url) based on the client_id and caches the list for fast access. ETS is an in-memory cache you get for Free in Elixir/Erlang. See: https://elixir-lang.org/getting-started/mix-otp/ets.html and: https://elixirschool.com/en/lessons/specifics/ets
parse_body_response/1
parses the response
so your app can use the resulting JSON (list of roles).
Transform a list of maps (roles) to comma-separated string of ids.
Link to this section Functions
get_approles(auth_url, client_id)
get_approles/2
fetches the roles for the app
get_role_from_cache(term)
`get_role_from_cache/1 retrieves a role from ets cache
has_role(conn, role_name)
`has_role/2 confirms if the person has the given role e.g: has_role(conn, "home_admin") > true has_role(conn, "potus") > false
init_roles_cache(auth_url, client_id)
`init_roles/2 fetches the list of roles for an app from the auth app (auth_url) based on the client_id and caches the list for fast access. ETS is an in-memory cache you get for Free in Elixir/Erlang. See: https://elixir-lang.org/getting-started/mix-otp/ets.html and: https://elixirschool.com/en/lessons/specifics/ets
parse_body_response(arg)
Specs
parse_body_response/1
parses the response
so your app can use the resulting JSON (list of roles).
transform_role_list_to_string(roles)
Transform a list of maps (roles) to comma-separated string of ids.
Examples
iex> RBAC.transform_role_list_to_string([%{id: 1}, %{id: 2}, %{id: 3}])
"1,2,3"
iex> RBAC.transform_role_list_to_string("1,2,3")
"1,2,3"
iex> RBAC.transform_role_list_to_string(%{name: "sub", id: 1, revoked: nil})
"1"
iex> RBAC.transform_role_list_to_string([%{id: 1, revoked: 1}, %{id: 3}])
"3"