This library adds UserApp support for the Python Tornado web framework. By simple decorators you can easily tap into the power of UserApp. Authenticate your users in just one line of code!
UserApp is a cloud-based user management API for web apps with the purpose to relieve developers from having to program logic for user authentication, sign-up, invoicing, feature/property/permission management, OAuth, and more.
Install using pip:
$ pip install userapp.tornado --pre
Load the library:
import userapp.tornado
All handlers should always be decorated with this. Go here to find your App Id.
Require that a request is authorized with UserApp. Once authenticated, use self.user_id
to retrieve the identity of your user.
Assert that an authorized user has a specific permission. Can either be a single string or an array of strings.
import userapp.tornado
@userapp.tornado.config(app_id='YOUR_APP_ID')
class ForumThreadHandler(tornado.web.RequestHandler):
def get(self):
"""Read all threads."""
# Does not have self.user_id since it does not require authorization.
@userapp.tornado.authorized()
def post(self):
"""Add a new thread."""
print(self.user_id) # Do something with the authorized user.
@userapp.tornado.authorized()
@userapp.tornado.has_permission('admin')
def delete(self):
"""Delete an existing thread (admin only)."""
print(self.user_id) # Do something with the authorized user.
For a full demo app, see Tempbox − A temporary file storage demo app powered by UserApp, Python (Tornado) and AngularJS.
- UserApp for Python (userapp)
Contact us via email at [email protected] or visit our support center.
MIT