Last active
December 31, 2019 04:58
-
-
Save eshleebien/aea78b4a40c803a37e7adb725e907a5f to your computer and use it in GitHub Desktop.
For Kong Gateway in Kubernetes medium article
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
apiVersion: configuration.konghq.com/v1 | |
kind: KongPlugin | |
metadata: | |
name: read-jwt-token | |
labels: | |
global: "true" | |
disabled: false | |
config: | |
functions: | |
- return function() | |
local ngx = require "ngx.base64" | |
local json = require "cjson" | |
local jwt = kong.request.get_header("authorization") | |
local header, data, sig = string.match(jwt, "(.*)%.(.*)%.(.*)") | |
local dcd = ngx.decode_base64url(data) | |
local jdcd = json.decode(dcd) | |
-- now do something with your jwt payload. | |
for k,v in pairs(jdcd) do | |
print(v) | |
end | |
end | |
plugin: post-function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment