From plans to rights
This page explains, for technical readers, how the plans a user holds in a tenant become rights in the platform’s other services: the question those services ask subscription, the token they ask it with, how they remember the answer, and the UPDATE_PLAN event that tells them to forget it.
The principle
subscription does not push rights to the services: each service asks for them.
- A user calls a service (CIRCÉ, the assistant…) with their Keycloak token and names the tenant in the
X-TENANT-IDheader. - The service asks subscription for this user’s access, in this tenant, for this service:
GET /api/v1/user-tenants/{tenantId}/{serviceName}/{userName}?realm=…, with its own service token. - subscription answers the plan the user holds for this service, with its features, and their role in the tenant; or
404if they hold none that grants access. - The service decides: the user is a member if the plan carries the expected feature (
basefor CIRCÉ,assistantfor the assistant); each screen or action then checks its own feature. - The service remembers the answer for a few minutes. When a right changes, subscription publishes
UPDATE_PLANso that the services forget it.
What the lookup answers
The GET /api/v1/user-tenants/{tenantId}/{serviceName}/{userName} endpoint looks up the user’s access to the tenant for the service:
{tenantId}is the tenant’s public id (tenantId), the same as in theX-TENANT-IDheader;{serviceName}is the service’s name, compared ignoring case (irrc,stress,library…);{userName}is the user’s login, and therealmparameter the realm that issued their token. Withoutrealm, subscription takes the default realm (application.identity.default-realm); a realm subscription does not accept is a400error.
subscription answers an access only when all these conditions hold:
| Condition | Otherwise |
|---|---|
| The user holds a plan of the service in the tenant. | 404 |
| Their access to the tenant is not suspended. | 404 |
| Their account is not disabled. | 404 |
The tenant is ACTIVE. |
404 |
| Now is within the tenant’s validity window (start included, end excluded). | 404 |
The validity is compared at each lookup: a contract that reaches its end closes access with no action and no message.
The answer holds the access’s id, the user, the tenant (without its status or dates), the plan with its features, and the user’s role in the tenant (MEMBER or ADMIN). Since a user holds at most one plan per service in a tenant, there is at most one answer.
A second endpoint, GET /api/v1/user-tenants/{serviceName}/{userName}?realm=…, returns the user’s accesses to the service in every tenant that grants access, under the same conditions (404 when there is none). CIRCÉ uses it to list the tenants a user may name.
Who may ask subscription
The services ask subscription with their own token: a client credentials token issued by a platform realm (mla or shared by default, security.jwt.platform-realms). A token issued by a client’s realm is never a service token.
| Endpoint | Callers admitted |
|---|---|
GET /api/v1/user-tenants/{tenantId}/{serviceName}/{userName} |
platform administrators; the services of the user-tenants group |
GET /api/v1/user-tenants/{serviceName}/{userName} |
the same, and the user themself, for their own name and in their own realm |
A service belongs to the user-tenants group when the Keycloak client of its token is listed in security.service-callers.groups.user-tenants. While security.service-callers.legacy-shared-client is true (the default), the shared internal_service_client is admitted too.
On the services’ side:
- CIRCÉ (
irrc) calls subscription through a Feign client namedsubscription, found through service discovery; - the assistant calls subscription with security-library’s
ServiceTokenClient(application.s2s.*), whose credentials come from Vault’s shared application secret.
The X-TENANT-ID header and tenant-web-library
A call to a multi-tenant service names its tenant in the X-TENANT-ID header, which carries the tenant’s public id. The shared tenant-web-library provides the filter that reads it and checks the caller’s membership; the assistant uses it. CIRCÉ has its own filter, which follows the same rules (see CIRCÉ).
tenant-web-library’s filter (TenantBindingFilter) runs after the Spring Security chain, on the covered paths (/api/** by default, minus the excluded paths):
- It reads
X-TENANT-ID. A missing or blank header is refused with a400(error.tenant.missing), and so is a value that is not a canonical UUID (error.tenant.invalid). In single-tenant mode, the header is ignored and the configured tenant is used. - It asks the service whether the caller is a member of the tenant (
TenantMembershipVerifier, which each service provides). An anonymous caller or a non-member gets a403(error.tenant.forbidden), the same for an unknown tenant and a forbidden one. A lookup that fails gives a500(error.tenant.lookup-failed) and lets nothing through. A caller the service declares trusted (TrustedCallerPolicy) goes through unchecked; by default, nobody. - It runs the request in the tenant, which it also puts in the logging context.
On a path declared with an optional tenant (optional-tenant-paths), a request without the header runs with no tenant.
The membership cache
The filter keeps the answers in a cache (TenantMembershipCache), by tenant, realm and user name:
| Property | Default | Purpose |
|---|---|---|
reglab.tenant.membership-cache.positive-ttl |
5m |
How long a membership is trusted: what bounds the access a removed user keeps if the eviction is lost. |
reglab.tenant.membership-cache.negative-ttl |
30s |
How long a refusal is trusted: what a user who has just been given access may have to wait. |
reglab.tenant.membership-cache.maximum-size |
10000 |
The maximum number of answers kept. |
Concurrent calls for the same key wait for a single lookup; an error is never kept. The service empties the cache with evict(tenant), evict(tenant, callerName) or evictAll(), in particular when it receives UPDATE_PLAN.
CIRCÉ (irrc)
CIRCÉ asks for the accesses of the irrc service.
- Membership. A user is a member of a tenant if subscription answers them an
irrcplan that carries thebasefeature. - Tenant admin. The
ADMINrole of the answer makes the user the administrator of that tenant in CIRCÉ, whatever their role in their other tenants. - Features. The screens tied to an offer also ask for a feature of the plan; a member whose plan lacks it gets a
403(see The feature names that are read). - Cache. CIRCÉ keeps each answer 5 minutes, and a refusal 30 seconds; these durations are set in its code (
CacheConfiguration). Each instance has its own cache. - Service accounts. The services of the
internalgroup (on the/api/v1/internal/**routes only) go through without a lookup.
The assistant
The assistant opens to a user in a tenant if their plan, in that tenant, of one of the services of application.subscription.plan-services (irrc, stress and library by default) carries the assistant feature (compared ignoring case). It offers an application’s tools only if that application’s plan opens the assistant.
- The assistant asks for each of these services, with the realm of the user’s token; a token that names no realm makes no member.
- It keeps the features of each plan, by tenant, realm, user and service: for
membership-cache-ttl(one hour by default) when they open the assistant, for tenant-web-library’snegative-ttl(30 seconds by default) otherwise. - tenant-web-library’s filter keeps its own answer too: a membership for
membership-cache-ttl, a refusal for thenegative-ttl. - No caller is trusted: the assistant always acts for a user.
The UPDATE_PLAN event
When a right changes, subscription publishes a message on the Kafka topic subscription_irrc_topic:
{"tenantId": "<public id of the tenant>", "messageType": "UPDATE_PLAN", "schemaVersion": 1}- The message names a tenant, never a user; its Kafka key is the
tenantId, which keeps one tenant’s messages in order. The fields are read by name: they are part of the contract between services. - It leaves inside the change’s transaction, once the change is written, and subscription waits for the broker’s acknowledgement (timeout
application.kafka.send-timeout). A failed send rolls the change back and fails the request: a right taken away is never recorded without the services being told. - The message leaves just before the transaction commits: a lookup made in those few milliseconds still reads the old right and keeps it until it expires.
On receipt:
- CIRCÉ (
MembershipConsumer) forgets the memberships and refusals kept for that tenant; a message without a readable tenant empties the whole cache. Each instance reads every message, in a consumer group of its own (irrc-membership-<uuid>). - The assistant (
MembershipConsumer) forgets the plans kept for that tenant, then the filter’s memberships; a message without a readable tenant empties both caches. Each instance has its own group (assistant-membership-<uuid>) and starts from the latest message; an unreadable message goes tosubscription_irrc_topic.DLT.
An instance without a broker, or one that has not joined its group yet, reads nothing: only the caches’ expiry then applies.
When subscription sends UPDATE_PLAN
| Change | Where it comes from in the console |
|---|---|
A user’s role and plans in a tenant are replaced (PUT /api/v1/tenants/{id}/members/{userId}) |
the form of a user’s access to a tenant |
An access’s plan or role changes (PUT /api/v1/user-tenants/{id}) |
— |
A plan is taken away from a user (DELETE /api/v1/user-tenants/{id}); the last plan takes the user out of the tenant |
— |
A user is taken out of a tenant (DELETE /api/v1/tenants/{id}/members/{userId}) |
Remove from the tenant |
| A user stops being a guest of a client: they are taken out of every tenant of that client | a user’s Guest clients card |
| A user’s access to a tenant is suspended or reactivated | Suspend access, Reactivate access |
| A user is disabled or enabled: one message per tenant where they hold a plan | Users |
| A tenant’s status or validity changes: suspension, reactivation, validity window, scheduled deletion, restore, purge | Client and Tenants |
On a purge, subscription also publishes TENANT_DELETED on tenant_lifecycle_topic (see The tenant lifecycle).
Nothing is sent when the change changes nothing: suspending an access already suspended, reactivating an active access, taking out of a tenant a user who holds nothing there.
What subscription does not announce
In these cases, no UPDATE_PLAN leaves: only the expiry of the services’ caches applies.
| Change | Effect in the services |
|---|---|
| A plan’s definition changes: its features, its service, its name (Plans page) | The services apply the former definition until their cache expires: up to 5 minutes for CIRCÉ; for the assistant, assistant taken off a plan stays open up to membership-cache-ttl (one hour by default). The plan’s holders receive an e-mail. |
| A feature is renamed (Features page) | As for a changed plan. |
An access is created on its own (POST /api/v1/user-tenants) |
The right gained waits for the kept refusal to expire: up to 30 seconds. The console’s access form goes through the replacement, which sends the message. |
A right taken away through the console is announced; a right gained that is not announced only waits for a refusal to expire (30 seconds). A change to the catalogue (plans, features) is what can leave a removed right active the longest.
The delays in short
| Situation | CIRCÉ | Assistant |
|---|---|---|
Right taken away, UPDATE_PLAN received |
at the next request | at the next request |
Right taken away, UPDATE_PLAN lost |
5 minutes at most | membership-cache-ttl at most (one hour by default) |
Right given after a kept refusal, no UPDATE_PLAN |
30 seconds at most | negative-ttl at most (30 seconds by default) |
| Tenant’s contract ended | once the kept answer expires (5 minutes at most) | once the kept answer expires |
CIRCÉ’s durations are set in its code; the assistant’s are properties, served by Consul.
The feature names that are read
A feature opens something only if a service reads its name. The names read today:
| Feature | Plan of the service | What it opens |
|---|---|---|
base |
any service | Membership of the service; in CIRCÉ, access to the tenant. |
anacredit |
irrc |
CIRCÉ’s AnaCredit screens. |
pilar3 |
irrc |
CIRCÉ’s Pillar 3 screens. |
ste |
irrc |
The ECB STE packages (SREP) and their controls. |
stress |
irrc |
CIRCÉ’s stress tests. |
generate-dpm |
irrc |
Generating XBRL-CSV packages from a workbook. |
mcp |
irrc |
CIRCÉ’s MCP tools for an MCP client. |
assistant |
irrc |
CIRCÉ’s MCP tools when the assistant calls for the user. |
assistant |
irrc, stress or library |
The assistant itself, and that application’s tools in the assistant. |
CIRCÉ compares the names as they are; the assistant compares them ignoring case.