buildbarn / bb-storage

Storage daemon, capable of storing data for the Remote Execution protocol
Apache License 2.0
142 stars 91 forks source link

Change AuthorizationHeaderParserConfiguration to take a JSON Web Key Set #179

Closed mortenmj closed 1 year ago

mortenmj commented 1 year ago

This adds a signature validator for JWKs (JSON Web Keys) to pkg/jwt. The new validator takes a JSON structure like the below, and will instantiate the correct signature validator for whichever types of keys are found in the structure.

{
   "keys":[
      {
         "kty":"RSA",
         "n":"u1SU1LfVLPHCozMxH2Mo4lgOEePzNm0tRgeLezV6ffAt0gunVTLw7onLRnrq0_IzW7yWR7QkrmBL7jTKEn5u-qKhbwKfBstIs-bMY2Zkp18gnTxKLxoS2tFczGkPLPgizskuemMghRniWaoLcyehkd3qqGElvW_VDL5AaWTg0nLVkjRo9z-40RQzuVaE8AkAFmxZzow3x-VJYKdjykkJ0iT9wCS0DRTXu269V264Vf_3jvredZiKRkgwlL9xNAwxXFg0x_XFw005UWVRIkdgcKWTjpBP2dPwVZ4WWC-9aGVd-Gyn1o0CLelf4rEjGoXbAAEgAqeGUxrcIlbjXfbcmw",
         "e":"AQAB",
         "alg":"RS256",
         "kid":"7c0b6913fe13820a333399ace426e70535a9a0bf",
         "use":"sig"
      }
   ]
}

The fields hmac_key and public_key in AuthorizationHeaderParserConfiguration have been replaced by a new field, jwks_inline, which takes the above structure.

As a follow-on step to this work, in a later PR, this data can be read from a file and periodically refreshed similar to how TLS certificates are treated.

EdSchouten commented 1 year ago

Thanks!