Skip to content

Commit 0064b97

Browse files
committed
send valid JSON in error reponse
use string type for object names see p. 3 in Ecma JSON standard https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
1 parent a1571c7 commit 0064b97

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bearer.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020
if token == nil then
2121
ngx.status = ngx.HTTP_UNAUTHORIZED
2222
ngx.header.content_type = "application/json; charset=utf-8"
23-
ngx.say("{error: \"missing JWT token or Authorization header\"}")
23+
ngx.say("{\"error\": \"missing JWT token or Authorization header\"}")
2424
ngx.exit(ngx.HTTP_UNAUTHORIZED)
2525
end
2626

@@ -42,7 +42,7 @@ if not jwt_obj["verified"] then
4242
ngx.status = ngx.HTTP_UNAUTHORIZED
4343
ngx.log(ngx.WARN, jwt_obj.reason)
4444
ngx.header.content_type = "application/json; charset=utf-8"
45-
ngx.say("{error: \"" .. jwt_obj.reason .. "\"}")
45+
ngx.say("{\"error\": \"" .. jwt_obj.reason .. "\"}")
4646
ngx.exit(ngx.HTTP_UNAUTHORIZED)
4747
end
4848

0 commit comments

Comments
 (0)