1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
import validations
from Table import *
from ModuleAuth import *
DATA_VALIDATION = [
('vserver!.*?!(directory|extensions|request)!.*?!passwdfile',
(validations.is_local_file_exists, 'cfg'))
]
NOTE_PASSWD = "Full path to the Htdigest formated password file."
class ModuleHtdigest (ModuleAuthBase):
PROPERTIES = ModuleAuthBase.PROPERTIES + [
'passwdfile'
]
METHODS = ['basic', 'digest']
def __init__ (self, cfg, prefix, submit):
ModuleAuthBase.__init__ (self, cfg, prefix, 'htdigest', submit)
def _op_render (self):
txt = ModuleAuthBase._op_render (self)
table = TableProps()
self.AddPropEntry (table, "Password File", "%s!passwdfile"%(self._prefix), NOTE_PASSWD)
txt += "<h2>Htpasswd file</h2>"
txt += self.Indent(table)
return txt
def _op_apply_changes (self, uri, post):
pre = '%s!passwdfile' % (self._prefix)
self.Validate_NotEmpty (post, pre, 'Password file can not be empty')
self.ApplyChanges ([], post, DATA_VALIDATION)
ModuleAuthBase._op_apply_changes (self, uri, post)
|