File: README.md

package info (click to toggle)
python-cyclone 1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,388 kB
  • ctags: 1,372
  • sloc: python: 8,823; sh: 183; makefile: 13; sql: 12
file content (31 lines) | stat: -rw-r--r-- 947 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Cyclone auth digest example

This is a port of https://github.com/bkjones/curtain (Apache License)

## Basic usage

### import digest.py at the top of your views file

	import digest

### subclass digest.DigestAuthMixin in authenticated views

	class MainHandler(digest.DigestAuthMixin, cyclone.web.RequestHandler):

### define a password store. This function is expected to return a hash containing 
auth\_username and auth\_password.

    def passwordz(username):
        creds = {
                'auth_username': 'test',
                'auth_password': 'foobar'
                }
        if username == creds['auth_username']:
            return creds

### decorate views (get/post) with digest.digest_auth. Passing in authentication realm and password store. 
If authenticated, `self.current_user` will be properly set.

    @digest.digest_auth('Cyclone', passwordz)
    def get(self):
        self.write("Hello %s" % (self.current_user))