Kerberos authentication for Twisted
Project description
authkerb
========
Kerberos authentication for Twisted
```python
import os
import sys
from twisted.cred.portal import IRealm, Portal
from twisted.internet import reactor
from twisted.python import log
from twisted.web import server
from twisted.web.guard import HTTPAuthSessionWrapper, BasicCredentialFactory
from twisted.web.resource import IResource, Resource
from zope.interface import implements
import authkerb
class Simple(Resource):
isLeaf = True
def render_GET(self, request):
return '<html>Hello, world!</html>'
class Realm(object):
implements(IRealm)
def requestAvatar(self, avatarId, mind, *interfaces):
if IResource in interfaces:
return (IResource, Simple(), lambda: None)
raise NotImplementedError()
os.environ['KRB5_KTNAME'] = '/path/to/keytab'
log.startLogging(sys.stdout)
negotiateChecker = authkerb.NegotiateCredentialsChecker()
basicChecker = authkerb.BasicCredentialsChecker('HTTP/example.org', 'EXAMPLE.ORG')
portal = Portal(Realm(), [negotiateChecker, basicChecker])
negotiateFactory = authkerb.NegotiateCredentialFactory('HTTP')
basicFactory = BasicCredentialFactory('realm')
resource = HTTPAuthSessionWrapper(portal, [negotiateFactory, basicFactory])
site = server.Site(resource)
reactor.listenTCP(8080, site)
reactor.run()
```
========
Kerberos authentication for Twisted
```python
import os
import sys
from twisted.cred.portal import IRealm, Portal
from twisted.internet import reactor
from twisted.python import log
from twisted.web import server
from twisted.web.guard import HTTPAuthSessionWrapper, BasicCredentialFactory
from twisted.web.resource import IResource, Resource
from zope.interface import implements
import authkerb
class Simple(Resource):
isLeaf = True
def render_GET(self, request):
return '<html>Hello, world!</html>'
class Realm(object):
implements(IRealm)
def requestAvatar(self, avatarId, mind, *interfaces):
if IResource in interfaces:
return (IResource, Simple(), lambda: None)
raise NotImplementedError()
os.environ['KRB5_KTNAME'] = '/path/to/keytab'
log.startLogging(sys.stdout)
negotiateChecker = authkerb.NegotiateCredentialsChecker()
basicChecker = authkerb.BasicCredentialsChecker('HTTP/example.org', 'EXAMPLE.ORG')
portal = Portal(Realm(), [negotiateChecker, basicChecker])
negotiateFactory = authkerb.NegotiateCredentialFactory('HTTP')
basicFactory = BasicCredentialFactory('realm')
resource = HTTPAuthSessionWrapper(portal, [negotiateFactory, basicFactory])
site = server.Site(resource)
reactor.listenTCP(8080, site)
reactor.run()
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
authkerb-0.1.tar.gz
(2.9 kB
view details)
File details
Details for the file authkerb-0.1.tar.gz
.
File metadata
- Download URL: authkerb-0.1.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f68f78dcddf26b456679b6ce1ccf1b774be05e2ff4752efe292b5f43d770fbbd |
|
MD5 | 5098ddc774f11eefd4eefe537600d410 |
|
BLAKE2b-256 | b74c412a8c2eb8a092e1ebf1ee7b141791cfb3c05ff951cfe209eb8df82777ea |