Skip to content

Commit 007187a

Browse files
Merge pull request #26 from superstreamlabs/master
release
2 parents f3a22b2 + 2c9733f commit 007187a

File tree

6 files changed

+67
-55
lines changed

6 files changed

+67
-55
lines changed

config-examples/README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,19 @@ npx superstream-kafka-analyzer
448448
- **Port**: 9092
449449
- **Best for**: Enterprise Confluent deployments
450450

451-
### 7. **Aiven Kafka** (`config.example.aiven-kafka.json`)
452-
- **Use case**: Aiven managed Kafka service
453-
- **Authentication**: SASL_SSL with PLAIN mechanism
451+
### 7. **Aiven Kafka - SASL Authentication** (`config.example.aiven-kafka-sasl.json`)
452+
- **Use case**: Aiven managed Kafka service with SASL authentication
453+
- **Authentication**: SASL_SSL with SCRAM-SHA-256 mechanism
454+
- **Port**: Custom (e.g., 12345)
455+
- **Best for**: Cloud-managed Kafka with Aiven using username/password authentication
456+
- **Requirements**: Username, password, and CA certificate
457+
458+
### 7a. **Aiven Kafka - SSL with Certificates** (`config.example.aiven-kafka-ssl.json`)
459+
- **Use case**: Aiven managed Kafka service with SSL client certificates
460+
- **Authentication**: SSL with client certificates
454461
- **Port**: Custom (e.g., 12345)
455-
- **Best for**: Cloud-managed Kafka with Aiven
462+
- **Best for**: Cloud-managed Kafka with Aiven using certificate-based authentication
463+
- **Requirements**: CA certificate, client certificate, and private key
456464

457465
### 8. **Redpanda** (`config.example.redpanda.json`)
458466
- **Use case**: Redpanda streaming platform
@@ -687,8 +695,13 @@ npx superstream-kafka-analyzer
687695

688696
### Aiven Kafka
689697
- Uses custom port numbers (not 9092)
690-
- Default username is `avnadmin`
698+
- Supports two authentication methods:
699+
- **SASL_SSL**: Username/password with SCRAM-SHA-256 (recommended)
700+
- **SSL**: Client certificates with CA verification
701+
- Default username is `avnadmin` for SASL authentication
691702
- Get connection details from Aiven console
703+
- CA certificate is required for SASL mode
704+
- For SSL mode, all three certificates (CA, client cert, private key) are required
692705

693706
### Redpanda
694707
- Compatible with Kafka protocol
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"kafka": {
3+
"brokers": ["kafka-xxxxx-aiven-kafka.aivencloud.com:12345"],
4+
"clientId": "superstream-analyzer",
5+
"vendor": "aiven",
6+
"useSasl": true,
7+
"sasl": {
8+
"mechanism": "scram-sha-256",
9+
"username": "avnadmin",
10+
"password": "*********"
11+
},
12+
"ssl": {
13+
"ca": "./certs/ca.pem"
14+
}
15+
},
16+
"file": {
17+
"outputDir": "./kafka-analysis",
18+
"formats": ["json", "csv", "html", "txt"],
19+
"includeMetadata": true
20+
},
21+
"email": "[email protected]"
22+
}

