Skip to content

Commit a1e4241

Browse files
committed
bulk support for all resource types
1 parent 0d1c868 commit a1e4241

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Http/Controllers/BulkController.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace ArieTimmerman\Laravel\SCIMServer\Http\Controllers;
44

55
use ArieTimmerman\Laravel\SCIMServer\Exceptions\SCIMException;
6+
use ArieTimmerman\Laravel\SCIMServer\SCIMConfig;
67
use Illuminate\Http\Request;
78
use Illuminate\Support\Facades\Validator;
89

@@ -66,6 +67,14 @@ public function processBulkRequest(Request $request)
6667
// Remove everything till the last occurence of Bulk, e.g. /scim/v2/Bulk should become /scim/v2/
6768
$prefix = substr($originalRequest->path(), 0, strrpos($originalRequest->path(), '/Bulk'));
6869

70+
$resourceTypeConfig = resolve(SCIMConfig::class)->getConfig();
71+
$resourceTypePattern = null;
72+
73+
if (!empty($resourceTypeConfig)) {
74+
$escapedResourceTypes = array_map(static fn ($name) => preg_quote($name, '/'), array_keys($resourceTypeConfig));
75+
$resourceTypePattern = '/^\/(' . implode('|', $escapedResourceTypes) . ')(?:\/|\?|$)/';
76+
}
77+
6978
foreach ($operations as $index => $operation) {
7079

7180
$method = $operation['method'];
@@ -81,9 +90,7 @@ public function processBulkRequest(Request $request)
8190
$encoded = str_replace(array_keys($bulkIdMapping), array_values($bulkIdMapping), $encoded);
8291
$path = str_replace(array_keys($bulkIdMapping), array_values($bulkIdMapping), $operation['path']);
8392

84-
// TODO: Allow BULK requests for all configured resource types (RFC 7644 §3.7).
85-
// ensure $path starts with /Users or /Groups
86-
if (!preg_match('/^\/(Users|Groups)/', $path)) {
93+
if ($resourceTypePattern === null || !preg_match($resourceTypePattern, $path)) {
8794
throw (new SCIMException('Invalid path!'))->setCode(400)->setScimType('invalidPath');
8895
}
8996

0 commit comments

Comments
 (0)