Skip to content

Latest commit

 

History

History
182 lines (120 loc) · 5.42 KB

dev_authentication_setup.md

File metadata and controls

182 lines (120 loc) · 5.42 KB

Guess The Number

If you followed the instructions in the README to run the app but noticed that the Player name is always Default-User and there is no option to login, the following instructions will fix that.

Setup Authentication using Keycloak

Before we begin,

Please DO NOT use these instructions for a production environment. These are strictly for the purpose of development on a local machine ONLY.

  • Make sure Docker is installed and is running.

Table Of Contents

1. Run Keycloak Container

$ docker run \
-p 8080:8080 \
-e KEYCLOAK_USER=admin \
-e KEYCLOAK_PASSWORD=admin \
quay.io/keycloak/keycloak:11.0.3

Top

2. Login to Keycloak

  • Goto http://localhost:8080 to connect to keycloak

keycloak-home

Top

  • Click on Administration Console and login as User: admin with Password: admin

keycloak-admin-login

Top

3. Create a new Client

  • Click on Clients in the left menu

keycloak-admin-console

Top

  • Click Create button in the top right corner to create new client

keycloak-clients

Top

  • Enter a Client ID, for example: wave
  • Select Client Protocol to be openid-connect
  • Press Save

keycloak-new-client-save

Top

  • Right after the page is saved, new settings appear on the same page
  • Set Access Type as confidential
  • Set Valid Redirect URIs as *
  • Press Save

keycloak-client-access-type

Top

3. Save Client Secret

  • Goto the Credentials tab for the newly created client
  • Save the Secret code to use later when starting the Wave Server.
  • The code shown in this example is 76344ea2-f64d-43a1-b150-725e385b2fee

keycloak-credentials

Top

4. Create New User

  • Click on Users in the left menu under Manage
  • Click on Add User in the top right corner to add a new user

keycloak-add-user

Top

keycloak-save-new-user

Top

  • After saving, goto the Credentials tab for the newly created user
  • Enter a new password for the user
  • Set Temporary field to OFF
  • Press Set Password
  • Create as many users as needed in this way

keycloak-new-user-set-password

Top

  • To see all the users, click on Users under Manage in the left menu
  • Click on View all users button

keycloak-view-all-users

Top

5. Logout of Admin on Keycloak

  • After all required users are created, logout as admin and close the browser window so that we can login as one of the newly created users while using the Wave app.

keycloak-admin-logout

Top

6. Start waved with authentication

  • Find the previously saved Client Secret in Step 3
  • In the next command, replace the value of oidc-client-secret with your Client Secret
  • Use the following command to start the Wave Server
 ./waved -oidc-client-id wave \
  -oidc-client-secret 76344ea2-f64d-43a1-b150-725e385b2fee \
  -oidc-end-session-url http://localhost:8080/auth/realms/master/protocol/openid-connect/logout \
  -oidc-provider-url http://localhost:8080/auth/realms/master \
  -oidc-redirect-url http://localhost:10101/_auth/callback

Top

7. Start the App

  • Assuming that the python environment for the wave app is already setup, and make sure you are in the right directory and start the app using
$ wave run guess_the_number/guess.py

Top

8. Login to Wave app

  • In a new incognito browser window, goto http://localhost:10101 to launch the app
  • The app will require you to login now
  • Login as one of the newly created users.
  • Once logged in, we can see the Player's name displayed on top.
  • Use a different browser, for example chrome/firefox to login simultaneously as a different user
  • Play a few games while logged in as each player
  • Private games include games that are abandoned by selecting Quit and games that are not selected to be shared publicly

Top