Skip to content

Commit 2b319ed

Browse files
authored
Fix SCIM startIndex parsing (#2105)
1 parent 4e812b4 commit 2b319ed

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

scim/views.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ def post(self, request, *args, **kwargs): # noqa: ARG002
172172
msg = "Invalid schema uri. Must be SearchRequest."
173173
raise exceptions.BadRequestError(msg)
174174

175-
start = body.get("startIndex", 1)
176-
count = body.get("count", 50)
175+
# cast to ints because scim-for-keycloak sends strings
176+
start = int(body.get("startIndex", 1))
177+
count = int(body.get("count", 50))
177178
sort_by = body.get("sortBy", "id")
178179
sort_order = body.get("sortOrder", "ascending")
179180
query = body.get("filter", None)

scim/views_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,12 @@ def _sort(user):
471471
{
472472
"schemas": [djs_constants.SchemaURI.SERACH_REQUEST],
473473
"filter": " OR ".join([f'email EQ "{email}"' for email in emails]),
474-
"startIndex": start_index + 1, # SCIM API is 1-based index
474+
# SCIM API is 1-based index
475+
# Additionally, scim-for-keycloak sends this as a string, but spec examples have ints
476+
"startIndex": str(start_index + 1),
475477
**({"sortBy": sort_by} if sort_by is not None else {}),
476478
**({"sortOrder": sort_order} if sort_order is not None else {}),
477-
**({"count": count} if count is not None else {}),
479+
**({"count": str(count)} if count is not None else {}),
478480
}
479481
),
480482
)

0 commit comments

Comments
 (0)