Troubleshooting Guide: Permission Inspector & Common Misconfigurations
- 1 Introduction
- 2 2. Permission Inspector Step-by-Step Protocol
- 3 3. Common Misconfigurations Reference
- 3.1 3.2 M-02: @PreAuthorize Role Missing from Token β 403
- 3.2 3.3 M-03: Blank Activity Dashboard β Lab Unit Not Assigned
- 3.3 3.4 M-04: Disabled User Can Still Access (Until Token Expires)
- 3.4 3.5 M-05: French Locale Login Error Shows Key String
- 3.5 3.6 M-06: Imported User isActive=false
- 3.6 3.7 M-07: Realm Roles Not Appearing in Token (Full Scope Allowed = OFF)
- 3.7 3.8 M-08: CORS Blocking API Calls from React Frontend
- 3.8 3.9 M-09: Access Token Too Short β Frequent Re-login
- 3.9 3.10 M-10: Duplicate Patient Results from Client Registry
- 3.10 3.11 M-11: Print Includes Unvalidated Results
- 3.11 3.12 M-12: FHIR Service Account Cannot Authenticate
- 3.12 3.13 M-13: Liquibase Checksum Error on Container Restart
- 3.13 3.14 M-14: Keycloak Container Fails to Start / Realm Not Imported
- 3.14 3.15 M-15: Missing 'In Progress' Filter on Pathology/Cytology Dashboards
- 4 4. Log and Diagnostic Reference
Introduction
OpenELIS Global 2 enforces access control across three independent layers. A user who logs in successfully may still be denied access to specific features if any one of these layers rejects the request.
Β
Layer | What It Checks | Where Configured |
1 β Keycloak (IdP) | Token signature, realm name, client ID, issuer URI, token expiry, user enabled/disabled | Keycloak Admin Console / realm JSON export |
2 β Spring Security | JWT claims vs @PreAuthorize expressions, CSRF tokens, CORS origins | SecurityConfig.java, application.properties |
3 β OpenELIS Admin UI | isActive flag, lab unit membership (data scope) | Admin > User Management |
Changes to Keycloak roles, token lifespan, or user-enabled state do NOT take effect on currently active sessions. The user must log out and log back in for a new JWT to be issued reflecting the change.
2. Permission Inspector Step-by-Step Protocol
Use this protocol whenever a user reports a 401, 403, blank page, missing menu, or 'insufficient permission' error. Work top-down; stop at the first layer that is broken and fix it before proceeding.
2.1 Step 1 β Obtain and Decode the User's JWT
A token that looks valid in the browser can still fail server-side validation. Always inspect the raw claims before assuming a role or configuration issue.
Option A β Browser DevTools (quickest)
Open the browser, log in as the affected user.
Open DevTools β Application β Local Storage β find the key beginning with oidc.user: or keycloak.
Copy the access_token value.
Paste into https://jwt.io (Debugger tab) and read the decoded payload.
Option B β Keycloak Admin Console Token Evaluate
Keycloak Admin β Clients β openelis-client β Client Scopes tab β Evaluate.
Enter the username of the affected user, click Evaluate.
Expand Generated Access Token β this is the token the user will receive on next login.
Claims to verify in the decoded token
Claim | Expected Value (OpenELIS default) | Fail Sign |
| http://<KEYCLOAK_HOST>:<PORT>/realms/OpenELIS | Mismatch with issuer-uri in application.properties |
| openelis-client (or account) | Missing or wrong client ID β 401 on every call |
| Array containing at least one of the 9 built-in OpenELIS roles | Empty array or missing key β 403 on all protected endpoints |
| Unix timestamp in the future relative to server clock | Token expired β 401 with WWW-Authenticate: Bearer error=invalid_token |
| UUID of the Keycloak user | Absent β Spring cannot map principal |
| Username as created in Keycloak (case-sensitive) | Mismatch with system_user record β blank activity dashboard |
2.2 Step 2 β Check Keycloak User Status
Even with a valid token, a user may have been disabled in Keycloak after their last login. Outstanding tokens remain valid until they expire.
Keycloak Admin β Realm: OpenELIS β Users β search for the user.
Confirm Enabled toggle is ON.
Check Credentials tab β confirm no Required Actions are pending (e.g. UPDATE_PASSWORD).
Check Role Mappings tab β confirm the expected role(s) appear under Assigned Roles for the openelis-client client.
If realm roles are used, check the Realm Roles column as well as client-level roles.
A user assigned a role in the Realm Roles section but NOT in the openelis-client client-level mapping may or may not receive that role in their token depending on whether Full Scope Allowed is enabled on the client. Always verify via the Evaluate tool (Step 1 Option B).
2.3 Step 3 β Check OpenELIS isActive Flag
Keycloak controls authentication. OpenELIS separately controls whether the user account is active at the application level. A user can be enabled in Keycloak but deactivated inside OpenELIS.
Log in as Global Admin.
Navigate to Admin β User Management.
Find the user and confirm the isActive checkbox is checked.
If unchecked, check it and save. The user must log out and back in.
The isActive flag was introduced in PR #1796. On fresh installs, all provisioned users default to active. On upgraded instances, users whose records were migrated may have isActive=false if the migration script did not set the flag.
2.4 Step 4 β Check Lab Unit Privileges (Data Scope)
Even with a valid token and an active account, users see a blank or empty activity dashboard if they have no lab unit assigned. This is the most common source of silent permission failures after a fresh install or user import.
Admin β User Management β select the user.
Scroll to the Lab Unit Privileges section.
Confirm at least one lab unit is assigned. If the list is empty, assign the relevant unit(s).
Save. The user must re-login for the session to reflect the change.
A user with the Lab Supervisor role but no lab unit assigned will authenticate successfully (HTTP 200) but see an empty worklist. This does NOT produce an error message visible to the user, making it a silent failure that is often misdiagnosed as a role problem.
2.5 Step 5 β Verify issuer-uri Alignment
Spring Security validates the iss claim in every incoming JWT against the issuer-uri configured in application.properties. A mismatch is silent at the UI level but produces a JwtValidationException in the backend log.
On the OpenELIS host, inspect the active application.properties or .env:
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://<KEYCLOAK_HOST>:<PORT>/realms/OpenELIS
Compare the value to the iss claim from Step 1. They must be byte-for-byte identical β including trailing slash presence, http vs https, and hostname case.
Check the backend log for the signature:
JwtValidationException: The 'iss' claim contained within the token is not equal to the configured issuer
If present, correct the issuer-uri to match the iss claim exactly, then restart the openelis container.
2.6 Step 6 β Verify CSRF and CORS Configuration
The dev.md documentation confirms that CSRF protection in SecurityConfig.java is enabled for form-login pages but disabled for HTTP Basic Auth / API paths. CORS misconfiguration surfaces as browser-side errors (403 or CORS policy failure) even when the JWT is perfectly valid.
Check for these signatures in the browser console:
Access to fetch at 'https://openelis.example.org/...' from origin 'https://app.example.org' has been blocked by CORS policy
403 on a POST/PUT/DELETE that uses form-based paths while Authorization: Bearer is absent
Remediation:
Confirm the React frontend origin is included in the allowed CORS origins in SecurityConfig.java.
For API clients using Bearer tokens, confirm the request does not include a CSRF token header β CSRF is not applicable to stateless JWT flows.
For browser-originated requests, confirm the client includes the Authorization: Bearer <token> header rather than relying on session cookies.
3. Common Misconfigurations Reference
The table below catalogs the fifteen most frequently encountered permission misconfigurations in OpenELIS Global 2 deployments. Severity ratings are relative to operational impact on a running lab.
ID | Symptom | Root Cause | Severity | Section |
M-01 | All API calls return 401; login appears successful | issuer-uri in application.properties does not match iss claim β trailing slash, http vs https, or wrong realm name | Β§ 3.1 | Critical |
M-02 | 403 on specific endpoints; other endpoints work normally | @PreAuthorize expression requires a role not present in realm_access.roles in the JWT | Β§ 3.2 | High |
M-03 | Blank activity dashboard; no error message | User has no lab unit assigned in OpenELIS Admin UI despite valid role and token | Β§ 3.3 | High |
M-04 | User disabled but can still access until token expires | Keycloak user disabled but outstanding JWT is still valid; token not invalidated by disabling | Β§ 3.4 | High |
M-05 | Login error shows key string instead of message text in French locale | i18n key lookup bug (PR #1364); the login error message returns the key name rather than the translated value | Β§ 3.5 | Low |
M-06 | New user can log in but activity worklist is empty | isActive flag is false; can happen on user import or after migration from 1.x | Β§ 3.6 | High |
M-07 | Realm roles are assigned but token does not contain them | Full Scope Allowed is OFF on openelis-client and realm roles are not in client scope mappings | Β§ 3.7 | Critical |
M-08 | CORS error in browser console on POST/PUT | React frontend origin not in CORS allowed list in SecurityConfig.java | Β§ 3.8 | High |
M-09 | Token expires after 5 minutes; users must log in repeatedly | Access Token Lifespan in Keycloak realm is set to the default 5 minutes | Β§ 3.9 | Medium |
M-10 | Duplicate patient results from Client Registry | Client Registry integration returns duplicate entries; dedup logic incomplete (PR #1319 partial fix) | Β§ 3.10 | Medium |
M-11 | Validated results print all results, not just validated | print-only-validated-results flag not set; changed in PR #1278 | Β§ 3.11 | Medium |
M-12 | FHIR service account cannot authenticate | Service account user created in Keycloak but not assigned the FHIR Integration Service role | Β§ 3.12 | High |
M-13 | Liquibase checksum error on container restart | Liquibase changeset file was modified after first run; checksum stored in databasechangelog table no longer matches | Β§ 3.13 | Critical |
M-14 | Keycloak container fails to start; realm not imported | OpenELIS realm JSON not mounted or realm already exists and import mode is set to FAIL_ON_EXISTING | Β§ 3.14 | Critical |
M-15 | Pathology / Cytology dashboard shows no 'In Progress' filter | Feature requires PR #1369 which added the In Progress filter; older Docker image predating this PR is deployed | Β§ 3.15 | Low |
3.1 M-01: Issuer URI Mismatch β Blanket 401
This is the single most common post-install failure. Every API call fails with 401 even though login appeared to succeed. The browser may show the dashboard briefly before all data requests fail.
How Spring Security validates the issuer:
On startup, Spring fetches <issuer-uri>/.well-known/openid-configuration.
It extracts the jwks_uri and builds a JwtDecoder.
On every incoming request, the JwtDecoder validates that the JWT's iss claim equals the configured issuer-uri exactly.
If they differ by even one character, the token is rejected with JwtValidationException.
Common variants of this mismatch:
In .env / application.properties | Actual iss in token | Result |
|
| FAIL β container hostname vs external hostname |
|
| FAIL β trailing slash mismatch |
|
| FAIL β realm name is case-sensitive |
|
| PASS |
Fix:
Decode a sample token (Β§ 2.1) and copy the iss value exactly.
Set spring.security.oauth2.resourceserver.jwt.issuer-uri to that exact value in .env.
Restart the openelis container: docker compose restart openelis.
Special case β Docker Compose internal networking: if Keycloak is accessed via its container name (keycloak) from within the Compose network, the issuer-uri must use that internal hostname. Tokens issued to a browser that contacted Keycloak via its external hostname will carry the external hostname in iss. In that scenario both hostnames must resolve to the same public key set; using the jwk-set-uri property in addition to issuer-uri can help decouple the two.
3.2 M-02: @PreAuthorize Role Missing from Token β 403
Spring Security applies @PreAuthorize expressions at the method level on every controller and service call. A 403 on a specific endpoint, while other endpoints work, is the signature of a missing role in the JWT's realm_access.roles array.
Diagnostic steps:
Identify the HTTP 403 response in browser DevTools β Network.
Note the URL path (e.g. /rest/results/patientEntry).
Find the corresponding controller in the source and look up the @PreAuthorize annotation β for example, hasRole('Results Entry') or hasAuthority('ROLE_Results Entry').
Decode the user's token (Β§ 2.1) and confirm realm_access.roles contains that exact string.
Spring Security's hasRole() automatically prepends ROLE_ when matching against GrantedAuthority objects. However, Keycloak role names in realm_access.roles do NOT include the ROLE_ prefix. The JWT converter in OpenELIS (typically a JwtAuthenticationConverter or custom Converter bean) is responsible for mapping Keycloak role strings to Spring GrantedAuthority objects with the ROLE_ prefix. If this converter is misconfigured, roles will never match.
Keycloak Admin β Clients β openelis-client β Roles β confirm the expected role exists by exactly the right name.
Keycloak Admin β Users β [user] β Role Mappings β openelis-client β assign the role.
User must log out and log back in; only the new token will carry the updated role.
Re-run the Evaluate tool (Β§ 2.1 Option B) to confirm the role now appears in Generated Access Token.
3.3 M-03: Blank Activity Dashboard β Lab Unit Not Assigned
PR #1374 introduced filtering of the activity dashboard by the user's assigned lab units. A user with valid authentication and a correctly-assigned role will see a completely empty worklist if they have no lab unit membership.
This failure is silent β no error is thrown, no 403 is returned. The dashboard renders but displays no work items. Users frequently misreport this as a role problem.
How to distinguish from a role problem:
Role problem: Specific menu items or buttons are absent; HTTP 403 appears in network log.
Lab unit problem: Menu items appear; clicking through to worklist shows empty table; no HTTP errors.
Fix:
Admin β User Management β locate user.
Under Lab Unit Privileges, add the relevant unit(s).
Save. User must re-login.
3.4 M-04: Disabled User Can Still Access (Until Token Expires)
Keycloak does not broadcast token revocation. When a Keycloak user is disabled, existing valid JWTs continue to be accepted by the Spring Security resource server until the access token expires naturally. By default, the OpenELIS realm's access token lifespan is 5 minutes; however if this has been extended (Β§ 3.9), a disabled user may remain active for hours.
Immediate revocation options:
Keycloak Admin β Users β [user] β Sessions tab β click Logout All Sessions. This invalidates the refresh token, preventing token renewal after the current access token expires. The user cannot silently re-acquire a new token.
For immediate enforcement without waiting for expiry: reduce Access Token Lifespan temporarily, then restore it after the user's token expires.
For API / FHIR service accounts that hold long-lived tokens: delete the service account session via kcadm.sh:
./kcadm.sh delete users/<USER_UUID>/sessions -r OpenELIS
3.5 M-05: French Locale Login Error Shows Key String
Symptom: When French language is selected and login fails, the error message displays a raw i18n key string such as error.login.disabled instead of the translated text.
Bug reference: Issue #1363, fixed in PR #1364 (fr.json and en.json updated).
Fix: Ensure the deployed Docker image includes PR #1364 or later. If running an older image:
Pull the latest image tag from the registry.
Run docker compose pull OpenLIS followed by docker compose up -d openelis.
3.6 M-06: Imported User isActive=false
Users whose system_user record is created by means other than first-login provisioning (e.g., direct SQL insert, migration script, user import tool) may have isActive set to false if the script did not explicitly set the flag. These users can log in via Keycloak and receive a valid JWT, but the application denies access at the data layer.
Diagnostic SQL (run against the openelis PostgreSQL database):
SELECT login_name, is_active FROM system_user WHERE is_active = false;
Fix:
Admin β User Management β locate user β check isActive β save.
Or via SQL (use with caution in production):
UPDATE system_user SET is_active = true WHERE login_name = '<username>';
3.7 M-07: Realm Roles Not Appearing in Token (Full Scope Allowed = OFF)
By default Keycloak clients have Full Scope Allowed set to ON, which means all realm roles assigned to a user are included in the access token. If this setting has been turned OFF (intentionally for security hardening or accidentally), only roles explicitly mapped in the client's scope will appear in realm_access.roles.
Diagnostic:
Keycloak Admin β Clients β openelis-client β Client Scopes tab β Evaluate β inspect Generated Access Token.
If realm_access.roles is empty or missing roles that appear in the user's Realm Roles assignment, Full Scope Allowed is likely OFF.
Fix (choose one):
Re-enable Full Scope Allowed: Clients β openelis-client β Settings β scroll to Full Scope Allowed β toggle ON.
Or (recommended for security hardening): keep Full Scope Allowed OFF and instead add explicit realm role scope mappings: Client Scopes β openelis-client-dedicated β Scope tab β Add realm roles one-by-one.
3.8 M-08: CORS Blocking API Calls from React Frontend
The React SPA and the Spring Boot backend run as separate services. If the allowed CORS origin list in SecurityConfig.java does not include the exact origin from which the browser is loading the React app, all cross-origin API calls will be blocked by the browser before the request reaches Spring.
Browser console signature:
Access to fetch at 'https://openelis.example.org/api/...' from origin 'https://app.example.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present
Common cause in Docker Compose deployments: the configured allowed origin uses http while the browser accesses via https, or uses a port number that is stripped by a reverse proxy.Fix:
Identify the exact origin used by the browser (scheme + hostname + port, no trailing slash).
Add it to the CORS configuration in SecurityConfig.java.
Rebuild and redeploy: docker compose build openelis && docker compose up -d openelis.
3.9 M-09: Access Token Too Short β Frequent Re-login
The Keycloak default access token lifespan is 5 minutes. In a busy lab environment users performing long data-entry sessions will experience silent session expiry, which manifests as 401 errors and a forced redirect to the login page mid-workflow.
Recommended settings for OpenELIS lab workflows:
Setting | Default | Recommended | Location |
Access Token Lifespan |
|
| Realm Settings β Tokens |
SSO Session Idle |
|
| Realm Settings β Sessions |
SSO Session Max |
|
| Realm Settings β Sessions |
Increasing the access token lifespan has a security tradeoff: a stolen token remains valid for longer. Balance session length against the lab's security posture. For high-security deployments, prefer a short access token lifespan with silent token refresh enabled in the React client rather than simply extending the lifespan.
3.10 M-10: Duplicate Patient Results from Client Registry
If the Client Registry integration (PR #1219) is enabled, OpenELIS queries an external patient index when displaying results. PR #1319 partially addressed deduplication, but edge cases remain where a patient with multiple registry entries generates duplicate result rows.
Diagnostic: the duplication is visible in the patient result report β the same accession number and result appear more than once for the same patient.
Fix:
Confirm the deployed image includes PR #1319 or later.
If the issue persists, disable the Client Registry integration in Admin β Site Information until the underlying patient registry data is cleaned up.
3.11 M-11: Print Includes Unvalidated Results
PR #1278 changed the default behaviour so that patient reports only print validated results. Deployments using a Docker image older than the release containing PR #1278 will print all results including pending and unvalidated ones, which is a clinical safety concern.
Fix: update to an image including PR #1278 or later. Verify by attempting to print a report for a patient with a mix of validated and unvalidated results.
3.12 M-12: FHIR Service Account Cannot Authenticate
FHIR integration uses a Keycloak service account (non-interactive OAuth2 client credentials grant). If the service account user was created in Keycloak but not assigned the FHIR Integration Service client role, the Bearer token it receives will not contain the required role and all FHIR API calls will return 403.
Fix:
Keycloak Admin β Clients β [fhir-client] β Service Account Roles tab.
Under Client Roles, select openelis-client and assign FHIR Integration Service.
Re-issue the service account token via the token endpoint and decode it to confirm realm_access.roles now contains the role.
3.13 M-13: Liquibase Checksum Error on Container Restart
Liquibase records a SHA256 checksum of every applied changeset in the databasechangelog table. If a changeset file is modified after it has been run (e.g., a developer edits a migration file in the repo and the change is pulled into a running environment), Liquibase will refuse to start and the OpenELIS container will crash-loop.
Log signature:
liquibase.exception.ValidationFailedException: Validation Failed: ... checksum '...' vs '...'
Fix:
Do NOT modify executed changesets. This is a Liquibase hard rule.
If the modification was accidental, revert the changeset file to its original state and restart.
If the modification was intentional and the environment is non-production: clear the offending row from databasechangelog and re-run.
DELETE FROM databasechangelog WHERE filename LIKE '%<offending_file>%';
For production: create a new addColumn / modifyColumn changeset for the intended change rather than editing the existing one.
Never delete rows from databasechangelog in production without first taking a full database backup and validating the change in staging.
3.14 M-14: Keycloak Container Fails to Start / Realm Not Imported
OpenELIS relies on the OpenELIS realm being present in Keycloak. If the realm JSON was not mounted into the container or the import mode is set to FAIL_ON_EXISTING and the realm already exists from a previous run, Keycloak may fail at startup.
Common docker-compose.yml configuration for realm import:
keycloak:
environment:
KC_DB=postgresKEYCLOAK_ADMIN=adminKEYCLOAK_ADMIN_PASSWORD=${KC_ADMIN_PASSWORD}
command: start --import-realm
volumes:
./config/OpenELIS-realm.json:/opt/keycloak/data/import/OpenELIS-realm.json
Troubleshooting steps:
docker compose logs keycloak β look for ERROR importing realm or WARN Realm OpenELIS already exists.
If the realm already exists and import is failing: the --import-realm flag will skip already-existing realms by default in Keycloak 22+. In older versions, set KC_IMPORT_OVERWRITE=true or remove the realm via kcadm.sh before restarting.
If the realm JSON file is not found: verify the volume mount path in docker-compose.yml matches the actual file location on the host.
3.15 M-15: Missing 'In Progress' Filter on Pathology/Cytology Dashboards
PR #1369 added the In Progress filter to the Pathology and Cytology dashboards. Deployments running images that predate this PR will not display the filter option.
Symptom: Pathology β Activity Dashboard shows Completed and Pending but no In Progress option.
Fix: Pull and deploy the latest image tag.
4. Log and Diagnostic Reference
4.1 Backend Log β Key Error Signatures
Enable Spring Security debug logging for deep troubleshooting (use in development/staging only):
logging.level.org.springframework.security=DEBUG
Log Signature | Meaning | Action |
| issuer-uri mismatch | Fix M-01 (Β§ 3.1) |
| @PreAuthorize failed; role not in token | Fix M-02 (Β§ 3.2) |
| Token past exp timestamp | Extend token lifespan (Β§ 3.9) or force re-login |
| Bearer token absent or malformed; treated as anonymous | Confirm Authorization header is being sent by client |
| Liquibase checksum mismatch | Fix M-13 (Β§ 3.13) |
| Keycloak container not reachable at startup | Check depends_on / healthcheck in docker-compose.yml |
4.2 Useful kcadm.sh Diagnostic Commands
Command | Purpose |
| List all effective roles for a user (including composite roles) |
| View current access/session token lifespan settings |
| Look up a user by username and retrieve their UUID |
| Immediately invalidate all active sessions for a user |
| Verify the openelis-client exists and is enabled |
| Retrieve the OpenID discovery document; confirms realm is up and returns the issuer value |
4.3 Useful Docker Compose Diagnostic Commands
Command | Purpose |
| Tail OpenELIS backend logs |
| Tail Keycloak logs; check for realm import errors |
| Verify all containers are Up; detect crash-loops |
| Confirm the issuer-uri and client secret env vars are set correctly inside the container |
| Apply .env changes to the OpenELIS container |
π Last reviewed: 2026-05 Β Β·Β Applies to: OpenELIS Global 3.2.x Β Β·Β Maintained by: the OEG documentation team Β Β·Β Suggest a change