Security

This page describes how subscription protects what it holds and who may call it: the tokens accepted, what each endpoint requires, the other services’ calls, the tenant credentials and their master keys, the public endpoints, and where subscription reads its secrets. It is meant for technical readers (development, operations). No secret value appears here, only property and path names.

Tokens accepted

subscription is an OAuth2 resource server: every call carries a Keycloak access token (JWT), checked by security-library’s decoder (CustomNimbusJwtDecoder).

  • Accepted realms. security.jwt.allowed-realms lists the realms whose tokens are accepted. The token’s issuer (iss) must be exactly <Keycloak URL>/realms/<realm> for one of them; any other token is refused before Keycloak is contacted. Without this property, the service does not start.
  • Signature. Only RS256-signed tokens are read; an encrypted or unsigned token gets 401. The public keys come from the realm’s JWKS endpoint.
  • Caller’s realm. subscription reads the user’s realm from the token’s issuer, and their login from the preferred_username claim. A user is the pair (realm, login): a login is unique only within its realm.

The browser holds no token: it has a session with the gateway, which attaches the user’s token to every request to subscription.

Who is who

subscription tells these callers apart, always from the token:

Caller Recognised by
Platform administrator a token from a platform realm (security.jwt.platform-realms, [mla, shared] by default) holding exactly the role ROLE_ADMIN in access_roles or realm_access.roles
MLA support member a platform administrator, or a token from the mla realm holding the role SUPPORT in access_roles or realm_access.roles
User their realm and preferred_username; their rights in a tenant (active member, administrator) are read from subscription’s database
Platform service a token from a platform realm issued to a Keycloak client listed in a caller group (security.service-callers.groups.<group>)
Shared service account a token from a platform realm issued to the internal_service_client client
The gateway, for support access a token from the shared realm issued to the svc-gateway client, a member of the support-access group

A ROLE_ADMIN role held in a client’s realm does not make a platform administrator.

What the API requires

The administration console is reserved to platform administrators. subscription applies the first rule matching the request:

