This project turns possible to register clients in Keycloak in an
Here, Keycloak is managed by Docker.
The Admin CLI is invoked inside the created container by
matrix-functions.sh to create realms, and manage the
Let’s see how this works by following the next steps.
- 1. Prerequisites
- 2. Download the project and change the current directory
- 3. Turn the Matrix functions available in your shell
- 4. Start the Matrix
- 5. Run the sample apps
A macOS or Linux operational system.
|This project was only tested on macOS 10.15.6 and Linux Ubuntu 20.04.1.|
2. Download the project and change the current directory
$ git clone https://github.com/paulojeronimo/keyckoak-matrix $ cd `basedir $_`
3. Turn the Matrix functions available in your shell
$ source functions.sh
The line above will turn available the
matrix-*functions in your shell. You can see what are these functions by typing the following command:
$ set | grep ^matrix- | sort
It will also put a line inside your
~./bash_profile(depend on with OS you are using) with will automatically load this script for you. You can check this by running the following command:
$ [[ $OSTYPE =~ darwin ]] && profile=~/.bash_profile || profile=~/.bashrc $ grep functions $profile
4. Start the Matrix
You can now open http://localhost:8080/auth/admin/ and log in using the credentials configured in
config.sh. The credentails are configured by two shell variables:
config.shis a copy of the file
config.sample.shwith your own configurations (and it is ignored by Git).
matrix-createfunction will start a Keycloak docker container. This container will be an instance of the image configured in the file
config.sh. The docker image (and the created container) can be checked by the following commands:
$ docker images | grep keycloak $ docker container ls | grep keycloak
You can also use the
matrix-statusfunction to discover if Keycloak is started.
Wait until Keycloak is started! You can check the logs by using the command
docker logs -f keycloakuntil you see a line like this:
00:57:26,386 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
5. Run the sample apps
5.1.1. Starting and configuring Keycloak
$ matrix-project-add samples/plain-js/
matrix-project-addfunction will add the specified project.
A project is a directory containing a file called
matrix-functions.sh. The function with suffix
-project-add(inside this file) will be called automatically.
5.1.2. Starting the webapp
$ samples/plain-js/serve.sh &
This will start a local server listening on port 3000 and serving the directory plain-js/webapp which contains an static HTML file called
$ open http://localhost:3000
If you are using Linux, type
xdg-openin place of
openin the command above.
You will need to register an new user. After that you will be automatically redirected to the app, as a logged user.
5.4. Spring Boot