ILEastic
ILEastic copied to clipboard
Unable to use JWKS endpoints using proc ptr
@NielsLiisberg I was trying to write a sample for JWKS implementation with below code. anytime I make a PROCPTR call, it seems I am upsetting some pointer values. Do you see any obvious issues with below code. I am quite bad with c, so unable to debug and identify issue myself. I was looking forward to use it soon so any help is appreciated.
**FREE // ILEastic : JWT Token secured route
ctl-opt decEdit('0,') datEdit(*YMD.) main(main); ctl-opt debug(*yes) bndDir('ILEASTIC'); ctl-opt thread(*CONCURRENT);
/include ./headers/ileastic.rpgle /include ./plugins/jwt/jwt_h.rpgle /include ./plugins/jwt/jwtplugin_h.rpgle
// ----------------------------------------------------------------------------- // Program Entry Point // ----------------------------------------------------------------------------- dcl-proc main; dcl-ds config likeds(il_config);
// The server will listen on port 44000. config.port = 44000; config.host = '*ANY';
// Sets the key which will be used for verifying the JWT token. il_jwt_addVerifyStructFromJWKS(%paddr('IdP_Jwks'));
// Adds the JWT plugin to the chain of plugins il_addPlugin(config : %paddr('il_jwt_filter') : IL_PREREQUEST);
// Adds the secured route. il_addRoute(config : %paddr(getTime) : IL_POST);
// Starts the server. il_listen(config); end-proc;
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -* // Procedure - IdP_Jwks * // Description - routine to retrieve public key from JWKS end point * //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*
dcl-proc IdP_Jwks; dcl-pi *n extproc(*dclcase); jwksDs LikeDS(jwksDs_t) Dim(10); keyCnt Packed(3 :0); end-pi;
//dcl-s JWKS_Uri Char(500);
// This is dummy data to show the issue. jwksDs(1).KeyTp = 'RSA'; jwksDs(1).KeyId = 'abcde_eaa'; jwksDs(1).Usage = 'sig'; jwksDs(1).Alg = 'RS512'; keyCnt = 1; return;
end-proc;
// ----------------------------------------------------------------------------- // Servlet callback implementation // ----------------------------------------------------------------------------- dcl-proc getTime; dcl-pi *n; request likeds(IL_REQUEST); response likeds(IL_RESPONSE); end-pi;
il_responseWrite(response : %char(%time())); end-proc;
=====
40 02/05/23 21:47:11.017414 < 3BadScalar 000230 ILEASTIC ILEASTIC
From Program . . . . . . . : Ex3203BadScalar
To module . . . . . . . . . : ILEASTIC
To procedure . . . . . . . : findRoute
Statement . . . . . . . . . : 13
Thread . . . . : 00000011
Message . . . . : Scalar operand contains a value that is not valid.
Cause . . . . . : The length of the invalid scalar operand is 8. The bit
offset to the invalid field is X'0000'. The operand number is 1. The
invalid data is X'0000000004040420'.
40 02/05/23 21:47:11.017584 ILEASTIC ILEASTIC *STMT ILEASTIC ILEASTIC
From module . . . . . . . . : ILEASTIC
From procedure . . . . . . : findRoute
Statement . . . . . . . . . : 13
To module . . . . . . . . . : ILEASTIC
To procedure . . . . . . . : findRoute
Statement . . . . . . . . . : 13
Thread . . . . : 00000011
Message . . . . : Space offset X'00000000' or X'0000000004040420' is outside
current limit for object JOB_DETAILS.
Cause . . . . . : A program tried to set a space pointer, tried to use
storage outside a space, or tried to use an unallocated page in teraspace.
The space class is X'07'. The space class designates the type of space: