Commit 4ebf018
authored
KAFKA-18608: Add Support for OAuth Client Assertion to client_credentials Grant Type (#21483)
## What
Implements
[KIP-1258](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1258%3A+Add+Support+for+OAuth+Client+Assertion+to+client_credentials+Grant+Type):
Add support for OAuth 2.0 client assertion authentication (RFC 7523§2.2)
as a more secure alternative to client secrets.
## Key Changes
### Core Implementation
- **New**: `ClientAssertionRequestFormatter` - Formats HTTP requests
with client assertion parameters
- **Enhanced**: `ClientCredentialsRequestFormatterFactory` - Three-tier
fallback mechanism with logging
- **Renamed**: `ClientCredentialsRequestFormatter`
→`ClientSecretRequestFormatter` (internal class)
### Three-Tier Fallback
1. File-based assertion (`sasl.oauthbearer.assertion.file`)
2. Dynamically-generated assertion
(`sasl.oauthbearer.assertion.claim.iss` + private key)
3. Client secret (backward compatible fallback)
### Infrastructure
- Reuses KIP-1139 assertion creation/signing/caching
- No new configuration properties required
- Supports RS256 and ES256 algorithms
- Automatic private key file reloading
## Testing
- ✅ RFC 7523 compliance verified
- ✅ Backward compatibility validated
## Compatibility
- ✅ 100% backward compatible
- ✅ No public API changes
- ✅ No broker changes required
- ✅ Client-side only implementation
## Configuration Example
```properties
# Client Assertion (Recommended)
sasl.oauthbearer.token.endpoint.url=https://idp.com/oauth/token
sasl.oauthbearer.assertion.private.key.file=/path/to/key.pem
sasl.oauthbearer.assertion.algorithm=RS256
sasl.oauthbearer.assertion.claim.iss=kafka-client
sasl.oauthbearer.assertion.claim.sub=service-account
sasl.oauthbearer.assertion.claim.aud=https://idp.com
# Client Secret (Still Works)
sasl.oauthbearer.client.credentials.client.id=my-client
sasl.oauthbearer.client.credentials.client.secret=my-secret
```
## References
- **JIRA**:
[KAFKA-18608](https://issues.apache.org/jira/browse/KAFKA-18608)
- **KIP**:
[KIP-1258](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1258)
- **RFC 7521**: [Assertion Framework for
OAuth2.0](https://datatracker.ietf.org/doc/html/rfc7521)
- **RFC 7523**: [JWT Profile for OAuth 2.0 Client
Authentication](https://datatracker.ietf.org/doc/html/rfc7523)
- **Related**: [KIP-1139 (jwt-bearer
grant)](https://cwiki.apache.org/confluence/display/KAFKA/KIP-1139)
Reviewers: Manikumar Reddy <manikumar.reddy@gmail.com>, Kirk True <kirk@kirktrue.pro>1 parent 5729bb6 commit 4ebf018
File tree
26 files changed
+3347
-209
lines changed- checkstyle
- clients/src
- main/java/org/apache/kafka/common/security/oauthbearer
- internals/secured
- assertion
- test/java/org/apache/kafka/common/security/oauthbearer
- internals/secured
- assertion
- core/src/test/scala/integration/kafka/api
- gradle
26 files changed
+3347
-209
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1900 | 1900 | | |
1901 | 1901 | | |
1902 | 1902 | | |
| 1903 | + | |
| 1904 | + | |
1903 | 1905 | | |
1904 | 1906 | | |
1905 | 1907 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
140 | 143 | | |
141 | 144 | | |
142 | 145 | | |
| |||
Lines changed: 14 additions & 132 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 20 | + | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
| 25 | + | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
36 | | - | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | 37 | | |
51 | 38 | | |
52 | 39 | | |
| |||
109 | 96 | | |
110 | 97 | | |
111 | 98 | | |
| 99 | + | |
112 | 100 | | |
113 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
114 | 110 | | |
115 | 111 | | |
116 | 112 | | |
117 | 113 | | |
118 | 114 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
| 115 | + | |
132 | 116 | | |
| 117 | + | |
| 118 | + | |
133 | 119 | | |
134 | 120 | | |
135 | 121 | | |
| |||
145 | 131 | | |
146 | 132 | | |
147 | 133 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | 134 | | |
Lines changed: 4 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
47 | | - | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
Lines changed: 11 additions & 39 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 24 | + | |
| 25 | + | |
29 | 26 | | |
30 | 27 | | |
31 | 28 | | |
32 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
37 | | - | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 38 | | |
46 | | - | |
47 | 39 | | |
48 | 40 | | |
49 | 41 | | |
| |||
116 | 108 | | |
117 | 109 | | |
118 | 110 | | |
| 111 | + | |
| 112 | + | |
119 | 113 | | |
120 | 114 | | |
121 | | - | |
122 | | - | |
| 115 | + | |
123 | 116 | | |
124 | 117 | | |
125 | 118 | | |
| |||
135 | 128 | | |
136 | 129 | | |
137 | 130 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 131 | + | |
160 | 132 | | |
161 | 133 | | |
162 | 134 | | |
163 | 135 | | |
| 136 | + | |
164 | 137 | | |
165 | 138 | | |
166 | 139 | | |
| |||
174 | 147 | | |
175 | 148 | | |
176 | 149 | | |
177 | | - | |
178 | | - | |
| 150 | + | |
179 | 151 | | |
180 | 152 | | |
181 | 153 | | |
0 commit comments