File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -12,15 +12,19 @@ http {
1212 location /api {
1313 content_by_lua_block {
1414 local libjwt = require( "resty.libjwt" )
15- local valid, err = libjwt.validate( {
16- ["header_token" ] = "Authorization" ,
17- ["jwks_files" ] = { "/usr/share/tokens/jwks.json" } ,
15+ local cjson = require( "cjson.safe" )
16+ local claim, err = libjwt.validate( {
17+ ["header_token" ] = "Authorization" ,
18+ ["jwks_files" ] = { "...." , "/usr/share/tokens/jwks.json" } ,
1819 } )
19- if err ~ = "" then
20+ if err and err ~ = "" then
21+ ngx.log( ngx.ERR, "JWT Validation Error: " .. err)
2022 return ngx.say( err)
2123 end
22- if valid then
23- return ngx.say( "OK" )
24+ if claim then
25+ local claim_str = cjson.encode( claim) or "Invalid Claim"
26+ ngx.log( ngx.ERR, "JWT Claims: " .. claim_str)
27+ return ngx.say( claim_str)
2428 end
2529 return ngx.say( "Unauthorized" )
2630 }
You can’t perform that action at this time.
0 commit comments