~canonical-livepatch-dependencies/canonical-livepatch-service-dependencies/twisted

« back to all changes in this revision

Viewing changes to twisted/plugins/cred_anonymous.py

  • Committer: Free Ekanayaka
  • Date: 2016-07-01 12:22:33 UTC
  • Revision ID: free.ekanayaka@canonical.com-20160701122233-nh55w514zwzoz1ip
Tags: upstream-16.2.0
ImportĀ upstreamĀ versionĀ 16.2.0

Show diffs side-by-side

added added

removed removed

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