[ 
https://issues.apache.org/jira/browse/KNOX-2527?focusedWorklogId=534377&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-534377
 ]

ASF GitHub Bot logged work on KNOX-2527:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Jan/21 17:55
            Start Date: 11/Jan/21 17:55
    Worklog Time Spent: 10m 
      Work Description: risdenk commented on a change in pull request #397:
URL: https://github.com/apache/knox/pull/397#discussion_r555234268



##########
File path: 
gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/DefaultTokenAuthorityService.java
##########
@@ -78,17 +83,22 @@
   private GatewayConfig config;
 
   private char[] cachedSigningKeyPassphrase;
+  private byte[] cachedSigningHmacSecret;
   private RSAPrivateKey signingKey;
 
   static {
-      // Only standard RSA signature algorithms are accepted
+      // Only standard RSA and HMAC signature algorithms are accepted
       // https://tools.ietf.org/html/rfc7518
       SUPPORTED_SIG_ALGS.add("RS256");
       SUPPORTED_SIG_ALGS.add("RS384");
       SUPPORTED_SIG_ALGS.add("RS512");
       SUPPORTED_SIG_ALGS.add("PS256");
       SUPPORTED_SIG_ALGS.add("PS384");
       SUPPORTED_SIG_ALGS.add("PS512");
+      //HMAC
+      SUPPORTED_SIG_ALGS.add("HS256");
+      SUPPORTED_SIG_ALGS.add("HS384");
+      SUPPORTED_SIG_ALGS.add("HS512");

Review comment:
       Would it make sense to have two `SUPPORTED_SIG_ALGS` lists? One for PKI 
and the other for HMAC? Then can check and hopefully provide a better error 
message if the wrong signature algorithm is chosen for the wrong method? 




----------------------------------------------------------------
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.

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 534377)
    Time Spent: 20m  (was: 10m)

> Support HMAC signature/verification in JWT token authority
> ----------------------------------------------------------
>
>                 Key: KNOX-2527
>                 URL: https://issues.apache.org/jira/browse/KNOX-2527
>             Project: Apache Knox
>          Issue Type: New Feature
>          Components: KnoxSSO, Server
>    Affects Versions: 1.5.0
>            Reporter: Sandor Molnar
>            Assignee: Sandor Molnar
>            Priority: Major
>             Fix For: 1.6.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> As of now, in {{DefaultTokenAuthorityService}}, the generated JWT token is 
> signed by RSA (PKI). It would be beneficial to add support for HMAC as well 
> so that token signature/verification would not require a keystore being set 
> but using a secret stored via Knox's alias service. The recommended alias 
> name is {{gateway.signing.hmac.secret}}
>  To support backward compatibility, the implementation should use HMAC 
> signature/verification only if:
>  - the HMAC secret is configured via the alias service for the gateway, and
>  - there is no previously pre-configured {{gateway.signing.keystore.name}} 
> which is a clear indication of end-user preference of using PKI signatures.
> The default HMAC signing algorithm should be {{HS256}} (HMAC using SHA-256 
> hash algorithm) and clients should be able to change it by already existing 
> request parameters called {{knoxsso.token.sigalg}} or {{knox.token.sigalg}}. 
> Other valid values are:
>  - {{HS384}} (HMAC using SHA-384 hash algorithm)
>  - {{HS512}} (HMAC using SHA-512 hash algorithm)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to