For this PR, I setup a new Keycloak realm for our project and created a new client (Application entry point) and 2 users (teacher-1 and student-1) with 2 different roles (demonstrator and student). Moreover, I added basic test endpoints to the backend to test the functionalities of the 'keycloak-connect' package that we are using. You can test the connection in various of ways:
You can check if keycloak is setup correctly by starting the project and going to any of the containers (docker exec -it <container_name> sh) and execute the following shell script: wget -O - --header 'Content-Type: application/x-www-form-urlencoded' --post-data "username=teacher-1&password=123&client_id=cap-app&client_secret=aQX4Vdbe7PhQTPCwRdeOwIdQzbpGkOdw&grant_type=password" "http://nginx/auth/realms/CAP/protocol/openid-connect/token". The previous script will give you an access_token if the connection was established. For now I typed the user credentials manually for testing.
You can start the whole project and wait until everything is fired up (Specially keycloak). Then open your terminal if you are on linux and type: wget -O - "localhost:5000/gettoken". The previous command will activate an api endpoint that will try to login to the client (cap-app) as "student-1". The request will return 200 which means that it was successful. To see the output and make sure it works, write the following command docker-compose -f docker-compose-local.yml logs -f backend. It will printout the backend logs and will keep watching the logs for changes (coz of the second -f flag).
I edited also the auth_db and imported the newest Keycloak database. The new database contains the stuff mentioned in the first sentence of this description.
For this PR, I setup a new Keycloak realm for our project and created a new client (Application entry point) and 2 users (teacher-1 and student-1) with 2 different roles (demonstrator and student). Moreover, I added basic test endpoints to the backend to test the functionalities of the 'keycloak-connect' package that we are using. You can test the connection in various of ways:
docker exec -it <container_name> sh
) and execute the following shell script:wget -O - --header 'Content-Type: application/x-www-form-urlencoded' --post-data "username=teacher-1&password=123&client_id=cap-app&client_secret=aQX4Vdbe7PhQTPCwRdeOwIdQzbpGkOdw&grant_type=password" "http://nginx/auth/realms/CAP/protocol/openid-connect/token"
. The previous script will give you an access_token if the connection was established. For now I typed the user credentials manually for testing.wget -O - "localhost:5000/gettoken"
. The previous command will activate an api endpoint that will try to login to the client (cap-app) as "student-1". The request will return 200 which means that it was successful. To see the output and make sure it works, write the following commanddocker-compose -f docker-compose-local.yml logs -f backend
. It will printout the backend logs and will keep watching the logs for changes (coz of the second-f
flag).I edited also the auth_db and imported the newest Keycloak database. The new database contains the stuff mentioned in the first sentence of this description.