mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 20:47:32 +00:00
fix: scim user query endpoint don't allow SortBy custom field (#9235)
# Which Problems Are Solved - scim list users endpoint (`GET /scim/v2/{orgId}/Users`): handle unsupported `SortBy` columns correctly # How the Problems Are Solved - throw an error if sorting by an unsupported column is requested # Additional Context Part of #8140
This commit is contained in:
@@ -93,6 +93,14 @@ func TestListUser(t *testing.T) {
|
|||||||
wantErr: true,
|
wantErr: true,
|
||||||
errorType: "invalidValue",
|
errorType: "invalidValue",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "custom sort field",
|
||||||
|
req: &scim.ListRequest{
|
||||||
|
SortBy: gu.Ptr("externalid"),
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
errorType: "invalidValue",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "unknown filter field",
|
name: "unknown filter field",
|
||||||
req: &scim.ListRequest{
|
req: &scim.ListRequest{
|
||||||
|
@@ -118,7 +118,7 @@ func (r *ListRequest) toSearchRequest(defaultSortCol query.Column, fieldPathColu
|
|||||||
if r.SortBy == "" {
|
if r.SortBy == "" {
|
||||||
// set a default sort to ensure consistent results
|
// set a default sort to ensure consistent results
|
||||||
sr.SortingColumn = defaultSortCol
|
sr.SortingColumn = defaultSortCol
|
||||||
} else if sortCol, err := fieldPathColumnMapping.Resolve(r.SortBy); err != nil {
|
} else if sortCol, err := fieldPathColumnMapping.Resolve(r.SortBy); err != nil || sortCol.FieldType == filter.FieldTypeCustom {
|
||||||
return sr, serrors.ThrowInvalidValue(zerrors.ThrowInvalidArgument(err, "SCIM-SRT1", "SortBy field is unknown or not supported"))
|
return sr, serrors.ThrowInvalidValue(zerrors.ThrowInvalidArgument(err, "SCIM-SRT1", "SortBy field is unknown or not supported"))
|
||||||
} else {
|
} else {
|
||||||
sr.SortingColumn = sortCol.Column
|
sr.SortingColumn = sortCol.Column
|
||||||
|
Reference in New Issue
Block a user