Zuppler Users Client v0.0.5 ZupplerUsers.Auth.Supervisor

Provides oauth toke authorization with zuppler

Dependencies

poolboy, lrucache

Setup

In the app module add a new child supervisor(Zuppler.Auth, []])

Usage

``` user_info = Zuppler.Auth.auth(token)

Authorization.ZupplerAuth.has_any_role?(user_info, "restaurant") Authorization.ZupplerAuth.has_any_role?(user_info, ["restaurant", "channel"]) Authorization.ZupplerAuth.acls_for(user_info, :restaurant) ```

Summary

Functions

Returns the given object ids on which the user has access to. subject must be a keyword

Authetnicates a user by token. Returns user_info if success or nil if not

Verifies if the user has a given role. Roles can be either a single string "admin" or an a list of string ["restaurant", "channel"]. It returns true if the user has any of the given roles

Callback implementation for c::supervisor.init/1

Functions

acls_for(user_info, subject)

Returns the given object ids on which the user has access to. subject must be a keyword

Example

Auth.acls_for(user_info, :restaurant) # => [2,3,4]

auth(token)

Authetnicates a user by token. Returns user_info if success or nil if not

has_role(user_info, roles)

Verifies if the user has a given role. Roles can be either a single string "admin" or an a list of string ["restaurant", "channel"]. It returns true if the user has any of the given roles

init(state)

Callback implementation for c::supervisor.init/1.

pool_name()
start_link(state \\ [])
with_cache(token, producer)