plugin configuration file added
setting "NameDatabase" replaced by "SettingsDir" storing of local settings implemented (CryptoBoxSettings.write())
This commit is contained in:
parent
11c2873934
commit
491d16899f
15 changed files with 267 additions and 24 deletions
|
@ -5,9 +5,6 @@ import Plugins
|
|||
from CryptoBoxExceptions import *
|
||||
import cherrypy
|
||||
|
||||
# TODO: for now the admin access is defined statically
|
||||
authDict = {"test": "tester"}
|
||||
|
||||
|
||||
class WebInterfacePlugins:
|
||||
|
||||
|
@ -63,7 +60,7 @@ class WebInterfaceSites:
|
|||
|
||||
## this is a function decorator to check authentication
|
||||
## it has to be defined before any page definition requiring authentification
|
||||
def __requestAuth(self, authDict):
|
||||
def __requestAuth(self=None):
|
||||
def check_credentials(site):
|
||||
def _inner_wrapper(self, *args, **kargs):
|
||||
import base64
|
||||
|
@ -81,8 +78,9 @@ class WebInterfaceSites:
|
|||
except AttributeError:
|
||||
## no cherrypy response header defined
|
||||
pass
|
||||
authDict = self.cbox.prefs.userDB["admins"]
|
||||
if user in authDict.keys():
|
||||
if password == authDict[user]:
|
||||
if self.cbox.prefs.userDB.getDigest(password) == authDict[user]:
|
||||
## ok: return the choosen page
|
||||
self.cbox.log.info("access granted for: %s" % user)
|
||||
return site(self, *args, **kargs)
|
||||
|
@ -203,20 +201,21 @@ class WebInterfaceSites:
|
|||
self.dataset.setCurrentDiskState(plugin.device)
|
||||
if not nextTemplate: nextTemplate = "show_volume"
|
||||
else:
|
||||
self.dataset.setPluginData()
|
||||
if not nextTemplate: nextTemplate = "form_system"
|
||||
## save the currently active plugin name
|
||||
self.dataset["Data.ActivePlugin"] = plugin.getName()
|
||||
return self.__render(nextTemplate, plugin)
|
||||
## apply authentication?
|
||||
if plugin.requestAuth:
|
||||
return lambda **args: self.__requestAuth(authDict)(handler)(self, **args)
|
||||
if plugin.isAuthRequired():
|
||||
return lambda **args: self.__requestAuth()(handler)(self, **args)
|
||||
else:
|
||||
return lambda **args: handler(self, **args)
|
||||
|
||||
|
||||
## test authentication
|
||||
@cherrypy.expose
|
||||
@__requestAuth(None, authDict)
|
||||
@__requestAuth
|
||||
def test(self, weblang=""):
|
||||
self.__resetDataset()
|
||||
self.__setWebLang(weblang)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue