1. Andriy Kornatskyy
  2. wheezy.security

Commits

Andriy Kornatskyy  committed d0785b8

Added Authorization section to documentation

  • Participants
  • Parent commits 90946b1
  • Branches default

Comments (0)

Files changed (5)

File doc/conf.py

View file
 # built documents.
 #
 # The short X.Y version.
-version = '0.1'
+version = '0.1.1'
 # The full version, including alpha/beta/rc tags.
-release = '0.1'
+release = '0.1.1'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

File doc/modules.rst

View file
 .. automodule:: wheezy.security
    :members:
 
+wheezy.security.authorization
+-----------------------------
+
+.. automodule:: wheezy.security.authorization
+   :members:
+   
+wheezy.security.errors
+----------------------
+
+.. automodule:: wheezy.security.errors
+   :members:
+   
 wheezy.security.principal
 -------------------------
 

File doc/userguide.rst

View file
 Combining them both you can introduce authentication/authorization cookie
 to your application.
 
+Authorization
+-------------
 
+Authorization specify access rights to resources and provide access control 
+in particular to your application.
+
+You are able to request authorization by decorating your method with 
+:py:meth:`~wheezy.security.authorization.authorized`. Here is typical use
+case::
+
+    from wheezy.security import authorized
+    
+    class MyBusinessLogic(object):
+    
+         principal = None
+         
+         @authorized
+         def cancel_transfer(self, id):
+             return True
+
+         @authorized(roles=('operator',))
+         def approve_transfer(self):
+             return True
+             
+Note that :py:meth:`~wheezy.security.authorization.authorized` decorator
+requires the object to supply ``principal`` attribute of type 
+:py:class:`~wheezy.security.principal.Principal`.
+
+If caller is not authorized to perform requested operation
+:py:class:`~wheezy.security.errors.SecurityError` exception is raised.
+See :py:meth:`~wheezy.security.authorization.authorized` for more details.

File src/wheezy/security/__init__.py

View file
 """ ``security`` package.
 """
 
-from wheezy.security.principal import ANONYMOUS
+from wheezy.security.authorization import authorized
+from wheezy.security.errors import SecurityError
 from wheezy.security.principal import Principal

File src/wheezy/security/principal.py

View file
         """
         id, roles, alias, extra = s.split('\x1f', 3)
         return cls(id, tuple(roles.split(';')), alias, extra)
-
-
-ANONYMOUS = Principal()