-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix KeycloakRBACAuthorizer to work with
StandardAuthorizer
in KRAFT…
… mode (#188) * Bump kafka-clients version to 3.4.0 Signed-off-by: Marko Strukelj <[email protected]> * Update testsuite/kafka image version Signed-off-by: Marko Strukelj <[email protected]> * Fix KeycloakRBACAuthorizer to work with `StandardAuthorizer` when in KRAFT mode Signed-off-by: Marko Strukelj <[email protected]> * Introduce a new authorizer class KeycloakAuthorizer + Add authorization tests for Kraft mode Signed-off-by: Marko Strukelj <[email protected]> * Documentation and code cleanup Signed-off-by: Marko Strukelj <[email protected]> * More refactoring, code fixes and tests Signed-off-by: Marko Strukelj <[email protected]> * Added more test and examples + fixed pools shutdown Signed-off-by: Marko Strukelj <[email protected]> * Update README.md Signed-off-by: Marko Strukelj <[email protected]> * Javadoc Signed-off-by: Marko Strukelj <[email protected]> * Apply suggestions from code review Co-authored-by: Tom Bentley <[email protected]> Co-authored-by: Jakub Scholz <[email protected]> Signed-off-by: Marko Strukelj <[email protected]> * Code comments, logger usage and code readability Signed-off-by: Marko Strukelj <[email protected]> * More fixes and explanations Signed-off-by: Marko Strukelj <[email protected]> * More javadoc and threading logic explanations Signed-off-by: Marko Strukelj <[email protected]> * Fix JVM specific test failure due to different JVM gc() dynamics Signed-off-by: Marko Strukelj <[email protected]> * Fix Spring example Signed-off-by: Marko Strukelj <[email protected]> * Fix Spring example Signed-off-by: Marko Strukelj <[email protected]> * Fix Spring example (debug Travis issue) Signed-off-by: Marko Strukelj <[email protected]> * Fix Spring example (debug Travis issue) Signed-off-by: Marko Strukelj <[email protected]> * Fix Spring example (debug Travis issue) Signed-off-by: Marko Strukelj <[email protected]> * Increase containers startup timeout to accommodate Travis Signed-off-by: Marko Strukelj <[email protected]> * Mark KeycloakRBACAuthorizer deprecated, log warning when configured as authorizer Signed-off-by: Marko Strukelj <[email protected]> --------- Signed-off-by: Marko Strukelj <[email protected]> Co-authored-by: Tom Bentley <[email protected]> Co-authored-by: Jakub Scholz <[email protected]>
- Loading branch information
1 parent
3f20677
commit 2cf1d5a
Showing
86 changed files
with
5,214 additions
and
1,557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
examples/docker/kafka-oauth-strimzi/compose-authz-kraft.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
version: '3.5' | ||
|
||
services: | ||
|
||
#################################### KAFKA BROKER #################################### | ||
kafka: | ||
image: strimzi/example-kafka | ||
build: kafka-oauth-strimzi/kafka/target | ||
container_name: kafka | ||
ports: | ||
- 9091:9091 | ||
- 9092:9092 | ||
|
||
# javaagent debug port | ||
#- 5006:5006 | ||
command: | ||
- /bin/bash | ||
- -c | ||
- cd /opt/kafka && ./start.sh --kraft | ||
|
||
environment: | ||
|
||
# Java Debug | ||
#KAFKA_DEBUG: y | ||
#DEBUG_SUSPEND_FLAG: y | ||
#JAVA_DEBUG_PORT: 5006 | ||
|
||
# | ||
# KAFKA Configuration | ||
# | ||
LOG_DIR: /home/kafka/logs | ||
KAFKA_PROCESS_ROLES: "broker,controller" | ||
KAFKA_NODE_ID: "1" | ||
KAFKA_CONTROLLER_QUORUM_VOTERS: "1@kafka:9091" | ||
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER | ||
KAFKA_SASL_MECHANISM_CONTROLLER_PROTOCOL: PLAIN | ||
|
||
KAFKA_LISTENERS: "CONTROLLER://kafka:9091,CLIENT://kafka:9092" | ||
KAFKA_ADVERTISED_LISTENERS: "CLIENT://kafka:9092" | ||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:SASL_PLAINTEXT,CLIENT:SASL_PLAINTEXT" | ||
|
||
KAFKA_SASL_ENABLED_MECHANISMS: OAUTHBEARER | ||
KAFKA_INTER_BROKER_LISTENER_NAME: CLIENT | ||
KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: OAUTHBEARER | ||
|
||
KAFKA_PRINCIPAL_BUILDER_CLASS: io.strimzi.kafka.oauth.server.OAuthKafkaPrincipalBuilder | ||
|
||
KAFKA_LISTENER_NAME_CONTROLLER_SASL_ENABLED_MECHANISMS: PLAIN | ||
KAFKA_LISTENER_NAME_CONTROLLER_PLAIN_SASL_JAAS_CONFIG: "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"admin\" password=\"admin-password\" user_admin=\"admin-password\" user_bobby=\"bobby-secret\" ;" | ||
|
||
KAFKA_LISTENER_NAME_CLIENT_SASL_ENABLED_MECHANISMS: OAUTHBEARER | ||
KAFKA_LISTENER_NAME_CLIENT_OAUTHBEARER_SASL_JAAS_CONFIG: "org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required;" | ||
KAFKA_LISTENER_NAME_CLIENT_OAUTHBEARER_SASL_LOGIN_CALLBACK_HANDLER_CLASS: io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler | ||
KAFKA_LISTENER_NAME_CLIENT_OAUTHBEARER_SASL_SERVER_CALLBACK_HANDLER_CLASS: io.strimzi.kafka.oauth.server.JaasServerOauthValidatorCallbackHandler | ||
|
||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | ||
|
||
KAFKA_LISTENER_NAME_CLIENT_OAUTHBEARER_CONNECTIONS_MAX_REAUTH_MS: 3600000 | ||
|
||
# | ||
# Strimzi OAuth Configuration | ||
# | ||
|
||
# Authentication config | ||
OAUTH_CLIENT_ID: "kafka" | ||
OAUTH_CLIENT_SECRET: "kafka-secret" | ||
OAUTH_TOKEN_ENDPOINT_URI: "http://${KEYCLOAK_HOST:-keycloak}:8080/auth/realms/${REALM:-kafka-authz}/protocol/openid-connect/token" | ||
|
||
# Validation config | ||
OAUTH_VALID_ISSUER_URI: "http://${KEYCLOAK_HOST:-keycloak}:8080/auth/realms/${REALM:-kafka-authz}" | ||
OAUTH_JWKS_ENDPOINT_URI: "http://${KEYCLOAK_HOST:-keycloak}:8080/auth/realms/${REALM:-kafka-authz}/protocol/openid-connect/certs" | ||
#OAUTH_INTROSPECTION_ENDPOINT_URI: "http://${KEYCLOAK_HOST:-keycloak}:8080/auth/realms/${REALM:-kafka-authz}/protocol/openid-connect/token/introspect" | ||
|
||
# username extraction from JWT token claim | ||
OAUTH_USERNAME_CLAIM: preferred_username | ||
|
||
# timeouts / refresh config | ||
OAUTH_JWKS_REFRESH_MIN_PAUSE_SECONDS: "5" | ||
OAUTH_CONNECT_TIMEOUT_SECONDS: "20" | ||
OAUTH_READ_TIMEOUT_SECONDS: "20" | ||
|
||
# Keycloak authorization | ||
KAFKA_AUTHORIZER_CLASS_NAME: io.strimzi.kafka.oauth.server.authorizer.KeycloakAuthorizer | ||
|
||
KAFKA_STRIMZI_AUTHORIZATION_KAFKA_CLUSTER_NAME: my-cluster | ||
KAFKA_STRIMZI_AUTHORIZATION_DELEGATE_TO_KAFKA_ACL: "true" | ||
KAFKA_STRIMZI_AUTHORIZATION_GRANTS_REFRESH_POOL_SIZE: "4" | ||
KAFKA_STRIMZI_AUTHORIZATION_GRANTS_REFRESH_PERIOD_SECONDS: "60" | ||
|
||
KAFKA_SUPER_USERS: "User:admin;User:service-account-kafka-broker" | ||
|
||
# For start.sh script to know where the keycloak is listening | ||
KEYCLOAK_HOST: ${KEYCLOAK_HOST:-keycloak} | ||
REALM: ${REALM:-kafka-authz} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
version: '3.5' | ||
|
||
services: | ||
|
||
#################################### KAFKA BROKER #################################### | ||
kafka: | ||
image: strimzi/example-kafka | ||
build: kafka-oauth-strimzi/kafka/target | ||
container_name: kafka | ||
ports: | ||
- 9091:9091 | ||
- 9092:9092 | ||
|
||
# javaagent debug port | ||
#- 5005:5005 | ||
command: | ||
- /bin/bash | ||
- -c | ||
- cd /opt/kafka && ./start.sh --kraft | ||
|
||
environment: | ||
|
||
# Java Debug | ||
#KAFKA_DEBUG: y | ||
#DEBUG_SUSPEND_FLAG: y | ||
#JAVA_DEBUG_PORT: 5005 | ||
|
||
# | ||
# KAFKA Configuration | ||
# | ||
LOG_DIR: /home/kafka/logs | ||
KAFKA_PROCESS_ROLES: "broker,controller" | ||
KAFKA_NODE_ID: "1" | ||
KAFKA_CONTROLLER_QUORUM_VOTERS: "1@kafka:9091" | ||
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER | ||
KAFKA_SASL_MECHANISM_CONTROLLER_PROTOCOL: PLAIN | ||
|
||
KAFKA_LISTENERS: "CONTROLLER://kafka:9091,CLIENT://kafka:9092" | ||
KAFKA_ADVERTISED_LISTENERS: "CLIENT://kafka:9092" | ||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: "CONTROLLER:SASL_PLAINTEXT,CLIENT:SASL_PLAINTEXT" | ||
|
||
KAFKA_INTER_BROKER_LISTENER_NAME: CLIENT | ||
KAFKA_SASL_MECHANISM_INTER_BROKER_PROTOCOL: OAUTHBEARER | ||
|
||
KAFKA_PRINCIPAL_BUILDER_CLASS: "io.strimzi.kafka.oauth.server.OAuthKafkaPrincipalBuilder" | ||
|
||
KAFKA_LISTENER_NAME_CONTROLLER_SASL_ENABLED_MECHANISMS: PLAIN | ||
KAFKA_LISTENER_NAME_CONTROLLER_PLAIN_SASL_JAAS_CONFIG: "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"admin\" password=\"admin-password\" user_admin=\"admin-password\" user_bobby=\"bobby-secret\" ;" | ||
|
||
KAFKA_LISTENER_NAME_CLIENT_SASL_ENABLED_MECHANISMS: OAUTHBEARER | ||
KAFKA_LISTENER_NAME_CLIENT_OAUTHBEARER_SASL_JAAS_CONFIG: "org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required;" | ||
KAFKA_LISTENER_NAME_CLIENT_OAUTHBEARER_SASL_LOGIN_CALLBACK_HANDLER_CLASS: io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler | ||
KAFKA_LISTENER_NAME_CLIENT_OAUTHBEARER_SASL_SERVER_CALLBACK_HANDLER_CLASS: io.strimzi.kafka.oauth.server.JaasServerOauthValidatorCallbackHandler | ||
|
||
KAFKA_SUPER_USERS: "User:admin,User:service-account-kafka-broker" | ||
|
||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | ||
|
||
|
||
# | ||
# Strimzi OAuth Configuration | ||
# | ||
|
||
# Authentication config | ||
OAUTH_CLIENT_ID: "kafka-broker" | ||
OAUTH_CLIENT_SECRET: "kafka-broker-secret" | ||
OAUTH_TOKEN_ENDPOINT_URI: "http://${KEYCLOAK_HOST:-keycloak}:8080/auth/realms/${REALM:-demo}/protocol/openid-connect/token" | ||
|
||
# Validation config | ||
OAUTH_VALID_ISSUER_URI: "http://${KEYCLOAK_HOST:-keycloak}:8080/auth/realms/${REALM:-demo}" | ||
OAUTH_JWKS_ENDPOINT_URI: "http://${KEYCLOAK_HOST:-keycloak}:8080/auth/realms/${REALM:-demo}/protocol/openid-connect/certs" | ||
#OAUTH_INTROSPECTION_ENDPOINT_URI: "http://${KEYCLOAK_HOST:-keycloak}:8080/auth/realms/${REALM:-demo}/protocol/openid-connect/token/introspect" | ||
|
||
|
||
# username extraction from JWT token claim | ||
OAUTH_USERNAME_CLAIM: preferred_username | ||
OAUTH_CONNECT_TIMEOUT_SECONDS: "20" | ||
|
||
# For start.sh script to know where the keycloak is listening | ||
KEYCLOAK_HOST: ${KEYCLOAK_HOST:-keycloak} | ||
REALM: ${REALM:-demo} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -x | ||
|
||
docker rm -f spring | ||
docker run -d --name spring strimzi/example-spring | ||
for i in {1..10} | ||
do | ||
sleep 1 | ||
RESULT=$(docker logs spring | grep "Started SimpleAuthorizationServerApplication") | ||
if [ "$RESULT" != "" ]; then | ||
docker rm -f spring | ||
exit 0 | ||
fi | ||
done | ||
|
||
echo "Failed to start Spring example" | ||
docker logs spring | ||
exit 1 |
Oops, something went wrong.