summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/authenticator-plaintext.lua9
-rw-r--r--lib/format.lua2
-rw-r--r--lib/roles.lua24
3 files changed, 34 insertions, 1 deletions
diff --git a/lib/authenticator-plaintext.lua b/lib/authenticator-plaintext.lua
index 57bbf35..c9d5c42 100644
--- a/lib/authenticator-plaintext.lua
+++ b/lib/authenticator-plaintext.lua
@@ -94,3 +94,12 @@ get_userinfo = function ( self, userid )
end
end
+get_userinfo_roles = function (self, userid)
+ local t = pvt.parse_authfile(self.conf.confdir .. "/passwd")
+ if t == false then
+ return nil
+ else
+ temp = pvt.get_id (userid, t)
+ return temp.roles
+ end
+end
diff --git a/lib/format.lua b/lib/format.lua
index 2865756..60fda82 100644
--- a/lib/format.lua
+++ b/lib/format.lua
@@ -112,7 +112,7 @@ end
-- This code comes from http://lua-users.org/wiki/SplitJoin
-- -- example: format.table_to_string( {"Anna", "Bob", "Charlie", "Dolores"}, ",")
function table_to_string (list, delimiter)
- local len = getn(list)
+ local len = #(list)
if len == 0 then
return ""
end
diff --git a/lib/roles.lua b/lib/roles.lua
index 808aa95..bdaf635 100644
--- a/lib/roles.lua
+++ b/lib/roles.lua
@@ -2,6 +2,7 @@
require ("posix")
+require ("fs")
require ("format")
module (..., package.seeall)
@@ -55,3 +56,26 @@ end
end
end
+get_roles_perm = function(self,roles)
+ --for now we are using the file static
+ --this will go through and search from the roles in sessionid to get the real
+ --permission list
+ local rolesfile = "/etc/acf/roles"
+ f = fs.read_file_as_array(rolesfile)
+ local temp = {}
+ for k,v in pairs(roles) do
+ for a,b in pairs(f) do
+ match = "^" .. v
+ c = string.match(b,match)
+ if c then
+ inval = string.match(b,"[,%w:]+$")
+ temp[#temp +1] = inval
+ end
+ end
+ end
+ temp1 = format.table_to_string(temp,",")
+ --we now can return the first level of roles perms. What if a role is a member of a role...
+
+ return temp1
+end
+