|
Revision 22257, 1.0 KB
(checked in by therve, 3 years ago)
|
|
Merge checker-2570-2
Authors: mesozoic, therve
Reviewers: glyph, exarkun
Fixes #2570
Add the possibility to twistd plugins to use cred checkers, via
twisted.cred.strcred.AuthOptionMixin. This allows twistd plugins to accept
checker via command-line arguments, and also offer a way to create other
pluggable checkers. The only plugin modified for now is the words one.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | """ |
|---|
| 7 | Cred plugin for anonymous logins. |
|---|
| 8 | """ |
|---|
| 9 | |
|---|
| 10 | from zope.interface import implements |
|---|
| 11 | |
|---|
| 12 | from twisted import plugin |
|---|
| 13 | from twisted.cred.checkers import AllowAnonymousAccess |
|---|
| 14 | from twisted.cred.strcred import ICheckerFactory |
|---|
| 15 | from twisted.cred.credentials import IAnonymous |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | anonymousCheckerFactoryHelp = """ |
|---|
| 19 | This allows anonymous authentication for servers that support it. |
|---|
| 20 | """ |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | class AnonymousCheckerFactory(object): |
|---|
| 24 | """ |
|---|
| 25 | Generates checkers that will authenticate an anonymous request. |
|---|
| 26 | """ |
|---|
| 27 | implements(ICheckerFactory, plugin.IPlugin) |
|---|
| 28 | authType = 'anonymous' |
|---|
| 29 | authHelp = anonymousCheckerFactoryHelp |
|---|
| 30 | argStringFormat = 'No argstring required.' |
|---|
| 31 | credentialInterfaces = (IAnonymous,) |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | def generateChecker(self, argstring=''): |
|---|
| 35 | return AllowAnonymousAccess() |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | theAnonymousCheckerFactory = AnonymousCheckerFactory() |
|---|