summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2012-10-26 23:55:17 +0000
committerTed Trask <ttrask01@yahoo.com>2012-10-26 23:55:17 +0000
commit8c2dc86dc5e0d8519bbacf0d5e3a24c755831792 (patch)
tree24e04a2b994fd0c0dc1a84e7f32aada54c316709
parentf85a475d3c44ec6380e5fd69d457799bde3f3019 (diff)
downloadacf-did-8c2dc86dc5e0d8519bbacf0d5e3a24c755831792.tar.bz2
acf-did-8c2dc86dc5e0d8519bbacf0d5e3a24c755831792.tar.xz
Use authenticator.get_subauth function rather than public auth variable
-rw-r--r--did-model.lua27
1 files changed, 17 insertions, 10 deletions
diff --git a/did-model.lua b/did-model.lua
index 08b342d..a043060 100644
--- a/did-model.lua
+++ b/did-model.lua
@@ -801,7 +801,8 @@ local function parseentry(entry)
end
local function getallowedlist(self, userid)
- local entry = authenticator.auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
+ local auth = authenticator.get_subauth(self)
+ local entry = auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
local restricted, allowedlist
restricted, allowedlist = parseentry(entry)
@@ -810,7 +811,7 @@ local function getallowedlist(self, userid)
-- add in the guest role
userinfo.roles[#userinfo.roles + 1] = roles.guest_role
for i,role in ipairs(userinfo.roles) do
- local entry = authenticator.auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
+ local entry = auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
local restricted2, allowed2
restricted2, allowed2 = parseentry(entry)
restricted = restricted or restricted2
@@ -821,12 +822,13 @@ local function getallowedlist(self, userid)
end
local function adduserpermission(self, userid, did)
- local entry = authenticator.auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
+ local auth = authenticator.get_subauth(self)
+ local entry = auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
local restricted, allowedlist
restricted, allowedlist = parseentry(entry)
allowedlist[#allowedlist+1] = did
- authenticator.auth.write_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid, tostring(restricted)..":"..(table.concat(allowedlist, ",") or ""))
+ auth.write_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid, tostring(restricted)..":"..(table.concat(allowedlist, ",") or ""))
end
-- ################################################################################
@@ -1251,10 +1253,11 @@ function getactivitylog()
end
function getpermissionslist(self)
+ local auth = authenticator.get_subauth(self)
local users = authenticator.list_users(self)
local userlist = {}
for i,user in ipairs(users) do
- local entry = authenticator.auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, user) or ""
+ local entry = auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, user) or ""
local restricted, allowedlist
restricted, allowedlist = parseentry(entry)
userlist[#userlist + 1] = {id=user, restricted=restricted, allowed=allowedlist}
@@ -1263,7 +1266,7 @@ function getpermissionslist(self)
local rolelist = {}
local rols = roles.list_all_roles(self)
for i,role in ipairs(rols) do
- local entry = authenticator.auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
+ local entry = auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
local restricted, allowedlist
restricted, allowedlist = parseentry(entry)
rolelist[#rolelist + 1] = {id=role, restricted=restricted, allowed=allowedlist}
@@ -1334,7 +1337,8 @@ local function validaterolepermissions(self, rolepermissions)
end
function getuserpermissions(self, userid)
- local entry = authenticator.auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
+ local auth = authenticator.get_subauth(self)
+ local entry = auth.read_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userid) or ""
local restricted, allowedlist
restricted, allowedlist = parseentry(entry)
local allowed = cfe({ type="list", value=allowedlist, label="DID Permissions", descr="List one DID per line" })
@@ -1349,7 +1353,8 @@ function setuserpermissions(self, userpermissions)
local success, userpermissions = validateuserpermissions(self, userpermissions)
if success then
- authenticator.auth.write_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userpermissions.value.userid.value, tostring(userpermissions.value.restricted.value)..":"..(table.concat(userpermissions.value.allowed.value, ",") or ""))
+ local auth = authenticator.get_subauth(self)
+ auth.write_entry(self, authenticator.usertable, self.conf.prefix..self.conf.controller, userpermissions.value.userid.value, tostring(userpermissions.value.restricted.value)..":"..(table.concat(userpermissions.value.allowed.value, ",") or ""))
else
userpermissions.errtxt = "Failed to set user permissions"
end
@@ -1357,7 +1362,8 @@ function setuserpermissions(self, userpermissions)
end
function getrolepermissions(self, role)
- local entry = authenticator.auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
+ local auth = authenticator.get_subauth(self)
+ local entry = auth.read_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, role) or ""
local restricted, allowedlist
restricted, allowedlist = parseentry(entry)
local allowed = cfe({ type="list", value=allowedlist, label="DID Permissions", descr="List one DID per line" })
@@ -1372,7 +1378,8 @@ function setrolepermissions(self, rolepermissions)
local success, rolepermissions = validaterolepermissions(self, rolepermissions)
if success then
- authenticator.auth.write_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, rolepermissions.value.role.value, tostring(rolepermissions.value.restricted.value)..":"..(table.concat(rolepermissions.value.allowed.value, ",") or ""))
+ local auth = authenticator.get_subauth(self)
+ auth.write_entry(self, authenticator.roletable, self.conf.prefix..self.conf.controller, rolepermissions.value.role.value, tostring(rolepermissions.value.restricted.value)..":"..(table.concat(rolepermissions.value.allowed.value, ",") or ""))
else
rolepermissions.errtxt = "Failed to set role permissions"
end