This repository was archived by the owner on Jan 16, 2024. It is now read-only.
Commit 93197dc 1 parent 20e6f79 commit 93197dc Copy full SHA for 93197dc
File tree 4 files changed +24
-2
lines changed
4 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ sudo cp haproxy-cloudflare-jwt-validator/src/* /usr/local/share/lua/5.3
25
25
26
26
# Version
27
27
28
- 0.1 .0
28
+ 0.2 .0
29
29
30
30
# Usage
31
31
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ backend http-backend
35
35
http-request set-var(txn.audience) str("1234567890abcde1234567890abcde1234567890abcde")
36
36
http-request lua.jwtverify
37
37
http-request deny unless { var(txn.authorized) -m bool }
38
+ http-request set-header custom-groups %[var(txn.http___schemas_groups)]
38
39
server debug_http_listener debug_http_listener:80 check
39
40
40
41
backend cloudflare_jwt
Original file line number Diff line number Diff line change @@ -30,7 +30,14 @@ CLAIM='{
30
30
"exp": 3993204858,
31
31
"type": "app",
32
32
"identity_nonce": "11111111111",
33
- "custom": {}
33
+ "custom": {
34
+ "http://schemas/groups": [
35
+ "application_admin",
36
+ "application_group1",
37
+ "application_group2",
38
+ "application_group3"
39
+ ]
40
+ }
34
41
}'
35
42
36
43
while ! nc -z localhost 8080; do
Original file line number Diff line number Diff line change @@ -278,6 +278,20 @@ function jwtverify(txn)
278
278
goto out
279
279
end
280
280
281
+ -- 7. Add custom values from payload to variable
282
+ if token .payloaddecoded .custom ~= nil then
283
+ for name , payload in pairs (token .payloaddecoded .custom ) do
284
+ local clean_name = name :gsub (" %W" ," _" )
285
+ local clean_value = payload
286
+ if (type (payload ) == ' table' ) then
287
+ clean_value = table.concat (payload , ' ,' )
288
+ end
289
+
290
+ txn .set_var (txn , " txn." .. clean_name , clean_value )
291
+ log_debug (" txn." .. clean_name .. " is defined from payload" )
292
+ end
293
+ end
294
+
281
295
-- 8. Set authorized variable
282
296
log_debug (" req.authorized = true" )
283
297
txn .set_var (txn , " txn.authorized" , true )
You can’t perform that action at this time.
0 commit comments