@@ -11,6 +11,7 @@ local validate_realm_roles = require("kong.plugins.jwt-keycloak.validators.roles
11
11
local validate_client_roles = require (" kong.plugins.jwt-keycloak.validators.roles" ).validate_client_roles
12
12
13
13
local re_gmatch = ngx .re .gmatch
14
+ local decode_base64 = ngx .decode_base64
14
15
15
16
local JwtKeycloakHandler = {
16
17
VERSION = " 1.2.1"
@@ -27,6 +28,24 @@ kong.log.debug('JWT_KEYCLOAK_PRIORITY: ' .. priority)
27
28
28
29
JwtKeycloakHandler .PRIORITY = priority
29
30
31
+ ---- ---------------------------------------------------------------------------
32
+ -- custom helper function of the extended plugin "jwt-keycloak"
33
+ -- --> this is contained in jwt_parser, but has a breaking change in 3.5
34
+ -- https://github.com/telekom-digioss/kong-plugin-jwt-keycloak/pull/9
35
+ ---- ---------------------------------------------------------------------------
36
+ local function custom_base64_decode (input )
37
+ local remainder = # input % 4
38
+ if remainder > 0 then
39
+ local padlen = 4 - remainder
40
+ input = input .. rep (" =" , padlen )
41
+ end
42
+
43
+ input = input :gsub (" -" , " +" ):gsub (" _" , " /" )
44
+ return decode_base64 (input )
45
+ end
46
+
47
+
48
+
30
49
function table_to_string (tbl )
31
50
local result = " "
32
51
for k , v in pairs (tbl ) do
@@ -239,7 +258,7 @@ local function get_keys(well_known_endpoint)
239
258
240
259
local decoded_keys = {}
241
260
for i , key in ipairs (keys ) do
242
- decoded_keys [i ] = jwt_decoder : base64_decode (key )
261
+ decoded_keys [i ] = custom_base64_decode (key )
243
262
end
244
263
245
264
kong .log .debug (' Number of keys retrieved: ' .. table .getn (decoded_keys ))
0 commit comments