Dhairya-007 opened a new pull request, #29425:
URL: https://github.com/apache/camel/pull/29425

   `GrpcConfiguration.jwtAlgorithm` declared
   
   ```java
   @UriParam(label = "security", defaultValue = "HMAC256", enums = 
"HMAC256,HMAC384,HMAC512,RSA256,RSA384,RSA512")
   private JwtAlgorithm jwtAlgorithm = JwtAlgorithm.HMAC256;
   ```
   
   but `JwtAlgorithm` only defines `HMAC256`, `HMAC384` and `HMAC512`. `RSA256`,
   `RSA384` and `RSA512` are not constants of that enum, so 
`jwtAlgorithm=RSA256`
   cannot work — it fails while converting the URI value to `JwtAlgorithm`, 
before
   `JwtHelper` is reached. `JwtHelper.selectAlgorithm` implements only the three
   HMAC variants too, and throws `"JWT algorithm ... not implemented"` for 
anything
   else.
   
   Because `enums` is taken verbatim by the schema generator, those three 
phantom
   values propagated into `grpc.json`, the catalog copy and from there into the
   reference docs, IDE completion and `camel-jbang` completion — the option 
offered
   six values of which three could never be set.
   
   The component's own hand-written documentation table already describes the
   option correctly:
   
   ```
   |||jwtAlgorithm|HMAC256(default) or (HMAC384,HMAC512)|Optional
   ```
   
   so the annotation was the stale copy. This drops the three values that do not
   exist; the remaining list is exactly `JwtAlgorithm`'s constants, which is 
also
   what the generator would derive on its own.
   
   ### Verification
   
   The build cannot run in my environment, so I compiled the unchanged
   `JwtAlgorithm` and `JwtHelper` sources together with the new test against
   minimal stubs for `com.auth0.jwt` and exercised the same code path:
   
   ```
   HMAC256 -> selectAlgorithm=HS256  token=signed
   HMAC384 -> selectAlgorithm=HS384  token=signed
   HMAC512 -> selectAlgorithm=HS512  token=signed
   values() = [HMAC256, HMAC384, HMAC512]
   ALL DECLARED ALGORITHMS IMPLEMENTED
   RSA256 -> IllegalArgumentException: not a JwtAlgorithm constant
   RSA384 -> IllegalArgumentException: not a JwtAlgorithm constant
   RSA512 -> IllegalArgumentException: not a JwtAlgorithm constant
   ```
   
   The regenerated `grpc.json` files were edited by hand for the same reason; I
   checked that the component copy and the `camel-catalog` copy remain
   byte-identical (`diff -q`).
   
   The added `JwtHelperTest` guards the invariant going forward: every constant 
of
   `JwtAlgorithm` must be backed by an implementation in `JwtHelper`, so adding 
one
   without a matching case fails the build instead of being advertised as 
usable.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to