GOV RBAC

GOV RBAC  ·  Role-based access control for UK Government

Identity and access, built for government. Audited by default.

A role-based access control platform across four services, with Keycloak IAM, OIDC sign-in and permissions embedded in signed tokens, all behind a GOV.UK Design System interface.

Manage
User profile with personal details, role links and account controls
One administrator workflow: find a user, manage their account, and review every change.

The product

Five tasks, one consistent service.

01  /  Sign in

Government-grade sign-in, out of the box.

Authentication uses the OIDC Authorization Code flow with PKCE via Keycloak. Tokens never reach the browser, and sessions are regenerated on every successful sign-in to prevent session fixation.

  • +Access, ID and refresh tokens stored server-side only
  • +Sign-in rate-limited to 20 requests per 15 minutes per IP
  • +Locked accounts are stopped at the door, before entering the app
GOV.UK Design System sign-in page with email and password fields
02  /  Find

Every user, every status, one search away.

Administrators search and list users with a live activity status. A daily scheduler marks accounts dormant after 60 days, so stale access is flagged without anyone having to remember.

  • +Active and inactive status driven by a daily inactivity scheduler
  • +Create user appears only for administrators
  • +One template serves every permission tier
User directory table with names, emails and Active status tags, a search field and a Create user button
03  /  Manage

Account controls that adapt to who's looking.

The profile shows personal details, roles and account controls. Reset password and Lock account render only for users with the right permissions, with no separate admin pages to maintain.

  • +Actions rendered conditionally against the signed-in user's roles
  • +Password reset issues a four-word passphrase, shown once and never stored
  • +Admin unlock clears Keycloak state and failed-attempt counts together
User profile for Joan Collins with details, a Roles section and Account controls
04  /  Assign

Role changes you confirm before they land.

Roles are changed in two steps: a selection form, then a confirmation page showing the before-and-after difference. On save, the full capability set is resolved and written into the user's next token.

  • +Two-step confirmation with a before-and-after view
  • +Role inheritance graph resolved to a complete capability set
  • +Capabilities synced to Keycloak and embedded in the next JWT
Manage roles page with checkboxes for User Core Access, Customer Maintenance and User Administration
05  /  Audit

A complete history, kept by the database itself.

Every change to an account or role assignment is captured by PostgreSQL versioning triggers into mirrored history tables. There is no application-level audit code to forget or bypass.

  • +Each row versioned with a validity window before it changes
  • +Role grants and revocations shown with who made them
  • +Structured logging with correlation IDs across services
Audit history showing timestamped account changes and role assignment history

Screens show test data. All names and email addresses are fictional.

Features

Engineered for consistency and control.

01

User creation saga

A distributed transaction across the user service, Keycloak and access control. If a later step fails, a compensation call rolls back the Keycloak account, keeping every system consistent without two-phase commit.

02

JWT capability embedding

Capabilities are written as Keycloak user attributes and embedded in signed tokens by protocol mappers. Downstream services read them straight from the JWT, with an HTTP fallback for older tokens.

03

Account lifecycle

A daily scheduler deactivates dormant accounts. An hourly job mirrors Keycloak brute-force locks into access control, and admin unlock resets everything atomically.

04

Temporal audit trail

Versioning triggers copy each modified row to a history table with a validity range. Modifier names are resolved across schemas by UUID.

05

Layered security

Server-side sessions with httpOnly, secure cookies; CSRF synchronizer tokens; Helmet headers with a strict CSP and no unsafe-inline; sign-in rate limiting; session regeneration on OIDC callback.

06

Permission-driven UI

Route-level checks in middleware, and Nunjucks templates that render each action only for users who can perform it. One template per page serves every tier.

Architecture

Four services. One source of identity.

All four services share one PostgreSQL instance, split across two schemas. Identity is correlated by a shared system user ID, and no foreign key crosses a schema boundary.

01
user-management-ui
Node.js · Express · TypeScript

GOV.UK interface. Owns the session, CSRF, OIDC callback and token refresh.

02
user-management-service
Spring Boot 3 · Java 17

Identity, profile, account lifecycle, schedulers and saga orchestration.

03
access-control-manager
Spring Boot 3 · Java 17

Roles and permissions, capability graph traversal, JWT attribute sync.

04
keycloak-manager
Spring Boot 3 · Java 17

Keycloak Admin API proxy: users, attributes and protocol mappers.

PostgreSQL user_management  ·  access_control Keycloak for identity and tokens

Key flows

  1. FLOW 01
    User creation saga

    The user service saves the record, asks the Keycloak manager to create the account, then initialises access control. If access control fails, the Keycloak account is deleted before the database transaction rolls back.

    UI → UMS [DB insert] → KM [Keycloak create] → ACM [AC insert]
    ACM fail → KM [Keycloak rollback] → UMS [DB rollback]
  2. FLOW 02
    JWT capability embedding

    On a role change, access control walks the inheritance graph and writes the resolved capabilities to Keycloak. Protocol mappers then embed them in every subsequent token, so no lookup is needed per request.

    Role change → ACM [graph traversal] → KM [write attributes] → Keycloak
    Next token: capabilities: ["Create users", …] as a signed claim
  3. FLOW 03
    Sign-in and account guard

    After the OIDC token exchange, the UI fetches the user record. A locked account has its session destroyed and is redirected to an account-locked page. Otherwise the session is regenerated and the last sign-in date is stamped.

Spring Boot 3Java 17KeycloakPostgreSQLNode.jsTypeScriptOIDC / PKCEJWTGOV.UK Frontend v6