-
Notifications
You must be signed in to change notification settings - Fork 8.7k
SCIM: PATCH operations list has no size limit — missing maxOperations… #50872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,13 @@ | |
|
|
||
| public abstract class AbstractScimResourceTypeProvider<M extends Model, R extends ResourceTypeRepresentation> implements ScimResourceTypeProvider<R> { | ||
|
|
||
| /** | ||
| * Maximum number of operations allowed in a single SCIM PATCH request. | ||
| * Exceeding this limit results in a {@code 400 Bad Request} with {@code scimType=tooMany}. | ||
| * This limit is not advertised via {@code /ServiceProviderConfig}. | ||
| */ | ||
| public static final int MAX_PATCH_OPERATIONS = 100; | ||
|
|
||
| protected final KeycloakSession session; | ||
| private final ModelSchema<M, R> schema; | ||
| private final List<ModelSchema<M, R>> schemaExtensions; | ||
|
|
@@ -107,6 +114,12 @@ public boolean delete(String id) { | |
| public void patch(R existing, List<PatchOperation> operations) { | ||
| Objects.requireNonNull(existing, "existing cannot be null"); | ||
| Objects.requireNonNull(operations, "operations cannot be null"); | ||
|
|
||
| if (operations.size() > MAX_PATCH_OPERATIONS) { | ||
| throw new ScimPatchException( | ||
| "PATCH request exceeds maximum allowed number of %d operations".formatted(MAX_PATCH_OPERATIONS)); | ||
|
Comment on lines
+118
to
+120
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The issue does mention bounding member/value arrays, so it's a legitimate gap in the PR. However, I would say this is a separate concern from the top-level operation count and could be addressed in a follow-up. Raising it as a suggestion for a separate PR is fair, blocking this PR on it seems a bit excessive.
Comment on lines
+118
to
+120
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not an issue, every patch-capable provider extends the same abstract class and future providers (if any) will follow the same pattern |
||
| } | ||
|
|
||
| M model = getModel(existing.getId()); | ||
|
|
||
| if (!hasPermission(model, getRealmResourceType(), AdminPermissionsSchema.MANAGE)) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Copyright 2026 Red Hat, Inc. and/or its affiliates | ||
| * and other contributors as indicated by the @author tags. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.keycloak.scim.resource.spi; | ||
|
|
||
| /** | ||
| * Exception thrown when a PATCH request exceeds the maximum allowed number of operations. | ||
| */ | ||
| public class ScimPatchException extends RuntimeException { | ||
|
|
||
| public ScimPatchException(String message) { | ||
| super(message); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martin-kanis I think this is a valid point: the
/ServiceProviderConfigendpoint will advertisemaxOperations: 0(meaning "no limit" or "not supported" depending on interpretation) while the server actually enforces 100. These should be consistent. We do something very similar for the filter'smaxResultsconfig. The value that is enforced is returned in theServiceProviderConfigeven if filtering is disabled.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After further reviewing, I think this is not a valid suggestion. Mixing bulk parameters with patch in the provider config is semantically wrong. There's nothing in the RFC that suggests patch should advertise its max operations constraint via the standard
ServiceProviderConfig.