auth.py 737B

12345678910111213141516171819202122
  1. from pyramid.security import ALL_PERMISSIONS
  2. from pyramid.security import Allow
  3. from pyramid.security import Authenticated
  4. def check_credentials(username, password, request):
  5. if username == 'admin' and password == 'admin':
  6. # an empty list is enough to indicate logged-in... watch how this
  7. # affects the principals returned in the home view if you want to
  8. # expand ACLs later
  9. return ['g:admin']
  10. if username == 'user' and password == 'user':
  11. return []
  12. class Root:
  13. # dead simple, give everyone who is logged in any permission
  14. # (see the home_view for an example permission)
  15. __acl__ = (
  16. (Allow, 'g:admin', ALL_PERMISSIONS),
  17. (Allow, Authenticated, 'user'),
  18. )