Request Who may call it
OPTIONS, any path anyone
GET /actuator, /actuator/health/**, /actuator/info anyone (Kubernetes and Consul probes)
the rest of /actuator/** the services of the actuator group only (Spring Boot Admin), never a user’s token, platform administrators included
GET /v3/api-docs/**, /swagger-ui/** anyone; served only where Consul turns them on (locally and on integration)
GET /api/v1/user-tenants/{service}/{user} platform administrator, services of the user-tenants group, or the user themself for their own realm
GET /api/v1/tenant-credentials services of the tenant-credentials group only, never a user’s token, platform administrators included
GET /api/v1/user-tenants/{tenant}/{service}/{user} platform administrator, or services of the user-tenants group
GET /api/v1/tenant-status platform administrator, or services of the tenant-status group
GET /api/v1/public/clients/by-subdomain/* and …/logo anyone, without a token
GET /api/v1/tenants/{tenantId}/logo any authenticated caller, then: service account, platform administrator, or active member of the tenant
/api/v1/reglab-users/me/language any token naming a user; each reads and sets their own language
GET /api/v1/events (the live-update stream) platform administrator, or a user of the support console
/api/v1/support-access/check, /sessions/events, /sessions/*/termination the gateway alone
GET /api/v1/access-events MLA support member; except for platform administrators, limited to support access events
/api/v1/support-access/** (the rest) any authenticated caller; each operation then checks its rights (see Support access)
everything else, /api/v1/master-keys and /api/v1/security/password/generate included platform administrator

The error page of an already authorized request (a 404, say) stays an error and does not turn into a 403.

Calls from the other services

The platform’s services call subscription with their own token, obtained from Keycloak through the client credentials flow. security-library provides it (ServiceTokenClient) from the service’s application.s2s.* keys: application.s2s.client-id, application.s2s.client-secret, application.s2s.token-endpoint and application.s2s.grant-type. The token is renewed before it expires (application.s2s.expiration-margin, 60 seconds by default). A service with its own Keycloak client (svc-irrc, svc-stress…) keeps its keys in its own Vault path, which wins over the shared client’s in secret/application.

subscription grants each group of endpoints to the clients listed in its Consul configuration, security.service-callers.groups.<group>:

Group Endpoints Clients in the local stack
tenant-credentials GET /api/v1/tenant-credentials svc-irrc, svc-stress, svc-risk-engine
user-tenants GET /api/v1/user-tenants/{service}/{user} and /{tenant}/{service}/{user} svc-irrc, svc-library, svc-stress, svc-risk-engine, svc-assistant
tenant-status GET /api/v1/tenant-status svc-stress
support-access the gateway’s endpoints for support access svc-gateway
actuator /actuator/** beyond health and info svc-admin
  • While security.service-callers.legacy-shared-client is true (the default), the shared internal_service_client is admitted in every group. The first admission per group is logged, to spot the services still using it. The gateway’s support access endpoints also require the svc-gateway client of the shared realm: the shared client does not get in there.
  • A change of these groups in Consul is taken into account without a restart, at the next configuration refresh (about a minute). An invalid value (an empty group) is refused and the value in use is kept; a restart would fail on it, though.
  • The groups actually configured in the deployed environments are read in their Consul, config/subscription/data.

subscription’s outgoing calls. subscription’s code does not call the other services over HTTP. It calls:

  • Keycloak’s admin API, in each realm, with the subscription-provisioning client (application.keycloak-accounts.client-id) and that realm’s secret (application.keycloak-accounts.client-secrets.<realm>). It uses it to disable or re-enable accounts, read the sign-ins, and re-read the roles of the operator and the target of support access;
  • Kafka, with the user of spring.kafka.*; e-mails go out on notification_topic with a dedicated user (application.notification.kafka-username, application.notification.kafka-password), the only one allowed to write that topic. Without both properties, no e-mail is sent.

Tenant credentials

Each tenant has a credential, chosen when it is created (Login credentials in the tenant form), which the form no longer changes afterwards. CIRCÉ (irrc) uses it to encrypt the tenant’s data.

  • Type. Only Password (PASSWORD) is accepted: a Key (KEY) credential is refused, since no service encrypts with a key pair yet.
  • Password. It must reach application.credential.minimum-password-length characters. Generate proposes one (GET /api/v1/security/password/generate); it is shown only at that moment. subscription draws a random salt on creation.
  • Storage. The password, salt, private_key and public_key columns of tenant_credential are encrypted with the current master key (see below).
  • Reading. GET /api/v1/tenant-credentials?tenantId= returns the credential in clear to the services of the tenant-credentials group only. No front reads it, and a platform administrator’s token is refused: a stolen administrator session does not yield the keys. Every read is logged with the calling client, its realm, the tenant and the outcome, never the secret (Tenant credential read: tenant=…, caller=…, realm=…, found=…).

Master keys

subscription encrypts the tenant credentials with its own master keys (EncryptionService):

  • each value is encrypted with AES-GCM (the v2 format of VersionedAesGcmEngine); it starts with the version byte, then the id of the key that encrypted it (0 to 255);
  • each value is bound to the tenant_credential table: a value moved to another use of the same secret is rejected;
  • each key is derived from its passphrase and salt (PBKDF2, 600,000 iterations), once, on first use.

The keys are properties:

Property Role
application.credential.encrypt-password, application.credential.encrypt-salt key 0; it also reads the values written before the v2 format
application.credential.keys.<id>.password, application.credential.keys.<id>.salt the other keys, <id> from 1 to 255; a passphrase too weak stops the start-up
application.credential.current-key-id the key of every new write (0 by default); if it is not configured, subscription does not start

Re-encryption at start-up. At every start, subscription re-encrypts with the current key every value not on it (TenantCredentialReencryption). A database lock keeps this work to a single instance. A value that fails is logged and left as it is, for the next start. The log then says whether every value is on the current key, or which remain on another key.

The Master key tab. The Settings page, Master key tab, shows the same state without reading the logs (GET /api/v1/master-keys, platform administrators). The keys themselves are never shown, and the screen changes nothing: every action is done in Vault. Refresh reads the state again.

The banner gives the verdict, most serious first:

Banner Meaning What to do
“… value(s) on key …, which Vault no longer holds” values name a key no longer configured: they are unreadable put the key back in Vault under the same id, then restart subscription
“Key … still encrypts … value(s)” an old key is still in use keep it in Vault; restart subscription to re-encrypt
“Key … no longer encrypts anything” the old key is no longer used remove it from Vault; keep a copy while a database backup older than the rotation exists
“Every tenant credential is on key …” a single key configured nothing

The table gives, for each key, its Status (Current, Still in use, Can be removed, Missing from Vault) and its number of Values, plus a Pre-v2 format (key 0) row if any remain.

Rotating the master key

Rotation is manual, in Vault; subscription reads its keys only at start-up, so each step ends with a rolling restart of subscription:

  1. Add the new key (application.credential.keys.<id>.password and .salt) without changing current-key-id, then restart. Every pod then knows the key before it is used.
  2. Make the new key current (application.credential.current-key-id), then restart: the values are re-encrypted at start-up. The Master key tab must say that the old key no longer encrypts anything.
  3. Remove the old key from Vault, then restart.
  4. Keep the old key in the team vault while a database backup older than the rotation exists.

The detailed procedure, checks and rollback included, is the rotation-cle-maitre-subscription runbook of the documentation repository. The rotation changes the master key only: the tenant credentials do not change, and CIRCÉ’s data stays readable.

Public endpoints and logos

Before anyone signs in, a front reads the client its host name names:

  • GET /api/v1/public/clients/by-subdomain/{subdomain} returns the realm to sign in to, the client’s name and whether it has a logo;
  • GET /api/v1/public/clients/by-subdomain/{subdomain}/logo returns its logo.

These two endpoints are open without a token. They answer only for a client that has a subdomain and an accepted realm, and say nothing more about it; otherwise 404. Their answer may be kept 5 minutes by shared caches.

The logo of a tenant’s client (GET /api/v1/tenants/{tenantId}/logo) is reserved to the service account, platform administrators and the tenant’s active members; any other caller is refused before learning whether the tenant exists. Its answer is private, kept one hour, then revalidated by ETag. Only platform administrators upload, read by client and remove a logo (/api/v1/clients/{id}/logo).

Vault and Consul

subscription imports its configuration from Consul, then from Vault (spring.config.import: consul: then optional:vault://). A key in Vault wins over a key of the same name in Consul. Consul is mandatory: an unreachable agent stops the start-up. Vault is marked optional only for the case where it is disabled; an unreachable Vault is still governed by the fail-fast setting.

Source Path Content
Consul config/application/data, then config/subscription/data (YAML) the configuration: security.jwt.*, security.service-callers.*, application.support-access.*, Kafka, etc.
Vault, KV engine secret secret/application keys shared by every service: shared Kafka user, shared service client (application.s2s.*), keycloak.server.url
Vault secret/subscription subscription’s secrets: database login, Kafka user, master keys (application.credential.*), secrets of the subscription-provisioning clients (application.keycloak-accounts.client-secrets.<realm>)

The connection is set by environment variables: VAULT_URI, VAULT_TOKEN, VAULT_KV_BACKEND (secret by default), VAULT_AUTH_METHOD (token by default; AppRole and Kubernetes are possible with VAULT_APPROLE_ROLE_ID, VAULT_APPROLE_SECRET_ID, VAULT_K8S_ROLE, VAULT_K8S_AUTH_PATH), and for Consul CONSUL_HOST, CONSUL_PORT, CONSUL_TOKEN.