okfn / timemapper

Create and share elegant timelines and timemaps fast
http://timemapper.okfnlabs.org/
MIT License
274 stars 60 forks source link

Authorization for API actions #27

Closed rufuspollock closed 12 years ago

rufuspollock commented 12 years ago

Config consists of a dictionary:

AUTHORIZATION = {
  {object-type}: {
    anonymous: ['create', 'read'],
    user: ['create', 'read'],
    owner: ['read', 'update', 'delete']
  }

Code:

role = getRole(user, object);
return AUTHORIZATION[object.object_type].findIndex(action) != -1

Issues