cred_anonymous.py 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # -*- test-case-name: twisted.test.test_strcred -*-
  2. #
  3. # Copyright (c) Twisted Matrix Laboratories.
  4. # See LICENSE for details.
  5. """
  6. Cred plugin for anonymous logins.
  7. """
  8. from __future__ import absolute_import, division
  9. from zope.interface import implementer
  10. from twisted import plugin
  11. from twisted.cred.checkers import AllowAnonymousAccess
  12. from twisted.cred.strcred import ICheckerFactory
  13. from twisted.cred.credentials import IAnonymous
  14. anonymousCheckerFactoryHelp = """
  15. This allows anonymous authentication for servers that support it.
  16. """
  17. @implementer(ICheckerFactory, plugin.IPlugin)
  18. class AnonymousCheckerFactory(object):
  19. """
  20. Generates checkers that will authenticate an anonymous request.
  21. """
  22. authType = 'anonymous'
  23. authHelp = anonymousCheckerFactoryHelp
  24. argStringFormat = 'No argstring required.'
  25. credentialInterfaces = (IAnonymous,)
  26. def generateChecker(self, argstring=''):
  27. return AllowAnonymousAccess()
  28. theAnonymousCheckerFactory = AnonymousCheckerFactory()