1515use ArieTimmerman \Laravel \SCIMServer \Events \Patch ;
1616use ArieTimmerman \Laravel \SCIMServer \Parser \Parser as ParserParser ;
1717use ArieTimmerman \Laravel \SCIMServer \PolicyDecisionPoint ;
18+ use ArieTimmerman \Laravel \SCIMServer \Tests \Model \User ;
1819use Illuminate \Contracts \Pagination \CursorPaginator ;
1920use Illuminate \Database \Eloquent \Builder ;
2021use Illuminate \Support \Facades \Validator ;
@@ -274,14 +275,20 @@ function (Builder $query) use ($filter, $resourceType) {
274275 }
275276
276277 // TODO: splitting the attributes parameters by dot and comma is not correct, but works in most cases
277- $ attributes = $ request ->input ('attributes ' ) ? preg_split ('/[,.]/ ' , $ request ->input ('attributes ' )) : [];
278+ // if body contains attributes and this is an array, use that, else use existing
279+ if ($ request ->json ('attributes ' ) && is_array ($ request ->json ('attributes ' ))){
280+ $ attributes = $ request ->json ('attributes ' );
281+ } else {
282+ $ attributes = $ request ->input ('attributes ' ) ? preg_split ('/[,.]/ ' , $ request ->input ('attributes ' )) : [];
283+ }
278284
279285 if (!empty ($ attributes )) {
280286 $ attributes [] = 'id ' ;
281287 $ attributes [] = 'meta ' ;
282288 $ attributes [] = 'schemas ' ;
283289 }
284290
291+ // TODO: implement excludedAttributes
285292 $ excludedAttributes = [];
286293
287294 return new ListResponse (
@@ -295,4 +302,19 @@ function (Builder $query) use ($filter, $resourceType) {
295302 ($ resourceObjects instanceof CursorPaginator) ? $ resourceObjects ->previousCursor ()?->encode() : null
296303 );
297304 }
305+
306+ public function search (Request $ request , PolicyDecisionPoint $ pdp , ResourceType $ resourceType ){
307+
308+ $ input = $ request ->json ()->all ();
309+
310+ // ensure request post body is a scim SearchRequest
311+ if (!is_array ($ input ) || !isset ($ input ['schemas ' ]) || !in_array ("urn:ietf:params:scim:api:messages:2.0:SearchRequest " , $ input ['schemas ' ])) {
312+ throw (new SCIMException ('Invalid schema. MUST be "urn:ietf:params:scim:api:messages:2.0:SearchRequest" ' ))->setCode (400 );
313+ }
314+
315+ // ensure $request->input reads from payload/post only, not query parameters
316+ $ request ->replace ($ request ->json ()->all ());
317+
318+ return $ this ->index ($ request , $ pdp , $ resourceType );
319+ }
298320}
0 commit comments