Skip to content
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

KAFKA-18627:add allowed modules to JaasUtils #18683

Open
wants to merge 11 commits into
base: trunk
Choose a base branch
from

Conversation

gongxuanzhang
Copy link
Contributor

@github-actions github-actions bot added triage PRs from the community clients small Small PRs labels Jan 24, 2025
@github-actions github-actions bot added core Kafka Broker and removed small Small PRs labels Jan 24, 2025
@gongxuanzhang
Copy link
Contributor Author

I cannot reproduce this issue locally. I suspect that the test case has added environment variables

@gongxuanzhang
Copy link
Contributor Author

@chia7712 PTAL

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gongxuanzhang thanks for this patch

List<String> jaasModules = new ArrayList<>();
jaasModules.add(ALLOWED_LOGIN_MODULES_DEFAULT);
jaasModules.addAll(Arrays.asList(customJaas));
System.setProperty(org.apache.kafka.common.security.JaasUtils.ALLOWED_LOGIN_MODULES_CONFIG, String.join(",", jaasModules));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why to use full package name?

@@ -75,6 +76,7 @@ public void setup() throws Exception {
TestJaasConfig testJaasConfig = TestJaasConfig.createConfiguration("PLAIN", Collections.singletonList("PLAIN"));
testJaasConfig.setClientOptions("PLAIN", TestJaasConfig.USERNAME, "anotherpassword");
server = createEchoServer(securityProtocol);
JaasUtils.allowDefaultJaasAndCustomJass();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not add any other modules, so do we really need it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case reports an error. It may be that a change to the default configuration caused the jaas tested to be rejected.
So I add this line

@@ -74,6 +75,7 @@ public void setup() throws Exception {
credentialCache = new CredentialCache();
SaslAuthenticatorTest.TestLogin.loginCount.set(0);
startTimeMs = time.milliseconds();
JaasUtils.allowDefaultJaasAndCustomJass();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -70,7 +70,6 @@ class SaslSslAdminIntegrationTest extends BaseAdminIntegrationTest with SaslSetu
this.serverConfig.setProperty(DelegationTokenManagerConfigs.DELEGATION_TOKEN_SECRET_KEY_CONFIG, secretKey)
this.serverConfig.setProperty(DelegationTokenManagerConfigs.DELEGATION_TOKEN_EXPIRY_TIME_MS_CONFIG, Long.MaxValue.toString)
this.serverConfig.setProperty(DelegationTokenManagerConfigs.DELEGATION_TOKEN_MAX_LIFETIME_CONFIG, Long.MaxValue.toString)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert unrelated change

@@ -46,7 +46,6 @@ abstract class SaslEndToEndAuthorizationTest extends EndToEndAuthorizationTest {
producerConfig.put(SaslConfigs.SASL_JAAS_CONFIG, clientLoginContext)
consumerConfig.put(SaslConfigs.SASL_JAAS_CONFIG, clientLoginContext)
adminClientConfig.put(SaslConfigs.SASL_JAAS_CONFIG, clientLoginContext)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@github-actions github-actions bot removed the triage PRs from the community label Jan 30, 2025
@gongxuanzhang
Copy link
Contributor Author

@chia7712 PTAL

@@ -68,11 +70,13 @@ public void tearDown() throws Exception {

@Test
public void testConfigNoOptions() throws Exception {
System.setProperty(ALLOWED_LOGIN_MODULES_CONFIG, "test.testConfigNoOptions");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this change means we break some compatibility ...

  1. print warning message if users define the org.apache.kafka.disallowed.login.modules
  2. adopt the org.apache.kafka.allowed.login.modules if it is existent
  3. evaluate the modules according to DISALLOWED_LOGIN_MODULES_DEFAULT

Additionally, we should open a jira for 5.0 to add ALLOWED_LOGIN_MODULES_DEFAULT

WDYT?

@github-actions github-actions bot added the small Small PRs label Feb 6, 2025
@gongxuanzhang
Copy link
Contributor Author

@chia7712 PTAL

Copy link
Contributor

@TaiJuWu TaiJuWu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. By the way, could you open a jira for 5.0 to remove DISALLOWED_LOGIN_MODULES_CONFIG

Comment on lines -26 to +30
private JaasUtils() {}
private JaasUtils() {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert unrelated this change.

@@ -16,13 +16,17 @@
*/
package org.apache.kafka.common.security;


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revet this too.

}
String loginModuleName = appConfigurationEntry.getLoginModuleName().trim();
String allowedProperty = System.getProperty(ALLOWED_LOGIN_MODULES_CONFIG);
if (allowedProperty != null) {
Copy link
Contributor

@TaiJuWu TaiJuWu Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we need to consider a case if a module in disallow and allow at same time?
Maybe it will happen in the meantime.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logic is to prioritize "allow", right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense, thanks!

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gongxuanzhang thanks for this patch. overall LGTM, and could you please add this change to upgrade.html?

Also ping @showuon @mumrah @mimaison - after merging this PR, we can file a ticket for 5.0 to remove disallowed list

@gongxuanzhang
Copy link
Contributor Author

@chia7712 PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants