Repository navigation
Conversation
|
Outside contributor here; we run a custom CIMD provider on 26.6.4 and reached the same conclusion about where this belongs, so a data point in favour of the placement. We first went looking for this in the client-registration policies, since a max-clients policy already exists there for RFC 7591. That cannot work for CIMD: Two questions on the semantics: 1. 2. The limit is a factory-global, so every realm on the server shares one number. Would this be better on the executor's client-profile |
|
@tnorimat : Thanks for the PR! When you get a chance, could you please rebase/resolve conflicts? |
|
Picking up my earlier comment — and I'd read your note on 48116 about the counting query You cited DCR as the precedent, and I think that's right. It also answers placement, the The bit missing from both threads: One deployment note: a factory-global SPI option isn't realm state, so declarative |
|
A follow-up to my comment above, because I think one part of it pointed the wrong way, based on what we ran into since. I suggested the existing This PR has the same shape:
A suggestion that leaves the policy to the operator: let them choose what the limit counts (the whole realm, as now, or only clients CIMD created) and set it per realm. A CIMD-only count needs no new marker: Prepared with AI assistance; the code paths above were checked against current |
There was a problem hiding this comment.
🟡 Changes recommended
Non-atomic quota checks and client persistence allow concurrent authorization requests to exceed the realm’s client cap.
2 open issues
What changed in this PR
This PR adds a client-count limit intended to curb uncontrolled CIMD client persistence. It checks the realm’s total client count before creating a new CIMD client, using a server-wide provider setting.
Changes:
- Adds
max-clientsconfiguration with a default of 1,000. - Rejects new CIMD client creation when the realm reaches the limit.
- Adds an integration test for rejection at capacity.
| File | Description |
|---|---|
tests/base/src/test/java/org/keycloak/tests/client/policies/ClientIdMetadataDocumentTest.java |
Configures a test limit and verifies rejection at capacity. |
services/src/main/java/org/keycloak/protocol/oauth2/cimd/clientpolicy/executor/ClientIdMetadataDocumentExecutorFactoryProviderConfig.java |
Loads the limit and defines its default value. |
services/src/main/java/org/keycloak/protocol/oauth2/cimd/clientpolicy/executor/AbstractClientIdMetadataDocumentExecutorFactory.java |
Exposes metadata for the max-clients provider option. |
services/src/main/java/org/keycloak/protocol/oauth2/cimd/clientpolicy/executor/AbstractClientIdMetadataDocumentExecutor.java |
Checks the realm’s client count before CIMD client creation. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent client creation can still exceed the realm’s client cap because quota checks cannot see other transactions’ uncommitted inserts, requiring cross-node serialization through transaction completion and a regression test.
1 open issue
2 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The client cap can still be exceeded under MySQL/MariaDB REPEATABLE READ because the separate-connection lock does not refresh the request’s existing transaction snapshot.
3 open issues
1 resolved since last review
Review effort: Balanced
closes keycloak#48116 Signed-off-by: Takashi Norim 8BD0 atsu <takashi.norimatsu.ws@hitachi.com>
c6dde07 to
bfc5072
Compare


closes #48116