/usr/share/doc/python-twisted-web2/examples/auth/credsetup.py is in python-twisted-web2 8.1.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | from zope.interface import Interface, implements
from twisted.cred import portal
from twisted.web2.auth.interfaces import IHTTPUser
class HTTPUser(object):
"""
A user that authenticated over HTTP Auth.
"""
implements(IHTTPUser)
username = None
def __init__(self, username):
"""
@param username: The str username sent as part of the HTTP auth
response.
"""
self.username = username
class HTTPAuthRealm(object):
implements(portal.IRealm)
def requestAvatar(self, avatarId, mind, *interfaces):
if IHTTPUser in interfaces:
return IHTTPUser, HTTPUser(avatarId)
raise NotImplementedError("Only IHTTPUser interface is supported")
|