KNOX-2527 - Added support for HMAC signature/verification in JWT token authority#397
Conversation
.../src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityService.java
Outdated
Show resolved
Hide resolved
lmccay
left a comment
There was a problem hiding this comment.
Sandor - this is a great improvement for JWT signing. I think that we make a couple adjustments to allow the mix of both RSA/PKI and HMAC methods though and I've made a couple comments to that end.
.../java/org/apache/knox/gateway/provider/federation/jwt/filter/JWTAuthCodeAssertionFilter.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityService.java
Outdated
Show resolved
Hide resolved
gateway-spi/src/main/java/org/apache/knox/gateway/services/security/token/TokenUtils.java
Show resolved
Hide resolved
.../src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityService.java
Outdated
Show resolved
Hide resolved
878e9b8 to
9d3e152
Compare
|
@lmccay - I tested it with different topologies come with different signature algorithms (HS256 and RS 256) and it was working as expected. Could you please give me another review and let me know if I can merge this PR? HS256 testCreated a 256 bit HMAC secret: gateway.log: Testing the acquired token: gateway-audit.log: RS256 test
gateway.log: Testing the acquired token: gateway-audit.log: The only difference between the |
…in JWT token authority (apache#397) Change-Id: I3422729e60f8c41e4b001967c56612331725a756
* changes: CDPD-21175 KNOX-2527 - Added support for HMAC signature/verification in JWT token authority (apache#397) CDPD-21175 KNOX-2382 - Logging token identifier for easier error debugging (apache#352)
What changes were proposed in this pull request?
In this change, I'm extending the current RSA based token signing with the use of HMAC. As described in the corresponding JIRA, from now on end-users are able to configure an HMAC secret in the gateway's alias service which then will be used as a signature secret (pay attention to the key size requirements!).
How was this patch tested?
Updated and ran a full maven build successfully and executed E2E tests:
gateway.signing.hmac.secretalias:KNOXTOKENservice in thesandboxtopology:tokenbased:knox.token.sigalgparameter toHS384, reset thegateway.signing.hmac.secretwith an appropriate secret (key length matters) and repeated steps 4-5. The call finished successfully.knox.token.sigalgparameter toHS512, reset thegateway.signing.hmac.secretwith an appropriate secret (key length matters) and repeated steps 4-5. The call finished successfully.knox.token.sigalgparameter toHS123and repeated steps 4-5. Call failed as expected.gateway.signing.hmac.secretand re-tried the get/verify steps; all were OK.Logged into the Knox home page successfully (the
hadoop-jwtcookie was added properly)Also tested the case when the
gateway.signing.keystore.namewas set.