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