Skip to content

Commit 9bd7a4e

Browse files
📝 Security documentation (#74)
1 parent c644712 commit 9bd7a4e

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

docs/tutorial/security.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Security
2+
3+
Py2K is built on top of the [confluent-kafka](https://github.com/confluentinc/confluent-kafka-python) python package which uses [librdkafka](https://github.com/edenhill/librdkafka) configuration for authentication.
4+
5+
## SSL Authentication Example
6+
7+
SSL authentication is built into the base Py2K wheels.
8+
9+
As an example, the below config and setup will work:
10+
11+
```Python
12+
{!../docs_src/security/security001.py!}
13+
```
14+
15+
## SASL_SSL Kerberos Authentication Example
16+
17+
<!-- prettier-ignore-start -->
18+
!!! info
19+
The Py2K installation install confluent-kafka for you, **however** the base confluent-kafka librdkafka linux wheel is not built with SASL Kerberos/GSSAPI support and if you required this you will need to install the wheels on your system first. For a guide, see [here](https://github.com/confluentinc/confluent-kafka-python#prerequisites)
20+
<!-- prettier-ignore-end -->
21+
22+
Once you've built from source you can use a similar base config to below:
23+
24+
```Python
25+
{!../docs_src/security/security002.py!}
26+
```

docs_src/security/security001.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from py2k.writer import KafkaWriter
2+
3+
cert_config = {
4+
'ssl.ca.location': '/path/to/ca.pem',
5+
'ssl.certificate.location': '/path/to/cert.pem',
6+
'ssl.key.location': '/path/to/ssl.key',
7+
}
8+
9+
topic = 'mytopic'
10+
schema_registry_config = {'url': 'https://schemaregistry.com', **cert_config}
11+
producer_config = {
12+
'bootstrap.servers': 'bootstrapservers.com',
13+
'security.protocol': 'ssl',
14+
**cert_config,
15+
}
16+
17+
writer = KafkaWriter(
18+
topic=topic,
19+
schema_registry_config=schema_registry_config,
20+
producer_config=producer_config,
21+
)

docs_src/security/security002.py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from py2k.writer import KafkaWriter
2+
3+
cert_config = {
4+
'ssl.ca.location': '/path/to/ca.pem',
5+
'ssl.certificate.location': '/path/to/cert.pem',
6+
'ssl.key.location': '/path/to/ssl.key',
7+
}
8+
9+
topic = 'mytopic'
10+
schema_registry_config = {'url': 'https://schemaregistry.com', **cert_config}
11+
producer_config = {
12+
'bootstrap.servers': 'bootstrapservers.com',
13+
'security.protocol': 'SASL_SSL',
14+
'sasl.kerberos.principal': 'principal@DOMAIN',
15+
'sasl.kerberos.keytab': '/path/to/principal.keytab',
16+
**cert_config,
17+
}
18+
19+
writer = KafkaWriter(
20+
topic=topic,
21+
schema_registry_config=schema_registry_config,
22+
producer_config=producer_config,
23+
)

mkdocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ nav:
3030
- Tutorial - User Guide:
3131
- Tutorial - User Guide - Intro: tutorial/index.md
3232
- First Steps: tutorial/first_steps.md
33+
- Security: tutorial/security.md
3334
- API Reference: reference.md
3435
- Motivation: motivation.md
3536
- Release Notes: release_notes.md

0 commit comments

Comments
 (0)