We are now using Keycloak as our Identity and Access Management (IAM) solution.
These commands should be run with the working directory coursemology2/authentication
(the same directory this README file is in)
-
Make sure you have docker and also docker-compose installed.
-
Run the following command
docker build -t coursemology_auth .
-
Run the following command to initialize
.env
files over herecp env .env
-
Create an empty coursemology_keycloak database in postgresql by running the following command
psql -c "CREATE DATABASE coursemology_keycloak;" -d postgres
-
From a terminal, enter the following command to start Keycloak:
docker compose up
If the above does not work (happened sometimes), you can instead opt to run the following command:
docker-compose up
-
The authentication pages can be accessed via
http://localhost:8443/admin
The local setup requires the authentication provider container to connect to the postgres service running on the host machine. On Windows and Mac, this is already set up by Docker Desktop, which lets the container do this by accessing the host.docker.internal
hostname. On Linux devices, this can be set up by either:
-
installing Docker Desktop for Linux; or
-
changing the
KC_NETWORK_MODE
environment variable tohost
, and adding the following to the docker-compose service declaration:services: coursemology_auth: container_name: coursemology_authentication ... extra_hosts: - 'host.docker.internal:127.0.0.1'
To ensure the smoothness in signing-in to Coursemology, you must ensure that the configuration for KEYCLOAK_BE_CLIENT_SECRET
inside .env
matches with the settings inside Keycloak. To do so, you can simply do the following instructions:
- Sign-in to authentication pages by inputting the following credentials:
Username:
admin
(whatever defined in KEYCLOAK_ADMIN inside ./.env)Password:
password
(whatever defined in KEYCLOAK_ADMIN_PASSWORD inside ./.env)
-
Navigate to coursemology realm by choosing Coursemology in the top-left dropdown box, or simply access Coursemology realm
-
Navigate to Client, then click on the Client ID in which name is
coursemology-backend
-
Over there, navigate to Credentials and you will see the Client Secret. If whatever is defined there does not match with the Client Secret defined in your environment setup, simply copy-paste the client secret inside the page (you can possibly regenerate it if you want), then copy-paste it to
KEYCLOAK_BE_CLIENT_SECRET
inside../.env
-
Finally, your Keycloak setup for Coursemology is finished and you are safe to proceed to the next step inside the Coursemology setup guide.