Skip to main content

Latest version released on PyPi Apache License, Version 2.0.

Digest and basic authentication for the Tornado web framework. Based on code and ideas from Twisted’s cred.

Installation

The latest stable version of tornado-ansi-markup can be installed from pypi:

$ pip install tornado-http-auth

Usage

import tornado.ioloop
from tornado.web import RequestHandler, Application
from tornado_http_auth import DigestAuthMixin, BasicAuthMixin, auth_required

credentials = {'user1': 'pass1'}

# Example 1 (using decorator).
class MainHandler(DigestAuthMixin, RequestHandler):
    @auth_required(realm='Protected', auth_func=credentials.get)
    def get(self):
        self.write('Hello %s' % self._current_user)

# Example 2 (using prepare and get_authentciated_user).
class MainHandler(BasicAuthMixin, RequestHandler):
    def prepare(self):
        self.get_authenticated_user(check_credentials_func=credentials.get, realm='Protected')

    def get(self):
        self.write('Hello %s' % self._current_user)

app = Application([
    (r'/', MainHandler),
])

app.listen(8888)
tornado.ioloop.IOLoop.current().start()

# curl --user user1:pass1 -v http://localhost:8888  -> 200 OK
# curl --user user2:pass2 -v http://localhost:8888  -> 401 Unauthorized
# Remove or comment second class
# curl --digest --user user1:pass1 -v http://localhost:8888  -> 200 OK
# curl --digest --user user2:pass2 -v http://localhost:8888  -> 401 Unauthorized

License

This project is released under the terms of the Apache License, Version 2.0.

Metadata

Release files for tornado-http-auth 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tornado-http-auth 1.1.1
File Size Uploaded
tornado-http-auth-1.1.1.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tornado-http-auth 1.1.1
File Interpreter ABI Platform
tornado_http_auth-1.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 10.9 kB

Release files / tornado-http-auth-1.1.1.tar.gz

Download URL tornado-http-auth-1.1.1.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1d6cc051ebf93807138367b3b2f2822c266edeed8bcc9bd2f22526a0802bcc43
BLAKE2b-256 checksum
How to use checksums
1e051021c5d235b610b8fb3e16b9c4b91a70ee93c7e51916cc78cfb31ab38385
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / tornado_http_auth-1.1.1-py2.py3-none-any.whl

Download URL tornado_http_auth-1.1.1-py2.py3-none-any.whl
Size 6.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2d8a4f49c4a8e99460942dd6168b455dd9f722fdc78d445630310ddf524c664a
BLAKE2b-256 checksum
How to use checksums
9b6a2a3c3669e7a45eda461a4426bd14620e175779e9829a8b3e4a4f258bf0fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page