config-examples/config.example.aiven-kafka.json renamed to config-examples/config.example.aiven-kafka-ssl.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"vendor": "aiven",
66
"useSasl": false,
77
"ssl": {
8-
"ca": "path/to/ca.pem",
9-
"cert": "path/to/service.cert",
10-
"key": "path/to/service.key"
8+
"ca": "./certs/ca.pem",
9+
"cert": "./certs/service.cert",
10+
"key": "./certs/service.key"
1111
}
1212
},
1313
"file": {
@@ -16,4 +16,4 @@
1616
"includeMetadata": true
1717
},
1818
"email": "[email protected]"
19-
}
19+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "superstream-kafka-analyzer",
3-
"version": "1.0.17",
3+
"version": "1.0.18",
44
"description": "Interactive utility to analyze Kafka clusters health and configuration",
55
"main": "src/cli.js",
66
"bin": {

src/cli.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ class CLI {
188188
brokerMessage = 'AWS MSK broker URLs (comma-separated):';
189189
brokerDefault = 'b-1.your-cluster.region.amazonaws.com:9092';
190190
} else if (vendorAnswer.vendor === 'aiven') {
191-
brokerMessage = 'Aiven broker URLs (comma-separated):';
192-
brokerDefault = 'kafka-xxxxx.aivencloud.com:12345';
191+
brokerMessage = 'kafka-xxxxx.aivencloud.com:12345';
192+
brokerDefault = 'superstream-test-superstream-3591.k.aivencloud.com:18848';
193193
}
194194

195195
const kafkaAnswers = await inquirer.prompt([
@@ -328,13 +328,13 @@ class CLI {
328328
type: 'input',
329329
name: 'certPath',
330330
message: 'Client Certificate path (optional, eg. "./certs/service.cert"):',
331-
default: './certs/service.cert',
331+
default: '',
332332
},
333333
{
334334
type: 'input',
335335
name: 'keyPath',
336336
message: 'Client Private Key path (optional, eg. "./certs/service.key"):',
337-
default: './certs/service.key',
337+
default: '',
338338
}
339339
]);
340340

src/kafka-client.js

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ class KafkaClient {
3939
// If SSL keys are provided, disable SASL
4040
if (this.config.ssl && (this.config.ssl.ca || this.config.ssl.cert || this.config.ssl.key)) {
4141
this.config.useSasl = false;
42-
}
42+
}
43+
44+
if (this.config.vendor === 'aiven' && this.config.ssl.ca && !this.config.ssl.cert && !this.config.ssl.key) {
45+
this.config.useSasl = true;
46+
}
4347

4448
// Handle authentication based on vendor and configuration
4549
if (this.config.useSasl && this.config.sasl) {
@@ -180,52 +184,25 @@ class KafkaClient {
180184
return true;
181185

182186
case 'aiven':
183-
// Aiven uses SASL_SSL with SCRAM-SHA-256 or OAuth
184-
console.log('🔐 Aiven detected - configuring SSL with certificates...');
185-
if (this.config.ssl && (this.config.ssl.ca || this.config.ssl.cert || this.config.ssl.key)) {
186-
kafkaConfig.ssl = await this.buildSslConfig();
187-
}
187+
// Aiven supports both SSL with certificates and SASL_SSL with username/password
188+
const hasSaslCredentials = this.config.sasl && this.config.sasl.username && this.config.sasl.password;
189+
const hasSslCertificates = this.config.ssl && (this.config.ssl.cert || this.config.ssl.key);
188190

189-
if (mechanism === 'oauthbearer' && useOIDC) {
190-
const oidcProvider = await createOIDCProvider('oidc', {
191-
...this.config.sasl,
192-
discoveryUrl: this.config.sasl.discoveryUrl,
193-
clientId: this.config.sasl.clientId,
194-
clientSecret: this.config.sasl.clientSecret,
195-
tokenHost: this.config.sasl.host || this.config.sasl.tokenHost,
196-
tokenPath: this.config.sasl.path || this.config.sasl.tokenPath,
197-
scope: this.config.sasl.scope,
198-
audience: this.config.sasl.audience,
199-
validateToken: this.config.sasl.validateToken
200-
});
201-
202-
kafkaConfig.sasl = {
203-
mechanism: 'oauthbearer',
204-
oauthBearerProvider: async () => {
205-
return await oidcProvider.getToken();
206-
}
207-
};
208-
} else if (mechanism === 'oauthbearer') {
209-
// Legacy OAuth support
210-
const oauthProvider = createOAuthProvider('generic', {
211-
clientId: this.config.sasl.clientId,
212-
clientSecret: this.config.sasl.clientSecret,
213-
tokenHost: this.config.sasl.host || this.config.sasl.tokenHost,
214-
tokenPath: this.config.sasl.path || this.config.sasl.tokenPath
215-
});
216-
217-
kafkaConfig.sasl = {
218-
mechanism: 'oauthbearer',
219-
oauthBearerProvider: async () => {
220-
return await oauthProvider.getToken();
221-
}
222-
};
223-
} else {
191+
if (hasSaslCredentials) {
192+
// SASL_SSL mode with username/password
193+
console.log('🔐 Aiven detected - configuring SASL_SSL with username/password...');
194+
kafkaConfig.ssl = await this.buildSslConfig();
224195
kafkaConfig.sasl = {
225196
mechanism: 'scram-sha-256', // Aiven typically uses SCRAM-SHA-256
226197
username: this.config.sasl.username,
227198
password: this.config.sasl.password
228199
};
200+
} else if (hasSslCertificates) {
201+
// SSL mode with client certificates
202+
console.log('🔐 Aiven detected - configuring SSL with client certificates...');
203+
kafkaConfig.ssl = await this.buildSslConfig();
204+
} else {
205+
throw new Error('Aiven configuration requires either SASL credentials (username/password) or SSL certificates (cert/key)');
229206
}
230207
break;
231208

0 commit comments

Comments
 (0)