RestAuth v0.9.5 RestAuth.CacheService View Source
Generic caching service to be used by the user implemented handler module. Has API style meant to be used by the handler and most access should be routed through there.
The module uses GenServer.multi_call/4
to flush caches and invalidations out to all
the nodes. Using this cache without nodes being connected will leave you unable to
invalidate acl or kill off user sessions.
The cache is backed by ets tables and supports read concurrency.
Link to this section Summary
Functions
Looks up if a user can access an item in the system.
Returns :not_found
if there is nothing in the cache and a boolean result if there is
Looks up a user in the cache based on the authority.
user_id
and token
fields needs to be set for this
function to look up anything sensible
Invalidates an authority based on the set user_id
and token
.
Returns
{:ok, Integer.t}
If all nodes invalidated the authority just fine with the int being how many nodes it invalidated on.{:error, [Node.t]}
with a list of the bad nodes. Mainly to be used for logging purposes
Invalidates all authorities for a given user_id
Invalidates all acls for a given user_id
in a RestAuth.Authority
Synchronously puts a user in the cache
Sets user access for a user_id / category / item id in the caching layer
Link to this section Functions
can_user_access?(authority :: RestAuth.Authority.t, category :: String.t, target_id :: any) :: :not_found | true | false
Looks up if a user can access an item in the system.
Returns :not_found
if there is nothing in the cache and a boolean result if there is.
Looks up a user in the cache based on the authority.
user_id
and token
fields needs to be set for this
function to look up anything sensible.
invalidate_token(authority :: RestAuth.Authority.t) :: :ok | {:error, [Node.t]}
Invalidates an authority based on the set user_id
and token
.
Returns
{:ok, Integer.t}
If all nodes invalidated the authority just fine with the int being how many nodes it invalidated on.{:error, [Node.t]}
with a list of the bad nodes. Mainly to be used for logging purposes.
invalidate_user(authority :: RestAuth.Authority.t) :: :ok | {:error, [Node.t]}
Invalidates all authorities for a given user_id
.
Returns
{:ok, Integer.t}
If all nodes invalidated the authority just fine with the int being how many nodes it invalidated on.{:error, [Node.t]}
with a list of the bad nodes. Mainly to be used for logging purposes.
invalidate_user_acl(authority :: RestAuth.Authority.t) :: :ok | {:error, [Node.t]}
Invalidates all acls for a given user_id
in a RestAuth.Authority
.
Returns
{:ok, Integer.t}
If all nodes invalidated the item acl just fine with the int being how many nodes it invalidated on.{:error, [Node.t]}
with a list of the bad nodes. Mainly to be used for logging purposes.
put_user(authority :: RestAuth.Authority.t) :: :not_found | {:ok, RestAuth.Authority.t}
put_user(authority :: RestAuth.Authority.t) :: :ok | {:error, [Node.t]}
Synchronously puts a user in the cache.
The call is syncronous to try to prevent multiple lookups / cache puts across the nodes. Returns
{:ok, Integer.t}
If all nodes stored the authority just fine with the int being how many nodes it stored on.{:error, [Node.t]}
with a list of the bad nodes. Mainly to be used for logging purposes.
set_user_access(authority :: RestAuth.Authority.t, category :: String.t, target_id :: any, allowed :: boolean) :: :ok | {:error, [Node.t]}
Sets user access for a user_id / category / item id in the caching layer.
Returns
{:ok, Integer.t}
If all nodes stored the access control with int being how many nodes it invalidated on.{:error, [Node.t]}
with a list of the bad nodes. Mainly to be used for logging purposes.