Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #14 from Ioannis/Revert_security_unlocked_actions
Revert_security_unlocked_actions
aaschenbrener committed Mar 5, 2024
2 parents 27396bf + 93ee86f commit 70b6458
Showing 3 changed files with 38 additions and 14 deletions.
16 changes: 12 additions & 4 deletions Controller/GrouperGroupsController.php
@@ -105,10 +105,18 @@ public function beforeFilter()
throw new InvalidArgumentException(_txt('er.grouperlite.glid'),
HttpStatusCodesEnum::HTTP_BAD_REQUEST);
}

if ($this->request->is('ajax')) {
$this->RequestHandler->addInputType('json', array('json_decode', true));
}
$this->response->disableCache();
$this->RequestHandler->addInputType('json', array('json_decode', true));

$this->Security->unlockedActions = [
'removeSubscriber',
'addSubscriber',
'joinGroup',
'leaveGroup',
'groupMember',
'groupOptin',
'groupOwner'
];

// Get the config
$args = array();
35 changes: 26 additions & 9 deletions Lib/GrouperApiAccess.php
@@ -332,6 +332,9 @@ public function deleteGroupWithTemplate(string $actAsUserId, string $workingGrou
*/
public function getGroupInfo(string $groupName): array
{
if(empty($groupName)) {
return [];
}
$groupInfo = [];

//Build request logic
@@ -362,7 +365,7 @@ public function getGroupInfo(string $groupName): array
$groupInfo = $results['WsGetAttributeAssignmentsResults']['wsGroups'];
}

//Now get the Group Attributes and add them to group
// Now get the Group Attributes and add them to group
$groupInfo[0]['attributes'] = $results['WsGetAttributeAssignmentsResults']['wsAttributeAssigns'] ?? [];

return $groupInfo;
@@ -376,22 +379,22 @@ public function getGroupInfo(string $groupName): array
* Note: Params added at end make sure that the groups returned can only be viewed by the member logged into
* Grouper Lite
*
* @param string $actorUserId
* @param string $actAsUserId
* @param string $userId
*
* @return array Membership records that User is a member of in Grouper
*
* @throws GrouperLiteWidgetException
*/
public function getUserGroups(string $actorUserId, string $userId): array
public function getUserGroups(string $actAsUserId, string $userId): array
{
if(empty($userId)) {
if(empty($userId) || empty($actAsUserId)) {
return [];
}

$actionEndpoint = "/subjects/{$userId}/groups?"
. 'wsLiteObjectType=WsRestGetGroupsLiteRequest'
. "&actAsSubjectId={$actorUserId}";
. "&actAsSubjectId={$actAsUserId}";
try {
$results = $this->http->sendRequest('GET', $actionEndpoint);
} catch (Exception $e) {
@@ -445,6 +448,13 @@ public function getUserGroups(string $actorUserId, string $userId): array
*/
public function getUserMemberships(string $userId, string $actAsUserId, string $groupType): array
{
if(empty($actAsUserId)
|| empty($userId)
|| empty($groupType)
) {
return [];
}

if(!in_array($groupType, [
GrouperGroupTypeEnum::OPTINS,
GrouperGroupTypeEnum::OPTOUTS,
@@ -496,11 +506,12 @@ public function getUserMemberships(string $userId, string $actAsUserId, string $
/**
* Get members associated to a specific Grouper Group
*
* @param string $actorUserId
* @param string $actAsUserId
* @param string $groupName
*
* @return array Listing of Members belonging to Grouper Group
* @throws GrouperLiteWidgetException|JsonException|NotFoundException
* @throws GrouperLiteWidgetException
* @throws JsonException
* @example https://github.com/Internet2/grouper/blob/master/grouper-ws/grouper-ws/doc/samples/getGroups/WsSampleGetGroupsRest_json.txt
*
* $: > grouperClientAlias --debug=true --operation=getMembersWs --actAsSubjectId=john.b.doe@at.internet2.edu --subjectAttributeNames=name --groupNames=ref:incommon-collab:co:member
@@ -532,13 +543,19 @@ public function getUserMemberships(string $userId, string $actAsUserId, string $
* }
* }
*/
public function getGroupMembers(string $actorUserId, string $groupName): array
public function getGroupMembers(string $actAsUserId, string $groupName): array
{
if(empty($actAsUserId)
|| empty($groupName)
) {
return [];
}

//Build request logic
$usersToShow = [
'WsRestGetMembersRequest' => [
'actAsSubjectLookup' => [
'subjectId' => $actorUserId
'subjectId' => $actAsUserId
],
'wsGroupLookups' => [
['groupName' => $groupName]
1 change: 0 additions & 1 deletion webroot/js/groups.js
@@ -42,7 +42,6 @@ export default {
const resp = await fetch(`${apiPath}`, {
headers: {
"Accept": "application/json",
// 'Content-Type': 'application/x-www-form-urlencoded',
},
method: "GET"
});

0 comments on commit 70b6458

Please sign in to comment.