question

Luis Saenz avatar image
Luis Saenz asked

Groups : Custom role with same permissions as admin

Is there an easy policy to set a custom role to have the same permissions as a build-in role? ei. custom role = admins. The custom group is meant to behave as an admin for playfab but have different access client side

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

PlayFab does not provide such features that can give a custom role all admin permissions with one-click. But you can implement such functions on CloudScript by using API Entity API GetProfiles and SetProfilePolicy in combination.

If you want to give the custom role the admin permission, you need to add the full permission statements in the Group’s profile policy as something like this example. You can refer to this example to add the corresponding permission statements for such resources "pfrn:data--*!*/*","pfrn:group--*!*", etc.

  {
    "Action": "*",
    "Effect": "Allow",
    "Resource": "pfrn:group--*!*/*",
    "Principal": {
      "MemberOf": {
        "RoleId": "[YourCustomRoleId]"
      }
    },
    "Comment": "Allow members of the group [CustomRole] to do anything with the group",
    "Condition": null
  }

Apart from adding the permission statements in the GameManager manually, you can also use API SetProfilePolicy to replacement update the group’s policy.

So you can use API GetProfiles to get the original group policy, find out the permission statements for admin, create the same permission statement for custom roles, splice the original policy with the permission statement you created, then update the new policy using SetProfilePolicy. After you package this process into a CloudScript function, you can reuse this function for the other groups.

If you need a PlayFab native feature that can give a custom role of the group all admin permissions easily, you can try to add a feature request for it.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.