Skip to content

Instantly share code, notes, and snippets.

@eshleebien
Last active December 31, 2019 04:58
Show Gist options
  • Save eshleebien/aea78b4a40c803a37e7adb725e907a5f to your computer and use it in GitHub Desktop.
Save eshleebien/aea78b4a40c803a37e7adb725e907a5f to your computer and use it in GitHub Desktop.
For Kong Gateway in Kubernetes medium article
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