forked from vouch/vouch-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing
Set
and tableHasKey
functions
- Loading branch information
Felix Geyer
committed
Oct 8, 2021
1 parent
78349de
commit 894baad
Showing
2 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]", | ||
|
@@ -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 |