Keycloak Configuration¶
Keycloak runs as shared infrastructure in its own standalone repository (Keycloak repo),
separate from the Recron AppHost. This guide documents the realm configuration used by Recron.
Table of Contents¶
- Creating a Realm
- Basic Settings
- Creating the Scalar Client (API Documentation)
- Creating the Frontend Client (Web Application)
- LinkedIn Identity Provider (Social Login)
- Theme Configuration
- Import/Export Configuration
1. Creating a Realm¶
Step 1: Access the Admin Console¶
- Navigate to
https://auth.bluebraces.online/admin - Log in as administrator
Step 2: Create a New Realm¶
- Click the dropdown in the top-left corner (defaults to "master")
- Click "Create Realm"
- Fill in the details:
- Realm name:
recron - Display name:
Recron - Enabled: ✅ ON
- Click "Create"
2. Basic Settings¶
Realm Settings → Login¶
- Go to Realm settings in the left menu
- Switch to the Login tab
- Enable the following options:
- ✅ User registration
- ✅ Forgot password
- ✅ Remember me
- ✅ Login with email
- Click Save
3. Creating the Scalar Client¶
The Scalar client is used for API documentation (Scalar API Reference) and uses the Client Credentials Flow.
Step 1: Create the Client¶
- Go to Clients in the left menu
- Click "Create client"
Step 2: General Settings¶
- Client type:
OpenID Connect - Client ID:
scalar - Click Next
Step 3: Capability Config¶
- Client authentication: ✅ ON (confidential client)
- Authorization: ✅ ON
- Authentication flow:
- ❌ Standard flow (disable)
- ❌ Implicit flow (disable)
- ❌ Direct access grants (disable)
- ✅ Service accounts roles (enable)
- PKCE Code Challenge Method:
S256 - Click Next
Step 4: Retrieve the Client Secret¶
- After saving, go to the Credentials tab
- Copy the Client Secret (needed for configuration)
- Save it in
Recron.AppHost/appsettings.Development.json:
{
"Parameters": {
"username": "your-username",
"password": "your-password",
"scalar-client-id": "scalar",
"scalar-client-secret": "<copied-secret>"
}
}
4. Creating the Frontend Client¶
The Frontend client is used by the frontend application (SolidJS SPA) and uses the Authorization Code Flow with PKCE.
Step 1: Create the Client¶
- Go to Clients in the left menu
- Click "Create client"
Step 2: General Settings¶
- Client type:
OpenID Connect - Client ID:
frontend - Click Next
Step 3: Capability Config¶
- Client authentication: ❌ OFF (public client)
- Authorization: ❌ OFF
- Authentication flow:
- ✅ Standard flow (enable)
- ❌ Implicit flow (disable)
- ❌ Direct access grants (disable)
- ❌ Service accounts roles (disable)
- PKCE Code Challenge Method:
S256(requires PKCE) - Click Next
Step 4: Login Settings¶
- Root URL:
http://localhost:5173(or your application URL) - Home URL:
http://localhost:5173 - Valid redirect URIs:
http://localhost:5173/*- In production, also add:
https://your-domain.com/* - Valid post logout redirect URIs:
http://localhost:5173/*- In production, also add:
https://your-domain.com/* - Web origins:
http://localhost:5173+(automatically adds all valid redirect URIs)- In production, also add:
https://your-domain.com - Click Save
Step 5: Application Configuration¶
The frontend application reads Keycloak configuration from environment variables (recron-web/.env):
VITE_AUTH_ISSUER=https://auth.bluebraces.online/realms/recron
VITE_AUTH_CLIENT_ID=frontend
VITE_AUTH_URL=http://localhost:5173
VITE_API_BASE_URL=http://localhost:5000
5. LinkedIn Identity Provider (Social Login)¶
LinkedIn allows users to sign in with their LinkedIn account using OpenID Connect.
Prerequisites¶
- LinkedIn Company Page — required to create an app. This must be a Company Page, not a personal profile. If you don't have one, click "Create a new LinkedIn Page" in the app creation form or create one at linkedin.com/company/setup.
- Privacy policy URL — must be a valid URL starting with
https://. The app includes a privacy policy page at/privacy(e.g.,https://app.bluebraces.online/privacy). - App logo — square image, at least 100x100px.
Step 1: Register an Application on LinkedIn¶
- Go to LinkedIn Developer Portal
- Click "Create app"
- Fill in the form:
| Field | Value |
|---|---|
| App name | Recron |
| LinkedIn Page | Search for your company name or paste the URL |
| Privacy policy URL | https://app.bluebraces.online/privacy |
| App logo | Upload a square logo (min. 100x100px) |
| Legal agreement | Check "I have read and agree to these terms" |
- Click "Create app"
Step 2: Add the "Sign In with LinkedIn" Product¶
- In your LinkedIn app, go to the Products tab
- Find "Sign In with LinkedIn using OpenID Connect"
- Click "Request access" and accept the terms
- Wait for approval (usually instant)
Step 3: Configure OAuth 2.0 Settings¶
- Go to the Auth tab in your LinkedIn app
- Under OAuth 2.0 settings → Authorized redirect URLs for your app, click "Add redirect URL" and add:
https://auth.bluebraces.online/realms/recron/broker/linkedin-openid-connect/endpoint- Copy the Client ID and Primary Client Secret from the top of the Auth tab
Step 4: Configure LinkedIn IdP in Keycloak¶
- Go to Keycloak Admin Console (
https://auth.bluebraces.online/admin) - Select the
recronrealm - Go to Identity Providers in the left menu
- Click "Add provider" → "LinkedIn OpenID Connect"
- Fill in:
- Alias:
linkedin-openid-connect(must match this exactly for the theme icon) - Display Name:
LinkedIn - Client ID: paste from LinkedIn Developer Portal
- Client Secret: paste from LinkedIn Developer Portal
- Default Scopes:
openid profile email - Sync Mode:
Import - Click "Save"
Step 5: Configure Attribute Mappers (Optional)¶
After saving the IdP, go to the Mappers tab and add:
| Name | Mapper Type | Claim | User Attribute |
|---|---|---|---|
| LinkedIn First Name | Attribute Importer | given_name |
firstName |
| LinkedIn Last Name | Attribute Importer | family_name |
lastName |
| LinkedIn Email | Attribute Importer | email |
email |
| LinkedIn Profile Picture | Attribute Importer | picture |
picture |
Step 6: Verification¶
- Navigate to
https://auth.bluebraces.online/realms/recron/account - You should see a LinkedIn button on the login page (with the LinkedIn icon from the Keywind theme)
- Click it to test the sign-in flow
Available Data from LinkedIn¶
LinkedIn's OpenID Connect provides the following data:
| Field | Example |
|---|---|
sub |
782bbtaQ |
name |
John Doe |
given_name |
John |
family_name |
Doe |
picture |
Profile picture URL |
email |
doe@email.com |
email_verified |
true |
locale |
en-US |
Note: Extended profile data (job title, company, work history, skills) requires separate LinkedIn API access that must be approved by LinkedIn. The self-serve "Sign In with LinkedIn" product only provides the basic data listed above.
6. Theme Configuration¶
Option A: Using the Keywind Theme (recommended)¶
Step 1: Theme Installation¶
The Keywind theme is located in the Keycloak repo at themes/keywind/.
It is bind-mounted into the Keycloak container via the Keycloak repo's docker-compose.yml.
Step 2: Set the Theme in Realm¶
- Go to Realm settings
- Switch to the Themes tab
- Set:
- Login theme:
keywind - Account theme:
keywind - Email theme:
keywind - Admin Console theme: leave default
- Click Save
Step 3: Customize Colors¶
To change the theme colors, edit the file in the Keycloak repo:
Find the <style> section at the end of the file (before </#macro>) and modify the colors as needed.
Reloading changes:
After saving changes to document.ftl:
- Restart the Keycloak container (
docker compose restartin the Keycloak repo) - Wait for the container to start
- Clear browser cache (Ctrl+Shift+Delete)
- Open the login page in incognito mode:
https://auth.bluebraces.online/realms/recron/account
Step 4: Verification¶
- Log out of the Admin Console
- Navigate to:
https://auth.bluebraces.online/realms/recron/account - You should see the new Keywind theme
7. Import/Export Configuration¶
Exporting the Realm Configuration¶
Via Admin Console (recommended for small changes):¶
- Go to Realm settings
- Click the Action tab → Partial export
- Select what to export:
- ✅ Export groups and roles
- ✅ Export clients
- Click Export
Via Keycloak repo (automatic on startup):¶
The realm configuration file is located in the Keycloak repo at:
The Keycloak docker-compose.yml mounts this directory to /opt/keycloak/data/import
and starts Keycloak with --import-realm, which imports the realm on first startup.
Local development: Start Keycloak from the Keycloak repo (docker compose up -d).
The realm is auto-imported on first startup. Then start Recron's AppHost, which connects
to Keycloak via the keycloak-authority parameter (default: https://auth.bluebraces.online).
Production: Keycloak runs from its own docker-compose.yml on the VPS at /opt/keycloak/.
The realm is imported on first startup. On subsequent restarts, realm data persists in the
Keycloak data volume.
Importing the Realm Configuration¶
Option 1: Via Admin Console¶
- Go to the dropdown in the top-left corner
- Click "Create Realm"
- Click "Browse" and select the
realm-export.jsonfile - Click "Create"
Option 2: Via Keycloak repo (local development)¶
Start Keycloak from the Keycloak repo with docker compose up -d.
The realm is automatically imported from realms/realm-export.json on first startup.
Updating an Existing Realm¶
⚠️ Warning: Importing may overwrite the existing configuration!
- Back up the current configuration (export the realm)
- Stop the Keycloak container (
docker compose downin the Keycloak repo) - Update the
realms/realm-export.jsonfile in the Keycloak repo - Restart the Keycloak container (
docker compose up -d)
Key Settings Summary¶
Realm: recron¶
- ✅ User registration: enabled
- ✅ Forgot password: enabled
- ✅ Remember me: enabled
- ✅ Login with email: enabled
- 🔐 SSL required: external
- 🎨 Theme: keywind
Client: scalar (API Documentation)¶
- Type: Confidential
- Flow: Client Credentials (Service Account)
- Authentication: ON
- Authorization: ON
- Redirect URIs:
/*
Client: frontend (Web App)¶
- Type: Public
- Flow: Authorization Code + PKCE
- Authentication: OFF
- PKCE: S256 (required)
- Redirect URIs:
http://localhost:5173/* - Web origins:
http://localhost:5173
Useful Links¶
- Admin Console: https://auth.bluebraces.online/admin
- Realm Account: https://auth.bluebraces.online/realms/recron/account
- OpenID Configuration: https://auth.bluebraces.online/realms/recron/.well-known/openid-configuration
- Token Endpoint: https://auth.bluebraces.online/realms/recron/protocol/openid-connect/token
Troubleshooting¶
Problem: Theme Not Loading¶
- Check that the
themes/keywind/loginfolder exists in the Keycloak repo - Restart the Keycloak container (
docker compose restart) - Check the Keycloak container logs (
docker compose logs keycloak)
Problem: Client Secret Not Working¶
- Make sure you copied the entire secret
- Verify the client has "Client authentication" enabled
- Regenerate the secret in the "Credentials" tab
Problem: CORS Errors in Frontend¶
- Check "Web origins" in the frontend client
- Make sure
http://localhost:5173or+is listed - Restart the frontend application
Problem: Redirect URI Mismatch¶
- Check "Valid redirect URIs" in the client
- Must contain the exact application URL +
/* - Example:
http://localhost:5173/*