Hi,
I have Pyramid REST server with Cornice
<https://github.com/Cornices/cornice>. This server implements authorization
using ACLs
<https://docs.pylonsproject.org/projects/pyramid/en/latest/narr/security.html#assigning-acls-to-your-resource-objects>.
All principals are defined as strings, for example (example taken from here
<https://groups.google.com/forum/#!searchin/pylons-discuss/principals|sort:date/pylons-discuss/KYQRE-Do1bU/YnVGDPZJBwAJ>
):
# 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
<https://docs.pylonsproject.org/projects/pyramid/en/latest/glossary.html#term-principal>,
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
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pylons-discuss/50b8038d-f5aa-47c7-9130-3eaa5d0c2c02%40googlegroups.com.