diff options
author | shmel1k <shmel1k@ydb.tech> | 2023-11-26 18:16:14 +0300 |
---|---|---|
committer | shmel1k <shmel1k@ydb.tech> | 2023-11-26 18:43:30 +0300 |
commit | b8cf9e88f4c5c64d9406af533d8948deb050d695 (patch) | |
tree | 218eb61fb3c3b96ec08b4d8cdfef383104a87d63 /contrib/python/Twisted/py2/twisted/plugins/cred_file.py | |
parent | 523f645a83a0ec97a0332dbc3863bb354c92a328 (diff) | |
download | ydb-b8cf9e88f4c5c64d9406af533d8948deb050d695.tar.gz |
add kikimr_configure
Diffstat (limited to 'contrib/python/Twisted/py2/twisted/plugins/cred_file.py')
-rw-r--r-- | contrib/python/Twisted/py2/twisted/plugins/cred_file.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/contrib/python/Twisted/py2/twisted/plugins/cred_file.py b/contrib/python/Twisted/py2/twisted/plugins/cred_file.py new file mode 100644 index 0000000000..66a5e334e2 --- /dev/null +++ b/contrib/python/Twisted/py2/twisted/plugins/cred_file.py @@ -0,0 +1,61 @@ +# -*- test-case-name: twisted.test.test_strcred -*- +# +# Copyright (c) Twisted Matrix Laboratories. +# See LICENSE for details. + +""" +Cred plugin for a file of the format 'username:password'. +""" + +from __future__ import absolute_import, division + +import sys + +from zope.interface import implementer + +from twisted import plugin +from twisted.cred.checkers import FilePasswordDB +from twisted.cred.strcred import ICheckerFactory +from twisted.cred.credentials import IUsernamePassword, IUsernameHashedPassword + + + +fileCheckerFactoryHelp = """ +This checker expects to receive the location of a file that +conforms to the FilePasswordDB format. Each line in the file +should be of the format 'username:password', in plain text. +""" + +invalidFileWarning = 'Warning: not a valid file' + + +@implementer(ICheckerFactory, plugin.IPlugin) +class FileCheckerFactory(object): + """ + A factory for instances of L{FilePasswordDB}. + """ + authType = 'file' + authHelp = fileCheckerFactoryHelp + argStringFormat = 'Location of a FilePasswordDB-formatted file.' + # Explicitly defined here because FilePasswordDB doesn't do it for us + credentialInterfaces = (IUsernamePassword, IUsernameHashedPassword) + + errorOutput = sys.stderr + + def generateChecker(self, argstring): + """ + This checker factory expects to get the location of a file. + The file should conform to the format required by + L{FilePasswordDB} (using defaults for all + initialization parameters). + """ + from twisted.python.filepath import FilePath + if not argstring.strip(): + raise ValueError('%r requires a filename' % self.authType) + elif not FilePath(argstring).isfile(): + self.errorOutput.write('%s: %s\n' % (invalidFileWarning, argstring)) + return FilePasswordDB(argstring) + + + +theFileCheckerFactory = FileCheckerFactory() |