Skip to content

Commit 5a41fe9

Browse files
committed
Allow limiting OpenID Connect auth to a list of users.
1 parent 69b56ae commit 5a41fe9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

backend/templates/_openid_connect.conf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@
1818
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
1919
end
2020

21+
{% if openidc_restrict_users_enabled -%}
22+
local function contains(table, val)
23+
for i=1,#table do
24+
if table[i] == val then
25+
return true
26+
end
27+
end
28+
return false
29+
end
30+
31+
local allowed_users = {
32+
{% for user in openidc_allowed_users %}
33+
"{{ user }}",
34+
{% endfor %}
35+
}
36+
37+
if not contains(allowed_users, res.id_token.email) then
38+
ngx.exit(ngx.HTTP_FORBIDDEN)
39+
end
40+
{% endif -%}
41+
2142

2243
ngx.req.set_header("X-OIDC-SUB", res.id_token.sub)
2344
ngx.req.set_header("X-OIDC-EMAIL", res.id_token.email)

0 commit comments

Comments
 (0)