This repository is intended to facilitate the creation of a dockerized development environment of Keycloak and Kong using Docker Swarm. It contains a custom kong image with the kong-oidc plugin already installed and a docker-compose file with all the necessary services. DO NOT use in production.
docker build -t kong:1.4.0-alpine-oidc kong/
docker stack deploy -c docker-compose.yml kk-stk
Give the stack a few minutes to initialize. You can check the status of each service running the command docker service ls
.
NOTE: The service kong-migration
will run once to initialize the database and will NOT be restarted after that.
- Go to http://localhost:1337 and create your user account in Konga.
- Login with your newly created user account.
- Add your Kong service to Konga using the Admin API port number.
- Name: Local
- Kong Admin URL: http://kong:8001
- In Konga go to
Services
and click the button+ ADD NEW SERVICE
. - Fill in the
Url
andPath
fields with the following information and then clickSUBMIT SERVICE
.- Name: mocking(Optional)
- Url: http://mockbin.org
- Path: /request
- Click your newly created service, go to
Routes
then+ ADD ROUTE
. - Add
/mock
in thePaths
field, hit theenter
key(on your keyboard) and clickSUBMIT ROUTE
. - You can access your newly created endpoint by typing http://localhost:8000/mock on your browser.
On your web browser go to http://localhost:8180, click on Administration Console
and login with the credentials specified in the docker-compose.yml
file.
- Go to
Clients
on the left menu and click the buttonCreate
on the top right corner. - Fill in the
Client ID
field withlocal-kong
and clickSave
. - On the
Settings
tab fill in the following fields then clickSave
:- Access Type: confidential
- Root URL: http://localhost:8000
- Valid Redirect URLs: /mock*
- Go to the
Credentials
tab and copy thesecret
since we are going to need it soon.
- Go to
Users
on the left menu and click the buttonAdd user
on the top right corner. - On the
Add user
screen set a username and make sure you turn on theEmail Verified
option then clickSave
. - Go to the
Credentials
tab and set a password for your newly created user. Make sure theTemporary
option is turned off.
- Go to
Services
on the left menu and click themocking
service you created on step 3.2.2. - Go to the
Routes
tab and select the route you created on step 3.2.4. - Go to the
Plugins
tab and click the+ ADD PLUGIN
button. - In the
Others
tab click theADD PLUGIN
button under theOidc
option. - Fill in the following fields then click the
ADD PLUGIN
button:- realm: master
- client id: local-kong
- discovey: http://HOST_IP:8180/auth/realms/master/.well-known/openid-configuration (Replace HOST_IP with your local IP address)
- secret: Paste the
secret
you copied on step 4.1.4. That's it! Now when you try to access your mocking endpoint (http://localhost:8000/mock) Kong should redirect you to authenticate with Keycloak.