Skip to content

Commit

Permalink
Add missing Set and tableHasKey functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Geyer committed Oct 8, 2021
1 parent 78349de commit 894baad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion examples/OpenResty/lua/group_auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
-- Group Authentication
-- via X-Vouch-IdP-Groups
-- ==============================
-- Function to turn a table with only values into a k=>v table
function Set (list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end
-- Function to find a key in a table
function tableHasKey(table,key)
return table[key] ~= nil
end
-- Validate that a user is in a group
local authorized_groups = Set {
"CN=Domain Users,CN=Users,DC=Contoso,DC=com",
Expand Down Expand Up @@ -29,4 +39,4 @@ if ngx.var.auth_resp_x_vouch_idp_claims_groups then
else
-- Throw forbidden if variable doesn't exist
ngx.exit(ngx.HTTP_FORBIDDEN)
end
end
12 changes: 11 additions & 1 deletion examples/OpenResty/lua/user_auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
-- User Authentication
-- via X-Vouch-User
-- ==============================
-- Function to turn a table with only values into a k=>v table
function Set (list)
local set = {}
for _, l in ipairs(list) do set[l] = true end
return set
end
-- Function to find a key in a table
function tableHasKey(table,key)
return table[key] ~= nil
end
-- Validate a user in nginx, instead of vouch
local authorized_users = Set {
"[email protected]",
Expand All @@ -17,4 +27,4 @@ if ngx.var.auth_resp_x_vouch_user then
else
-- Throw forbidden if variable doesn't exist
ngx.exit(ngx.HTTP_FORBIDDEN)
end
end

0 comments on commit 894baad

Please sign in to comment.