Skip to content

Revert_security_unlocked_actions #14

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Controller/GrouperGroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
35 changes: 26 additions & 9 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion webroot/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default {
const resp = await fetch(`${apiPath}`, {
headers: {
"Accept": "application/json",
// 'Content-Type': 'application/x-www-form-urlencoded',
},
method: "GET"
});
Expand Down