IBM Verify

 View Only
  • 1.  JWKS endpoint shows all cert in kdb

    Posted Thu August 01, 2024 07:31 AM
    Edited by Sascha W Thu August 01, 2024 07:37 AM

    Hi,

    i usually put all my oauth certificates in one kdb.

    I have multiple OAUTH definitions (almost 100) and multiple JWKS urls (each with the oauth definition name in it) but the endpoint shows ALL the certificates in the KDB.

    Apart from not needing to cross-share the certs with different partner i have a serious issue: some java library fail to manage the jwks content since its too big, and some partners complain about having to manage all the unneeded certificates when they only need one.

    Is there a way to let the jwks endpoint from OAUTH definition "Pluto" to show only the "Pluto" cert?

    The only workaround i found is to have a different kdb for each oauth definition but i don't want to end up with 100+ kdbs.

    Thank you

    S.



  • 2.  RE: JWKS endpoint shows all cert in kdb

    Posted Thu August 01, 2024 08:23 AM

    Hi Sascha!

    Just curious to why would you have so many OAuth definitions to begin with?



    ------------------------------
    Jonatan Wålegård
    ------------------------------



  • 3.  RE: JWKS endpoint shows all cert in kdb

    Posted Fri August 02, 2024 04:30 AM
    Edited by Sascha W Fri August 02, 2024 05:23 AM

    Hi, the customer needs to separate each oauth application as a separate entity.

    The IDP for application A must be different from the IDP for application B so each token has a different issuer and different cert.




  • 4.  RE: JWKS endpoint shows all cert in kdb

    Posted Fri August 02, 2024 06:23 AM

    @Sascha W I think you are being forced into a corner where it's not really optimal to be. I would start to question your approach and/or try to work around it and/or perhaps use SAML instead. A lot of things can be done to tighten the security if it's a security concern. 

    With that said I hope someone can answer your initial question.

    I also want to share some info about the rotation of the keyset, because I had a ticket before with IBM about it:

    "There is no specific endpoint or configuration to rotate those keys automatically.

    Details about all supported endpoints

    https://www.ibm.com/docs/en/sva/10.0.7?topic=support-oauth-20-endpoints

    The rotation of the key should be done manually. The relying Party will use the JWKS Uri to get the keys of Openid Provider to validate the tokens."

    Might be good to know.

    Good luck



    ------------------------------
    Jonatan Wålegård
    ------------------------------



  • 5.  RE: JWKS endpoint shows all cert in kdb

    Posted Mon August 05, 2024 12:41 AM

    I can probably help you with a crafty Lua HTTP transformation rule to filter out the jwks entries that you don't need based on the JWKS URL being accessed and the x5c of the key related to the application you wish to show (if there is only one). If there is something in the x5c that identifies the app (eg the CN contains something related to the OIDC definition name), then that would make the filtering "alogrithmic" rather than you having to manage a definition -> KID list yourself. Can you provide a sample of the current jwks data, an example of the definition name (i.e. JWKS URL that is used for a particular app), and which key from the JWKS that "app" relates to? Perhaps if there is some identifying string in the JWKS entry that maps to a part of the JWKS endpoint URL path, then you can get clever here and use a single HTTP transformation rule just applied to the response from each and every JWKS endpoint.



    ------------------------------
    Shane Weeden
    IBM
    ------------------------------



  • 6.  RE: JWKS endpoint shows all cert in kdb

    Posted Mon August 05, 2024 02:09 AM
    Edited by Shane Weeden Mon August 05, 2024 02:12 AM

    In the interests of trying to get you to a solution quickly, here's a SAMPLE Lua HTTP transformation rule that might help start you in the right direction: 

    https://github.com/sbweeden/blog_assets/blob/master/lua_http_transformations/jwks_filter_app.lua

    There is a variable declared in it called definitionNameToCNList which maps an OAuth/OIDC definition name to a list of strings. Each string is a lower case DN, and if the subject of any of the certificates defined in an x5c array of any key in the JWKS matches any of these lower case DNs, then that key will be included in the JWKS endpoint response, otherwise it will be filtered out.

    This takes a little while to get your head around, but basically if you listed all of your OIDC definitions, and for each you had an array (even if that array only contains one DN string) of the DNs of the certificates from keys you want included in the output for the JWKS endpoint for that OIDC definition, then only those keys you want for each definition will be returned. 

    There is a comment block at the top of the file that shows how I configured it in the webseal configuration file. 



    ------------------------------
    Shane Weeden
    IBM
    ------------------------------



  • 7.  RE: JWKS endpoint shows all cert in kdb

    Posted Mon August 05, 2024 05:33 AM

    Hi Shane, thank for you reply and your effort in writing this lua script.

    my cns are not lower case, can i just put it in the json in lower case and it will work?




  • 8.  RE: JWKS endpoint shows all cert in kdb

    Posted Mon August 05, 2024 06:47 AM

    Yes. Read the code and try it first. I comment the debug loging output too as you observe what it does. The LoggingUtils Lua file is in the same directory. 



    ------------------------------
    Shane Weeden
    IBM
    ------------------------------



  • 9.  RE: JWKS endpoint shows all cert in kdb

    Posted Mon August 05, 2024 06:56 AM

    Thank you so much. I'm gonna try it after summer, only problem for me is that i'm gonna end up with a very big json,

    i'll have to maintain it updated and to begin i'll have to write script just for filling the initial json with 100+ definitions/certs i already have.

    I'll probably put the json in a separate lua script which i'll import in the main one (if is possible as for mapping rules).

    Thank you again