Acceptable values for ACL principals

19 views
Skip to first unread message

Anton Novikov

unread,
Oct 29, 2019, 5:56:01 PM10/29/19
to pylons-discuss
Hi,

I have Pyramid REST server with Cornice. This server implements authorization using ACLs. All principals are defined as strings, for example (example taken from here):

# The Cornice service.
bills_service = Service("bills", "/api/bills", factory=BillsListContext)

# The Context factory:
class BillListContext(object):
   def __init__(self, request):
       pass

    @property
   def __acl__(self):
       return [
           (Allow, "role:buyer", "get_bills"),
           (Allow, "role:seller", "get_bills"),
       ]

# And the view function is then:
@bills_service.get(
   content_type="application/json",
   accept="application/json",
   permission="get_bills",
   )
def get_bills(request):
   # …

According to the documentation, principal is expected to be a string or Unicode object. However, i wonder if this limitation is necessary, because i couldn't find any place requiring principal to be a string (or Unicode object).
What i want is to use enum values for principals. I know, it's possible to create enum which inherits from `str` type, however i'm curious if i'm really limited by `str` type for principals.

Regards,
Anton
Reply all
Reply to author
Forward
0 new messages