How to restrict access to a controller?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If you require that only authenticated users can access you controller, just
-add the ``AuthRequired`` decorator to your controller class.
+All controllers require authentication by default.
+If you require that the controller can be accessed without authentication,
+then you can add the parameter ``secure=False`` to the controller decorator.
-Example::
+Example:
+
+.. code-block:: python
import cherrypy
- from ..tools import ApiController, AuthRequired, RESTController
+ from . import ApiController, RESTController
- @ApiController('ping2')
- @AuthRequired()
- class Ping2(RESTController):
+ @ApiController('ping', secure=False)
+ class Ping(RESTController):
def list(self):
return {"msg": "Hello"}
-Now only authenticated users will be able to "ping" your controller.
-
How to access the manager module instance from a controller?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~