1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
|
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
namespace SCIM\services;
use API as APIRPC;
use APIException;
use CAuthenticationHelper;
use CApiInputValidator;
use CProvisioning;
use DB;
use SCIM\ScimApiService;
class Group extends ScimApiService {
public const SCIM_SCHEMA = 'urn:ietf:params:scim:schemas:core:2.0:Group';
/**
* Return all groups information.
* When filter 'id' or 'displayName' is defined will return information for single group.
* If group not found, for filter 'id', will return ZBX_API_ERROR_NO_ENTITY error.
*
* @param array $options
* @param string $options['id'] (optional) SCIM group id.
* @param string $options['displayName'] (optional) SCIM group display name.
*
* @return array Array of groups data when no filters are defined. Single group data for defined filter.
*/
public function get(array $options = []): array {
$this->validateGet($options);
if (array_key_exists('id', $options)) {
$db_scim_group = DB::select('scim_group', [
'output' => ['name'],
'scim_groupids' => $options['id']
]);
if (!$db_scim_group) {
self::exception(ZBX_API_ERROR_NO_ENTITY, 'No permissions to referred object or it does not exist!');
}
$users = $this->getUsersByGroupIds([$options['id']]);
return [
'id' => $options['id'],
'displayName' => $db_scim_group[0]['name'],
'users' => $users[$options['id']]
];
}
if (array_key_exists('displayName', $options)) {
$db_scim_group = DB::select('scim_group', [
'output' => ['name', 'scim_groupid'],
'filter' => ['name' => $options['displayName']]
]);
if (!$db_scim_group) {
return [];
}
$users = $this->getUsersByGroupIds([$db_scim_group[0]['scim_groupid']]);
return [
'id' => $db_scim_group[0]['scim_groupid'],
'displayName' => $db_scim_group[0]['name'],
'users' => $users
];
}
$db_scim_groups = DB::select('scim_group', [
'output' => ['name'],
'preservekeys' => true
]);
if ($db_scim_groups) {
$groups_users = $this->getUsersByGroupIds(array_keys($db_scim_groups));
foreach ($groups_users as $groupid => $users) {
$db_scim_groups[$groupid]['users'] = $users;
}
}
return $db_scim_groups;
}
/**
* @param array $options
*
* @throws APIException if input is invalid.
*/
private function validateGet(array &$options): void {
$api_input_rules = ['type' => API_OBJECT, 'fields' => [
'displayName' => ['type' => API_STRING_UTF8],
'id' => ['type' => API_ID],
'startIndex' => ['type' => API_INT32, 'default' => 1],
'count' => ['type' => API_INT32, 'default' => 100]
]];
if (!CApiInputValidator::validate($api_input_rules, $options, '/', $error)) {
self::exception(ZBX_API_ERROR_PARAMETERS, $error);
}
}
/**
* Create group, assign users to new group when 'members' is passed in request.
*
* @param array $options
* @param string $options['displayName'] SCIM group name.
* @param array $options['members'] Array with SCIM group members.
* @param string $options['members'][]['value'] Userid.
*
* @return array Array with data for created group.
*/
public function post(array $options): array {
$this->validatePost($options);
$db_scim_groups = DB::select('scim_group', [
'output' => ['scim_groupid'],
'filter' => ['name' => $options['displayName']]
]);
if ($db_scim_groups) {
$options['id'] = $db_scim_groups[0]['scim_groupid'];
return $this->put($options);
}
[$scim_groupid] = DB::insert('scim_group', [['name' => $options['displayName']]]);
if (!$scim_groupid) {
self::exception(ZBX_API_ERROR_INTERNAL, 'Cannot create group '.$options['displayName'].'.');
}
$group = [
'id' => $scim_groupid,
'displayName' => $options['displayName'],
'users' => []
];
if (array_key_exists('members', $options) && $options['members'] != []) {
$userdirectoryid = CAuthenticationHelper::getSamlUserdirectoryidForScim();
$scim_group_members = array_column($options['members'], 'value');
$group['users'] = $this->verifyUserids($scim_group_members, $userdirectoryid);
foreach ($scim_group_members as $memberid) {
$user_group = DB::insert('user_scim_group', [[
'userid' => $memberid,
'scim_groupid' => $scim_groupid
]]);
if (!$user_group) {
self::exception(ZBX_API_ERROR_INTERNAL,
'Cannot add user '.$memberid.' to group '.$options['displayName'].'.'
);
}
$this->updateProvisionedUserGroups($memberid, $userdirectoryid);
}
}
return $group;
}
/**
* @param array $options
*
* @throws APIException if input is invalid.
*/
private function validatePost(array $options): void {
$api_input_rules = ['type' => API_OBJECT, 'flags' => API_REQUIRED | API_ALLOW_UNEXPECTED, 'fields' => [
'schemas' => ['type' => API_STRINGS_UTF8, 'flags' => API_REQUIRED | API_NOT_EMPTY],
'displayName' => ['type' => API_STRING_UTF8, 'flags' => API_REQUIRED | API_NOT_EMPTY],
'members' => ['type' => API_OBJECTS, 'fields' => [
'display' => ['type' => API_STRING_UTF8, 'flags' => API_REQUIRED | API_NOT_EMPTY],
'value' => ['type' => API_ID, 'flags' => API_REQUIRED]
]]
]];
if (!CApiInputValidator::validate($api_input_rules, $options, '/', $error)) {
self::exception(ZBX_API_ERROR_PARAMETERS, $error);
}
if (!in_array(self::SCIM_SCHEMA, $options['schemas'], true)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'Incorrect schema was sent in the request.');
}
}
/**
* Receives new information on the SCIM group and its members. Updates 'user_scim_group' table, updates users'
* user groups mapping based on the remaining SCIM groups and SAML settings.
*
* @param array $options
* @param string $options['id'] SCIM group id.
* @param array $options['members'] Array with SCIM group members.
* @param string $options['members'][]['value'] Userid.
*
* @return array Array with data for updated group.
*/
public function put(array $options): array {
$this->validatePut($options);
$db_scim_groups = DB::select('scim_group', [
'output' => ['name'],
'scim_groupids' => $options['id']
]);
if (!$db_scim_groups) {
self::exception(ZBX_API_ERROR_NO_ENTITY, 'No permissions to referred object or it does not exist!');
}
$db_scim_group = $db_scim_groups[0];
if ($options['displayName'] !== $db_scim_group['name']) {
$scim_groupid = DB::update('scim_group', [
'values' => ['name' => $options['displayName']],
'where' => ['scim_groupid' => $options['id']]
]);
if (!$scim_groupid) {
self::exception(ZBX_API_ERROR_INTERNAL,
'Cannot update group '.$db_scim_group['name'].' to group '.$options['displayName'].'.'
);
}
$db_scim_group['name'] = $options['displayName'];
}
$userdirectoryid = CAuthenticationHelper::getSamlUserdirectoryidForScim();
$scim_group_members = array_column($options['members'], 'value');
$this->verifyUserids($scim_group_members, $userdirectoryid);
$db_scim_group_members = DB::select('user_scim_group', [
'output' => ['userid'],
'filter' => ['scim_groupid' => $options['id']]
]);
$users_to_add = array_diff($scim_group_members, array_column($db_scim_group_members, 'userid'));
$users_to_remove = array_diff(array_column($db_scim_group_members, 'userid'), $scim_group_members);
if($users_to_add) {
foreach ($users_to_add as $userid) {
$scim_user_group = DB::insert('user_scim_group', [[
'userid' => $userid,
'scim_groupid' => $options['id']
]]);
if (!$scim_user_group) {
self::exception(ZBX_API_ERROR_INTERNAL,
'Cannot add user '.$userid.' to group '.$options['displayName'].'.'
);
}
$this->updateProvisionedUserGroups($userid, $userdirectoryid);
}
}
if ($users_to_remove) {
DB::delete('user_scim_group', [
'userid' => array_values($users_to_remove),
'scim_groupid' => $options['id']
]);
foreach ($users_to_remove as $userid) {
$this->updateProvisionedUserGroups($userid, $userdirectoryid);
}
}
$db_users = APIRPC::User()->get([
'output' => ['userid', 'username'],
'userids' => $scim_group_members,
'filter' => ['userdirectoryid' => $userdirectoryid]
]);
return [
'id' => $options['id'],
'displayName' => $db_scim_group['name'],
'users' => $db_users
];
}
/**
* @param array $options
*
* @throws APIException if input is invalid.
*/
private function validatePut($options) {
$api_input_rules = ['type' => API_OBJECT, 'flags' => API_REQUIRED | API_ALLOW_UNEXPECTED, 'fields' => [
'schemas' => ['type' => API_STRINGS_UTF8, 'flags' => API_REQUIRED | API_NOT_EMPTY],
'id' => ['type' => API_ID, 'flags' => API_REQUIRED],
'displayName' => ['type' => API_STRING_UTF8, 'flags' => API_REQUIRED | API_NOT_EMPTY],
'members' => ['type' => API_OBJECTS, 'flags' => API_REQUIRED, 'fields' => [
'display' => ['type' => API_STRING_UTF8, 'flags' => API_REQUIRED | API_NOT_EMPTY],
'value' => ['type' => API_ID, 'flags' => API_REQUIRED]
]]
]];
if (!CApiInputValidator::validate($api_input_rules, $options, '/', $error)) {
self::exception(ZBX_API_ERROR_PARAMETERS, $error);
}
if (!in_array(self::SCIM_SCHEMA, $options['schemas'], true)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'Incorrect schema was sent in the request.');
}
}
/**
* Receives new information on the SCIM group members. Updates 'user_scim_group' table, updates users'
* user groups mapping based on the remaining SCIM groups and SAML settings.
*
* @param array $options
* @param string $options['id'] SCIM group id.
* @param array $options['Operations'] List of operations that need to be performed.
* @param string $options['Operations'][]['op'] Operation that needs to be performed -'add',
* 'replace', 'remove'.
* @param string $options['Operations'][]['path'] On what operation should be performed, filters are
* not supported, only 'members' path is supported.
* @param array $options['Operations'][]['value'] Array of values on which operation should be
* performed. If operation is 'remove' this can be
* omitted, in this case all members should be removed.
* @param string $options['Operations'][]['value'][]['value'] User id on which operation should be performed.
*
* @return array Array with data for updated group.
*
* @throws APIException
*/
public function patch(array $options): array {
$this->validatePatch($options);
$db_scim_groups = DB::select('scim_group', [
'output' => ['name'],
'scim_groupids' => $options['id']
]);
if (!$db_scim_groups) {
self::exception(ZBX_API_ERROR_NO_ENTITY, 'No permissions to referred object or it does not exist!');
}
$db_users = [];
$db_users_delete = [];
$new_userids = [];
$del_userids = [];
$do_replace = false;
$userdirectoryid = CAuthenticationHelper::getSamlUserdirectoryidForScim();
foreach ($options['Operations'] as $operation) {
if ($operation['path'] === 'displayName') {
$scim_groupid = DB::update('scim_group', [
'values' => ['name' => $operation['value']],
'where' => ['scim_groupid' => $options['id']]
]);
if (!$scim_groupid) {
self::exception(ZBX_API_ERROR_INTERNAL,
'Cannot update group '.$db_scim_groups[0]['name'].' to group '.$operation['value'].'.'
);
}
$db_scim_groups[0]['name'] = $operation['value'];
}
else if ($operation['path'] === 'members') {
switch ($operation['op']) {
case 'add':
$new_userids = array_merge($new_userids, array_column($operation['value'], 'value'));
break;
case 'remove':
if (!$do_replace) {
if (array_key_exists('value', $operation)) {
$del_userids = array_merge($del_userids, array_column($operation['value'], 'value'));
}
if (!$del_userids) {
// Empty 'value' array for 'remove' operation should act as 'replace' operation.
$do_replace = true;
}
}
break;
case 'replace':
$new_userids = array_merge($new_userids, array_column($operation['value'], 'value'));
$do_replace = true;
break;
}
}
}
if ($new_userids || $del_userids) {
$new_userids = array_diff($new_userids, $del_userids);
if (!$do_replace && $new_userids) {
$db_userids = DB::select('user_scim_group', [
'output' => ['userid'],
'filter' => ['scim_groupid' => $options['id']]
]);
$new_userids = array_diff($new_userids, array_column($db_userids, 'userid'));
}
$db_users = $this->verifyUserids($new_userids, $userdirectoryid);
$db_users_delete = $this->verifyUserids($del_userids, $userdirectoryid);
}
if ($do_replace) {
DB::delete('user_scim_group', ['scim_groupid' => $options['id']]);
}
else if ($del_userids) {
DB::delete('user_scim_group', ['userid' => $del_userids, 'scim_groupid' => $options['id']]);
}
if ($new_userids) {
$values = [];
foreach ($new_userids as $userid) {
$values[] = [
'userid' => $userid,
'scim_groupid' => $options['id']
];
}
DB::insertBatch('user_scim_group', $values);
}
foreach (array_column(array_merge($db_users, $db_users_delete), 'userid') as $db_userid) {
$this->updateProvisionedUserGroups($db_userid, $userdirectoryid);
}
return [
'id' => $options['id'],
'displayName' => $db_scim_groups[0]['name'],
'users' => $db_users
];
}
/**
* @param array $options
*
* @throws APIException if input is invalid.
*/
private function validatePatch(array &$options): void {
$api_input_rules = ['type' => API_OBJECT, 'flags' => API_REQUIRED | API_ALLOW_UNEXPECTED, 'fields' => [
'id' => ['type' => API_ID, 'flags' => API_REQUIRED],
'schemas' => ['type' => API_STRINGS_UTF8, 'flags' => API_REQUIRED | API_NOT_EMPTY],
'Operations' => ['type' => API_OBJECTS, 'flags' => API_REQUIRED | API_NOT_EMPTY | API_ALLOW_UNEXPECTED, 'fields' => [
'path' => ['type' => API_STRING_UTF8, 'flags' => API_REQUIRED, 'in' => implode(',', ['members', 'externalId', 'displayName'])],
'op' => ['type' => API_MULTIPLE, 'rules' => [
['if' => ['field' => 'path', 'in' => 'displayName'], 'type' => API_STRING_UTF8, 'flags' => API_REQUIRED, 'in' => implode(',', ['replace', 'Replace'])],
['else' => true, 'type' => API_STRING_UTF8, 'flags' => API_REQUIRED, 'in' => implode(',', ['add', 'remove', 'replace', 'Add', 'Remove', 'Replace'])]
]],
'value' => ['type' => API_MULTIPLE, 'rules' => [
['if' => ['field' => 'path', 'in' => 'members'], 'type' => API_OBJECTS, 'flags' => API_NOT_EMPTY, 'fields' => [
'value' => ['type' => API_ID]
]],
['else' => true, 'type' => API_STRING_UTF8, 'flags' => API_NOT_EMPTY]
]]
]]
]];
if (!CApiInputValidator::validate($api_input_rules, $options, '/', $error)) {
self::exception(ZBX_API_ERROR_PARAMETERS, $error);
}
if (!in_array(ScimApiService::SCIM_PATCH_SCHEMA, $options['schemas'], true)) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'Incorrect schema was sent in the request.');
}
foreach ($options['Operations'] as &$operation) {
$operation['op'] = strtolower($operation['op']);
}
}
/**
* Deletes SCIM group from 'scim_group' table. Deletes the users that belong to this group from 'user_scim_group'
* table. Updates users' user groups mapping based on the remaining SCIM groups and SAML settings.
*
* @param array $options
* @param string $options['id] SCIM group to be deleted.
*
* @return array Deleted group id.
*/
public function delete(array $options): array {
$this->validateDelete($options);
$db_scim_group_members = DB::select('user_scim_group', [
'output' => ['userid'],
'filter' => ['scim_groupid' => $options['id']]
]);
DB::delete('scim_group', ['scim_groupid' => $options['id']]);
foreach (array_column($db_scim_group_members, 'userid') as $userid) {
$this->updateProvisionedUserGroups($userid, CAuthenticationHelper::getSamlUserdirectoryidForScim());
}
return [$options['id']];
}
/**
* @param array $options
*
* @throws APIException if the input is invalid.
*/
private function validateDelete(array $options): void {
$api_input_rules = ['type' => API_OBJECT, 'flags' => API_REQUIRED, 'fields' => [
'id' => ['type' => API_ID, 'flags' => API_REQUIRED]
]];
if (!CApiInputValidator::validate($api_input_rules, $options, '/', $error)) {
self::exception(ZBX_API_ERROR_PARAMETERS, $error);
}
}
/**
* Based on SCIM group id, returns all the users that are included in this group.
*
* @param array $groupids SCIM groups' IDs.
*
* @return array Returns array where each group has its own array of users. Groupid is key, userid is key.
* [<groupid>][<userid>]['userid']
* [<groupid>][<userid>]['username']
*/
private function getUsersByGroupIds(array $groupids): array {
$db_scim_groups_members = DB::select('user_scim_group', [
'output' => ['userid', 'scim_groupid'],
'filter' => ['scim_groupid' => $groupids]
]);
if (!$db_scim_groups_members) {
return array_fill_keys($groupids, []);
}
$users = APIRPC::User()->get([
'output' => ['userid', 'username'],
'userids' => array_column($db_scim_groups_members, 'userid'),
'preservekeys' => true
]);
$users_groups = array_fill_keys($groupids, []);
foreach ($groupids as $groupid) {
foreach ($db_scim_groups_members as $scim_group_member) {
if ($scim_group_member['scim_groupid'] == $groupid) {
$users_groups[$groupid][$scim_group_member['userid']] = $users[$scim_group_member['userid']];
}
}
}
return $users_groups;
}
/**
* Checks what kind of SCIM groups user belongs to, checks the mapping of the groups in SAML settings and updates
* user's user group and role based on this mapping.
*
* @param string $userid
* @param array $userdirectoryid
*/
private function updateProvisionedUserGroups(string $userid, string $userdirectoryid): void {
$provisioning = CProvisioning::forUserDirectoryId($userdirectoryid);
$user_scim_groupids = DB::select('user_scim_group', [
'output' => ['scim_groupid'],
'filter' => ['userid' => $userid]
]);
$user_scim_group_names = DB::select('scim_group', [
'output' => ['name'],
'scim_groupids' => array_column($user_scim_groupids, 'scim_groupid')
]);
$group_rights = $provisioning->getUserGroupsAndRole(array_column($user_scim_group_names, 'name'));
APIRPC::User()->updateProvisionedUser([
'userid' => $userid,
'roleid' => $group_rights['roleid'],
'usrgrps' => $group_rights['usrgrps']
]);
}
/**
* Verifies if provided users exist in the database.
*
* @param array $userids User ids.
* @param string $userdirectoryid User directory id to which users belong to.
*
* @return array Returns array with users' id and username.
*
* @throws APIException
*/
private function verifyUserids(array $userids, string $userdirectoryid): array {
$users = APIRPC::User()->get([
'output' => ['userid', 'username'],
'userids' => $userids,
'filter' => ['userdirectoryid' => $userdirectoryid]
]);
if (count($users) !== count($userids)) {
self::exception(ZBX_API_ERROR_NO_ENTITY, 'No permissions to referred object or it does not exist!');
}
return $users;
}
/**
* Add user to specified list of SAML/SCIM groups. Creates new entries in 'scim_group' if group do not exists.
* Remove user to scim group relation from 'user_scim_group' when no groups supplied but
* do not removes scim_groups entry if user were last related to group user.
*
* @param array $saml_group_names Array of strings with SAML/SCIM groups names.
* @param int $userid User id.
*/
public static function createScimGroupsFromSamlAttributes(array $saml_group_names, string $userid): void {
if (!$saml_group_names) {
DB::delete('user_scim_group', ['userid' => $userid]);
return;
}
$db_scim_groups = DB::select('scim_group', [
'output' => ['scim_groupid', 'name'],
'filter' => ['name' => $saml_group_names],
'preservekeys' => true
]);
$groups_to_add = array_diff($saml_group_names, array_column($db_scim_groups, 'name'));
$scim_groupids = array_column($db_scim_groups, 'scim_groupid');
if ($groups_to_add) {
$insert = [];
foreach ($groups_to_add as $group_to_add) {
$insert[] = ['name' => $group_to_add];
}
$db_newids = DB::insert('scim_group', $insert, true);
$scim_groupids = array_merge($scim_groupids, $db_newids);
}
$db_users_scim_groupids = DB::select('user_scim_group', [
'output' => ['scim_groupid'],
'filter' => ['userid' => $userid]
]);
$db_users_scim_groupids = array_column($db_users_scim_groupids, 'scim_groupid');
$user_scim_groupids_delete = array_diff($db_users_scim_groupids, $scim_groupids);
$user_scim_groupids_add = [];
foreach(array_diff($scim_groupids, $db_users_scim_groupids) as $scim_groupid) {
$user_scim_groupids_add[] = [
'userid' => $userid,
'scim_groupid' => $scim_groupid
];
}
if ($user_scim_groupids_add) {
DB::insert('user_scim_group', $user_scim_groupids_add);
}
if ($user_scim_groupids_delete) {
DB::delete('user_scim_group', [
'userid' => $userid,
'scim_groupid' => $user_scim_groupids_delete
]);
}
}
}
|