Layer7 API Management

  • 1.  jot validation

    Posted Sep 20, 2018 11:26 PM

    Hi There,

    we wanted to validate the signature of JWT token against the below key-set(rotation). Am wondering what is this "n' value.

    In generally the jwt would be signed with private-key and validate with public key, but how would I convert the "n" from the below to public key and verify the signature of jwt token?

     

    {
      "keys": [
      {
        "kty": "RSA",
        "alg": "RS256",
        "use": "sig",
        "kid": "3405d0ec4edf60539acf73be64604d49a097189a",
        "n": "vBNfb9rmZLTwVpjoeT9lsLvzwl5rAVWGius9n2AFdibXlTaA_o...",
        "e": "AQAB"
      },
      {
        "kty": "RSA",
        "alg": "RS256",
        "use": "sig",
        "kid": "ac7ebbdff9e77669785f4c530fe2d4a6408bc98d",
        "n": "1L2jYqXcdvdxtY10zT3PTZyTxG_gIScRcSheHYsuRMfdsh40x...",
        "e": "AQAB"
      },
      {
        "kty": "RSA",
        "alg": "RS256",
        "use": "sig",
        "kid": "1838c3d30929ad5f8a84b124538d467dc612cd4f",
        "n": "sblvLT44RjceIc7_sxgOfKmy3Ddm81n4qtjzlFO-VZtampq...",
        "e": "AQAB"
      },
      {
        "kty": "RSA",
        "alg": "RS256",
        "use": "sig",
        "kid": "978ca4118bf1883b316bbca6ce9044d9977f2027",
        "n": "qpe-lPi7HVP8_SRqodC19iWDcYJ-5-wZbBxxxgszoPbphgN8...",
        "e": "AQAB"
      }
      ]
    }



  • 2.  Re: jot validation

    Broadcom Employee
    Posted Sep 23, 2018 08:58 PM

    Hello,

    As per RFC7517

    https://tools.ietf.org/html/rfc7517#section-9.3

     

    The "n” should be the RSA modulus.

     

    I would guess you're using Azure JWT token.

    I don't think you need to manually convert anything. The Decode json web token assertion can auto use the JWKS. (we have few successful cases to validate the Azure JWT)

     

    Regards,

    Mark

     



  • 3.  Re: jot validation

    Posted Oct 08, 2018 05:01 PM

    Mark, we are not using Azure we are using some other IAM vendor can't disclose it.Basically i have to verify signature of the jwt token.Essentially we get kid in the jwt we have to match the corresponding kid in the keys which i captured in the first msg,this keys i will make a call to vendor to retrieve the keys change dynamically every month. Not sure how to peform it.I was thinking like first i will make a call to the vendor and will put the keys in the catche and will compare the kid against the keys and which ever kid match will extract the key and will verify the signature.Does this is mechanism supported by API gateway 9.1?



  • 4.  Re: jot validation

    Broadcom Employee
    Posted Oct 08, 2018 09:20 PM

    I am not sure the other vendor, but Azure change the key set timely as well. Azure provides a public URL to retrieve the current key set.

    In my case, we use the key set in cache to validate the jwt first, if fail, use route via http assertion to retrieve the current key set and store in cache, validate the jwt again, if still fail, then the jwt is invalid.

     

    For you IAM vendor, it should be similar.



  • 5.  Re: jot validation

    Posted Oct 17, 2018 06:53 AM

    We are using some thing similar to google key rotation.The key rotation is done approximately 4 times in a year,so could you let me know the better recommendation how much time i should set for max acceptable age ,can i have some thing like 2 months(in sec)? Pls advice.



  • 6.  Re: jot validation

    Broadcom Employee
    Posted Oct 17, 2018 06:47 PM

    Yes, it should be fine.

    As our policy logic will update the cache if first try is fail, you can set as long as you wish.

    Although the "max acceptable age” has a limit, but the limit should be 100,000,000 seconds, much longer than 2 months.



  • 7.  Re: jot validation

    Posted Oct 23, 2018 06:47 AM

    Hi there,am unable to have i variable inside key ID which throws an exception,which mean am looping with for each run assertion with an iteration no since there are few key-sets received from google.Pls advice.

     

     

     



  • 8.  Re: jot validation

    Posted Oct 24, 2018 02:00 AM

    there is an assertion that can be used to retrieve a variable at a certain position of a multi-valued variable:

    Look Up Item by Index Position Assertion

    Look Up Item by Index Position Assertion - CA API Gateway - 9.3 - CA Technologies Documentation 

     

    put that before the 'decode Json Web Token' assertion to retrieve the key id and then use that resulting variable in the Key ID field

     

    I hope that helps



  • 9.  Re: jot validation

    Posted Oct 31, 2018 08:21 AM

    Thanks for the reply.Am just wondering in the google key-set we received the keys are quite different which mean they doesn't look alike public keys, infact the decode jwt assertion validate the signature of the msg with the google keys.

    Generally the public keys starts with Begin and End certificate lines.I presume the google uses RSA(asymmetric) but their 'n' value of cert doesn't sounds like a public cert. Pls comment on it.



  • 10.  Re: jot validation

    Posted Nov 02, 2018 01:24 PM

    Did you run into any errors after using that in the Key ID field? If so, what was the error or behaviour observed?