GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MINOR: Improve validation in OAuthBearerValidatorCallbackHandler (#24… · coderbruis/kafka@bc4e0b9

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • clients/src
    • main/java/org/apache/kafka/common
      • config
        • SaslConfigs.java
      • security/oauthbearer
        • OAuthBearerValidatorCallbackHandler.java
    • test/java/org/apache/kafka/common/security/oauthbearer
      • OAuthBearerValidatorCallbackHandlerTest.java
  • docs/getting-started
    • upgrade.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎clients/src/main/java/org/apache/kafka/common/config/SaslConfigs.java‎

Copy file name to clipboardExpand all lines: clients/src/main/java/org/apache/kafka/common/config/SaslConfigs.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public class SaslConfigs {
157157
+ "<p>The built-in <code>JwtValidator</code> implementations are:</p>"
158158
+ "<ul>"
159159
+ "<li><code>org.apache.kafka.common.security.oauthbearer.BrokerJwtValidator</code></li>"
160-
+ "<li><code>org.apache.kafka.common.security.oauthbearer.ClientJwtValidator</code></li>"
160+
+ "<li><code>org.apache.kafka.common.security.oauthbearer.ClientJwtValidator</code> (clients only, it does not verify JWT signatures and cannot be used on brokers)</li>"
161161
+ "<li><code>org.apache.kafka.common.security.oauthbearer.DefaultJwtValidator</code></li>"
162162
+ "</ul>";
163163

Collapse file

‎clients/src/main/java/org/apache/kafka/common/security/oauthbearer/OAuthBearerValidatorCallbackHandler.java‎

Copy file name to clipboardExpand all lines: clients/src/main/java/org/apache/kafka/common/security/oauthbearer/OAuthBearerValidatorCallbackHandler.java
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ public void configure(Map<String, ?> configs, String saslMechanism, List<AppConf
127127
SaslConfigs.SASL_OAUTHBEARER_JWT_VALIDATOR_CLASS));
128128
}
129129

130+
if (validator instanceof ClientJwtValidator) {
131+
Utils.closeQuietly(validator, "JWT validator");
132+
throw new ConfigException(String.format(
133+
"The OAuth validator for the broker cannot use \"%s\" because it does not verify JWT signatures." +
134+
" Set \"%s\" to a signature-verifying validator, such as \"%s\".",
135+
ClientJwtValidator.class.getName(),
136+
SaslConfigs.SASL_OAUTHBEARER_JWT_VALIDATOR_CLASS,
137+
BrokerJwtValidator.class.getName()));
138+
}
139+
130140
jwtValidator = validator;
131141
}
132142

Collapse file

‎clients/src/test/java/org/apache/kafka/common/security/oauthbearer/OAuthBearerValidatorCallbackHandlerTest.java‎

Copy file name to clipboardExpand all lines: clients/src/test/java/org/apache/kafka/common/security/oauthbearer/OAuthBearerValidatorCallbackHandlerTest.java
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,16 @@ public void testFailsToStartWhenExpectedIssuerMissingWithJwksUrl() {
256256
SaslConfigs.SASL_OAUTHBEARER_EXPECTED_ISSUER);
257257
}
258258

259+
@Test
260+
public void testFailsToStartWithClientJwtValidator() {
261+
Map<String, ?> configs = getSaslConfigs(SaslConfigs.SASL_OAUTHBEARER_JWT_VALIDATOR_CLASS,
262+
ClientJwtValidator.class.getName());
263+
OAuthBearerValidatorCallbackHandler handler = new OAuthBearerValidatorCallbackHandler();
264+
assertThrowsWithMessage(ConfigException.class,
265+
() -> handler.configure(configs, OAUTHBEARER_MECHANISM, getJaasConfigEntries()),
266+
ClientJwtValidator.class.getName());
267+
}
268+
259269
@Test
260270
public void testConfigureAcceptsCustomValidatorClass() {
261271
// A custom (non-default) validator class must be accepted; the startup check only applies
Collapse file

‎docs/getting-started/upgrade.md‎

Copy file name to clipboardExpand all lines: docs/getting-started/upgrade.md
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type: docs
3232

3333
### Notable changes in 4.5.0
3434

35+
* The broker-side OAUTHBEARER JWT validator now fails at startup when `sasl.oauthbearer.jwt.validator.class` is set to `org.apache.kafka.common.security.oauthbearer.ClientJwtValidator`, because that validator does not verify JWT signatures. Use `org.apache.kafka.common.security.oauthbearer.BrokerJwtValidator` or another signature-verifying validator on brokers instead.
3536
* `ssl.principal.mapping.rules` now builds the principal name from the same full match that is used to check the rule. Previously, a rule that is not anchored with both `^` and `$`, or that uses alternation, could build the name from a shorter match or apply the replacement twice. For example, `RULE:CN=(.*?),OU=(.*?)/$1/` mapped `CN=bob,OU=eng` to `bobeng` instead of `bob`. Rules anchored with `^` and `$`, such as the documented examples, are not affected. If you use such rules, check that ACLs, quotas and `super.users` refer to the corrected principal names before upgrading.
3637
* The `ConsumerRebalanceListener` interface and the `Consumer#subscribe` overloads that accept it are deprecated and will be removed in Kafka 5.0. Implement `RebalanceListener` instead, whose callbacks receive a `RebalanceConsumer` exposing the operations that are safe to call during a rebalance, and register it with `Consumer#setRebalanceListener` before subscribing. For further details, please refer to [KIP-1306](https://cwiki.apache.org/confluence/spaces/KAFKA/pages/406623733/KIP-1306+Extend+ConsumerRebalanceListener+with+Consumer-Aware+methods).
3738

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.