This guide explains how to use Keycloak for testing Hawk's SSO implementation.
From the project root:
docker-compose up keycloakKeycloak will be available at: http://localhost:8180
The setup script will configure Keycloak with a test realm, SAML client, and test users.
Option 1: Run from your host machine (recommended):
cd api/test/integration/keycloak
KEYCLOAK_URL=http://localhost:8180 ./setup.shOption 2: Run from API container (if you don't have curl on host):
docker-compose exec -e KEYCLOAK_URL=http://keycloak:8180 api /keycloak/setup.shNote: The setup script requires curl and bash to interact with Keycloak API. The Keycloak container doesn't have these tools, so we either run from host or from another container (like api).
- URL: http://localhost:8180
- Username:
admin - Password:
admin
- Name:
hawk - SAML Endpoint: http://localhost:8180/realms/hawk/protocol/saml
- Client ID / Entity ID:
urn:hawk:tracker:saml- This must match
SSO_SP_ENTITY_IDenvironment variable in Hawk API
- This must match
- Protocol: SAML 2.0
- ACS URL: http://localhost:4000/auth/sso/saml/{workspaceId}/acs
- Name ID Format: email
Hawk API requires the following environment variable:
- SSO_SP_ENTITY_ID:
urn:hawk:tracker:saml- Set in
docker-compose.ymlor.envfile - This is the Service Provider Entity ID used to identify Hawk in SAML requests
- Set in
| Username | Password | Department | Title | |
|---|---|---|---|---|
| testuser | testuser@hawk.local | password123 | Engineering | Software Engineer |
| alice | alice@hawk.local | password123 | Product | Product Manager |
| bob | bob@hawk.local | password123 | Engineering | Senior Developer |
To configure SSO in Hawk workspace settings:
Option 1: Use the helper script (recommended):
cd api/test/integration/keycloak
./get-config.shThis will output all required values that you can copy-paste into Hawk SSO settings.
Option 2: Get values manually:
-
IdP Entity ID:
http://localhost:8180/realms/hawk -
SSO URL:
http://localhost:8180/realms/hawk/protocol/saml -
X.509 Certificate:
Via command line:
curl -s "http://localhost:8180/realms/hawk/protocol/saml/descriptor" | grep -oP '(?<=<ds:X509Certificate>)[^<]+' | head -1
Via Keycloak Admin Console:
- Go to Realm Settings → Keys
- Find RS256 algorithm row
- Click "Certificate" button
- Copy the certificate (without BEGIN/END lines)
- Paste into Hawk SSO settings
Configure these mappings in Hawk:
- Email:
email - Name:
name(full name - combines firstName and lastName from Keycloak) - Department (optional):
department - Title (optional):
title
Select: Email address (urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress)
- Configure SSO in Hawk workspace settings with the values above
- Enable SSO for the workspace
- Navigate to: http://localhost:4000/auth/sso/saml/{workspaceId}
- You'll be redirected to Keycloak login page
- Login with any test user (e.g.,
testuser@hawk.local/password123) - After successful authentication, you'll be redirected back to Hawk with tokens
Run integration tests:
cd api
yarn test:integrationCheck Docker logs:
docker-compose logs keycloakIf you need to reset:
docker-compose down -v
docker-compose up keycloakIf SAML validation fails:
- Verify the certificate is copied correctly (no extra spaces/newlines)
- Ensure you copied the certificate content without BEGIN/END markers
- Check Keycloak logs for signature errors
You can view the full SAML metadata descriptor at:
http://localhost:8180/realms/hawk/protocol/saml/descriptor
This contains all technical details about the IdP configuration.
Files are located in api/test/integration/keycloak/:
import/hawk-realm.json- Keycloak realm configurationsetup.sh- Automated setup script
To test with a different workspace ID, update the ACS URL in the Keycloak Admin Console:
- Go to Clients → hawk-sp
- Update
saml_assertion_consumer_url_postattribute - Save changes
You can add more users through:
- Keycloak Admin Console → Users → Add User
- Or update
api/test/integration/keycloak/import/hawk-realm.jsonand re-import
If you need to run Keycloak on a different port:
- Update
KC_HTTP_PORTindocker-compose.yml - Update port mapping in
docker-compose.yml - Update all URLs in this README
- Update
api/test/integration/keycloak/import/hawk-realm.jsonwith new URLs