Skip to content

Commit 56bd109

Browse files
authored
fix #103 (#107)
* fix #103 * changelog
1 parent b7dfab3 commit 56bd109

File tree

6 files changed

+20
-11
lines changed

6 files changed

+20
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
## [0.11] - SNAPSHOT
88
- Renamed packages to `io.conduktor`
99
- Prepared release to sonatype and Maven
10+
- Renamed `ksm.extract` config to `ksm.extract.enable` (breaking change)
1011

1112
## [0.10.2] - 12/05/2021
1213
- Removed gRPC

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Overall we use the [lightbend config](https://github.com/lightbend/config) libra
152152
The [default configurations](src/main/resources/application.conf) can be overwritten using the following environment variables:
153153

154154
- `KSM_READONLY=false`: enables KSM to synchronize from an External ACL source. The default value is `true`, which prevents KSM from altering ACLs in Zookeeper
155-
- `KSM_EXTRACT=true`: enable extract mode (get all the ACLs from Kafka formatted as a CSV or YAML)
155+
- `KSM_EXTRACT_ENABLE=true`: enable extract mode (get all the ACLs from Kafka formatted as a CSV or YAML)
156156
- `KSM_EXTRACT_FORMAT=csv`: selects which format to extract the ACLs with (defaults to csv, supports also yaml)
157157
- `KSM_REFRESH_FREQUENCY_MS=10000`: how often to check for changes in ACLs in Kafka and in the Source. 10000 ms by default. If it's set to `0` or negative value, for example `-1`, then KMS executes ACL synchronization just once and exits
158158
- `KSM_NUM_FAILED_REFRESHES_BEFORE_NOTIFICATION=1`: how many times that the refresh of a Source needs to fail (e.g. HTTP timeouts) before a notification is sent. Any value less than or equal to `1` here will notify on every failure to refresh.
@@ -215,7 +215,7 @@ Alternatively, you can get the automatically built Docker images on [Docker Hub]
215215
Then apply to the docker run using for example (in EXTRACT mode):
216216

217217
```
218-
docker run -it -e AUTHORIZER_ZOOKEEPER_CONNECT="zookeeper-url:2181" -e KSM_EXTRACT=true \
218+
docker run -it -e AUTHORIZER_ZOOKEEPER_CONNECT="zookeeper-url:2181" -e KSM_EXTRACT_ENABLE=true \
219219
conduktor/kafka-security-manager:latest
220220
```
221221

@@ -234,7 +234,7 @@ For full usage of the docker-compose file see [kafka-security-manager](https://g
234234

235235
## Extracting ACLs
236236

237-
You can initially extract all your existing ACL in Kafka by running the program with the config `extract=true` or `export KSM_EXTRACT=true`
237+
You can initially extract all your existing ACL in Kafka by running the program with the config `ksm.extract.enable=true` or `export KSM_EXTRACT_ENABLE=true`
238238

239239
Output should look like:
240240
```
@@ -254,7 +254,7 @@ You can then use place this CSV anywhere and use it as your source of truth.
254254

255255
KSM Version | Kafka Version | Notes
256256
--- | --- | ---
257-
0.11.0 | 2.5.x | renamed packages to `io.conduktor`
257+
0.11.0 | 2.5.x | renamed packages to `io.conduktor`. Breaking change on extract config name
258258
0.10.0 | 2.5.x | YAML support<br>Add configurable num failed refreshes before notification
259259
0.9 | 2.5.x | Upgrade to Kafka 2.5.x
260260
0.8 | 2.3.1 | Add a "run once" mode

src/main/resources/application.conf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ ksm {
33
debug = false
44
debug = ${?KSM_DEBUG}
55

6-
extract = false
7-
extract = ${?KSM_EXTRACT}
8-
9-
extract.format = csv
10-
extract.format = ${?KSM_EXTRACT_FORMAT}
6+
extract {
7+
enable = false
8+
enable = ${?KSM_EXTRACT_ENABLE}
9+
format = csv
10+
format = ${?KSM_EXTRACT_FORMAT}
11+
}
1112

1213
num.failed.refreshes.before.notification = 1
1314
num.failed.refreshes.before.notification = ${?KSM_NUM_FAILED_REFRESHES_BEFORE_NOTIFICATION}

src/main/scala/io/conduktor/ksm/AppConfig.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class AppConfig(config: Config) {
5959
private val ksmConfig = config.getConfig("ksm")
6060
val refreshFrequencyMs: Int = ksmConfig.getInt("refresh.frequency.ms")
6161
val numFailedRefreshesBeforeNotification: Int = ksmConfig.getInt("num.failed.refreshes.before.notification")
62-
val extract: Boolean = ksmConfig.getBoolean("extract")
62+
val extract: Boolean = ksmConfig.getBoolean("extract.enable")
6363
val extractFormat: String = ksmConfig.getString("extract.format")
6464
val readOnly: Boolean = ksmConfig.getBoolean("readonly")
6565
}

src/main/scala/io/conduktor/ksm/KafkaSecurityManager.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ object KafkaSecurityManager extends App {
1919
val parserRegistry: AclParserRegistry = new AclParserRegistry(appConfig)
2020
val scheduler: ScheduledExecutorService = Executors.newScheduledThreadPool(1)
2121

22+
// For backward compatibility, see https://github.com/conduktor/kafka-security-manager/issues/103
23+
val oldExtractConfig = sys.env.get("KSM_EXTRACT")
24+
if (oldExtractConfig.isDefined) {
25+
log.error("The KSM_EXTRACT environment variable has been renamed to KSM_EXTRACT_ENABLE. Please fix your scripts")
26+
sys.exit(1)
27+
}
28+
2229
if (appConfig.KSM.extract) {
2330
val parser = parserRegistry.getParser(appConfig.KSM.extractFormat)
2431
new ExtractAcl(appConfig.Authorizer.authorizer, parser).extract()

src/main/scala/io/conduktor/ksm/parser/csv/CsvAclParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class CsvAclParser(delimiterInput: Char = ',') extends AclParser {
5656
log.warn(
5757
s"""Since you upgraded to Kafka 2.0, your CSV needs to include an extra column '$PATTERN_TYPE_COL', after $RESOURCE_TYPE_COL and before $RESOURCE_NAME_COL.
5858
|The CSV header should be: KafkaPrincipal,ResourceType,PatternType,ResourceName,Operation,PermissionType,Host
59-
|For a quick fix, you can run the application with KSM_EXTRACT=true and replace your current CSV with the output of the command
59+
|For a quick fix, you can run the application with KSM_EXTRACT_ENABLE=true and replace your current CSV with the output of the command
6060
|For backwards compatibility, the default value $PATTERN_TYPE_COL=LITERAL has been chosen""".stripMargin
6161
)
6262
// Default

0 commit comments

Comments
 (0)