Skip to main content

Keycloak Local Development Guide

1. Local Setup (Step-by-Step)

  1. Launch Containers: Use docker-compose up -d keycloak keycloak-db.
  2. Auto-Import: The system is configured to import keycloakConfig.json automatically on startup.
  3. Verify: Access the UI at http://localhost:8081.

2. Pre-configured Test Users

The following accounts are included in keycloakConfig.json to facilitate testing of various permission levels within the PROMPT platform.

UsernamePasswordUniversity LoginMatriculation NumberClient Role (prompt-server)
adminadminad12min00000001PROMPT_Admin
lecturerlecturerle50ctu00000002PROMPT_Lecturer
course-lecturercourse-lecturerco67lec00000003PROMPT_Course_Lecturer
course-editorcourse-editorco69edt00000004PROMPT_Course_Editor
studentstudentno42tum00000005PROMPT_Student
student-passkeystudent-passkeyno43tum00000006PROMPT_Student

3. Modifying Users and Roles

  • Adding Users: Go to Users -> Add user. Required fields: Username, Email, First/Last Name.
  • Assigning Roles: Go to Users -> pick user -> go to Role Mapping tab and Assign role.

4. Manual Client Mapper Configuration

If you need to manually add mappers for prompt-server:

  1. Go to Clients -> prompt-server -> Client scopes.
  2. Click prompt-server-dedicated -> Add mapper -> By configuration.
  3. Choose User Attribute.
  4. Example (University Login):
    • Name: university_login
    • User Attribute: university_login
    • Token Claim Name: university_login

5. Troubleshooting & Reset

  • Reset to Default: Run docker-compose down -v and rm -rf keycloak_postgres_data. This wipes the DB and re-imports the JSON on next Keycloak start.
  • 401 Unauthorized: Check if KEYCLOAK_CLIENT_SECRET in .env.dev matches the one in Keycloak UI.
  • Passkey Issues: Ensure Resident Key is Required in WebAuthn Passwordless Policy.