Skip to content

Sources for "Unified authorization in microservices (HTTP and Kafka-based interactions)" meetup

License

Notifications You must be signed in to change notification settings

stn1slv/meetup-authorization

Repository files navigation

Demo case

The presentation from the meetup.

Demo case Demo case

Preparing

You have to add some entries to your /etc/hosts file:

127.0.0.1            keycloak
127.0.0.1            kafka

That's needed for host resolution because Kafka brokers and Kafka clients connecting to Keycloak have to use the same hostname to ensure the compatibility of generated access tokens. Also, when Kafka client connects to Kafka broker running inside docker image, the broker will redirect the client to kafka:9092.

Start infrastructure

Cleanup

docker rm keycloak kafka zookeeper

Startup

Go to docker directory of the repo:

cd docker

All the following docker-compose commands should be run from this directory.

Starting infra:

docker-compose -f compose.yml -f keycloak/compose.yml -f keycloak-import/compose.yml -f kafka-oauth-strimzi/compose-authz.yml up --build

Run and test

Console tools

⚠️ Before using Kafka console apps, you should add strimzi libs to your Kafka libs directory. To do this, clone strimzi-kafka-oauth repository and follow the steps on the link.

Produce

Service-A

kafka-console-producer.sh --broker-list kafka:9092 --topic a_messages --producer.config=service-a.properties

Service-C

kafka-console-producer.sh --broker-list kafka:9092 --topic a_messages --producer.config=service-c.properties
Consume

Service-B

kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic a_messages --from-beginning --consumer.config=service-b.properties --group a_consumer_group_1

Run demo apps

Service-A
cd service-a
mvn spring-boot:run
Service-B
cd service-b
mvn spring-boot:run
Service-C
cd service-c
go run main.go
Service-D
cd service-d
go run main.go

About

Sources for "Unified authorization in microservices (HTTP and Kafka-based interactions)" meetup

Topics

Resources

License

Stars

Watchers

Forks