-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YARN-11738 Modernize SecretManager config #7144
base: trunk
Are you sure you want to change the base?
Conversation
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
@K0K0V0K , thanks for working on this! If we change the HMAC and key length, then the keys generated before this change and after this change won't be the same. Then, this become an incompatible change. We probably need to add confs to set the algorithm and key length for backward compatibility. |
1352cfd
to
9854cee
Compare
Hi @szetszwo and @brumi1024 ! First of all thanks for the review. I modified the PR, now it is configurable. I know to create a configuration object at class static method is a bit risky, but that was the quick win what i found. |
💔 -1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
...mmon-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/SecretManager.java
Outdated
Show resolved
Hide resolved
💔 -1 overall
This message was automatically generated. |
Make hash algorithm at SecretManager configurable. - hadoop.security.hmac-algorithm: The name of the hashing algorithm. Default: HmacSHA1 - hadoop.security.hmac-length: The length of the random keys to use. Default: 64 Change-Id: I735573c1d7b9f256e05722c98cd550cd8dd4acf0
🎊 +1 overall
This message was automatically generated. |
Hi @brumi1024 @szetszwo! May i ask a review again? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@K0K0V0K , thanks for the update! Please see the comments inlined.
public static final String HMAC_ALGORITHM = "hadoop.security.hmac-algorithm"; | ||
public static final String DEFAULT_HMAC_ALGORITHM = "HmacSHA1"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add "secret-manager.key-generator.algorithm" (we may use a non-hmac algorithm).
- Also, we should use the existing naming convention.
- The javadoc is not useful. Let's skip it.
public static final String HADOOP_SECURITY_SECRET_MANAGER_KEY_GENERATOR_ALGORITHM_KEY
= "hadoop.security.secret-manager.key-generator.algorithm";
public static final String HADOOP_SECURITY_SECRET_MANAGER_KEY_GENERATOR_ALGORITHM_DEFAULT
= "HmacSHA1";
public static final String HMAC_LENGTH = "hadoop.security.hmac-length"; | ||
public static final int DEFAULT_HMAC_LENGTH = 64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "key-length". It has nothing to do with hmac.
public static final String HADOOP_SECURITY_SECRET_MANAGER_KEY_LENGTH_KEY
= "hadoop.security.secret-manager.key-length";
public static final int HADOOP_SECURITY_SECRET_MANAGER_KEY_LENGTH_DEFAULT
= 64;
} catch (NoSuchAlgorithmException nsa) { | ||
throw new IllegalArgumentException("Can't find " + DEFAULT_HMAC_ALGORITHM + | ||
" algorithm."); | ||
throw new IllegalArgumentException("Can't find " + SELECTED_ALGORITHM + " algorithm."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's include the cause:
throw new IllegalArgumentException("Failed to get " + HMAC_ALGORITHM, nsa);
} catch (NoSuchAlgorithmException nsa) { | ||
throw new IllegalArgumentException("Can't find " + DEFAULT_HMAC_ALGORITHM + | ||
" algorithm."); | ||
throw new IllegalArgumentException("Can't find " + SELECTED_ALGORITHM + " algorithm."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's include the cause:
throw new IllegalArgumentException("Failed to get " + HMAC_ALGORITHM, nsa);
<description>The configuration key specifying the hashing algorithm used for | ||
HMAC (Hash-based Message Authentication Code) operations. | ||
|
||
The HMAC algorithm is used in token management to compute secure | ||
message digests. This configuration allows users to specify the | ||
algorithm to be used for HMAC operations. The algorithm must be a | ||
valid cryptographic hash algorithm supported by the Java Cryptography | ||
Architecture (JCA). Common examples include "HmacSHA1", "HmacSHA256", | ||
and "HmacSHA512".</description> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's update the description as below:
The configuration key specifying the KeyGenerator algorithm used in SecretManager
for generating secret keys. The algorithm must be a KeyGenerator algorithm supported by
the Java Cryptography Architecture (JCA). Common examples include "HmacSHA1",
"HmacSHA256", and "HmacSHA512".
<description>The configuration key specifying the key length for HMAC (Hash-based | ||
Message Authentication Code) operations. | ||
|
||
This property determines the size of the secret keys generated | ||
for HMAC computations. The key length must be appropriate for the | ||
selected HMAC algorithm. For example, longer keys are generally | ||
more secure but may not be supported by all algorithms.</description> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this to:
The configuration key specifying the key length of the generated secret keys
in SecretManager. The key length must be appropriate for the algorithm.
For example, longer keys are generally more secure but may not be supported
by all algorithms.
Description of PR
Make hash algorithm at SecretManager configurable.
How was this patch tested?