cred_anonymous.py 958 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 zope.interface import implementer
  9. from twisted import plugin
  10. from twisted.cred.checkers import AllowAnonymousAccess
  11. from twisted.cred.credentials import IAnonymous
  12. from twisted.cred.strcred import ICheckerFactory
  13. anonymousCheckerFactoryHelp = """
  14. This allows anonymous authentication for servers that support it.
  15. """
  16. @implementer(ICheckerFactory, plugin.IPlugin)
  17. class AnonymousCheckerFactory:
  18. """
  19. Generates checkers that will authenticate an anonymous request.
  20. """
  21. authType = "anonymous"
  22. authHelp = anonymousCheckerFactoryHelp
  23. argStringFormat = "No argstring required."
  24. credentialInterfaces = (IAnonymous,)
  25. def generateChecker(self, argstring=""):
  26. return AllowAnonymousAccess()
  27. theAnonymousCheckerFactory = AnonymousCheckerFactory()