3

I am using parse.com as a backend for my android application. I need help to solve the following scenario. I wanna do some access control. The app will consists of the following users say Super Admin, Admin, Moderator and Editors. The Super Admin can create a number of Admins(each admin has its own group), where as the Admin can create Moderator and Editors. Now i wanna set ACL to these users in which one group cannot be able to read or write data of another group. Is there any simple example for this scenario available.

                                      SUPER ADMIN
                        |------------------|--------------------|
                        |                  |                    |
                 ADMIN(Group A)     ADMIN(Group B)       ADMIN(Group C)
                     |                     |                    |
                     |-Moderator           |-Moderator          |-Moderator
                     |                     |                    |
                     |-Editor1             |-Editor1            |-Editor1
                     |                     |                    |
                     |-Editor2             |-Editor2            |-Editor2
                     |                                          |
                     |-Editor3                                  |-Editor3

2 Answers 2

4

Yes, you can do this. Roles use ACLs just as other objects to. I think the example in the docs answer most of what you are after:

https://parse.com/docs/android_guide#roles

Try that and check back here with a specific question if you have problems solving your scenario.

Snipped from the docs:

// By specifying no write privileges for the ACL, we can ensure the role cannot be altered.
ParseACL roleACL = new ParseACL();
roleACL.setPublicReadAccess(true);
ParseRole role = new ParseRole("Administrator", roleACL);
role.saveInBackground();

ParseRole role = new ParseRole(roleName, roleACL);
for (ParseUser user : usersToAddToRole) {
  role.getUsers().add(user)
}
for (ParseRole childRole : rolesToAddToRole) {
  role.getRoles().add(childRole);
}
role.saveInBackground();
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for the reply @Handsomeguy. The above code will add users to a specific role, but i wanna add roles to a user.
Sorry, I didn't see your comment. That's not the way it works. Compare the roles to a "group" in a network. "Administrators" is a group where you put people who have the administrator "role" at your company. I can agree that it may be a little confusing. But just think of roles as access groups.
hi @Handsomeguy , Does it mean for every Group a new Roles have to be created? e.g. GroupAAdmin, GroupBAdmin, GroupAModerator, ... in order to restrict access to group resources?
Not sure if I understand your question. Why do you talk about both groups and roles? If you think of roles as a group (as that is essentially how it works in Parse) you only need to create the Roles you need. What, in your scenario, is the difference between GroupAAdmin and GroupBAdmin? How are they different? What is different about what access they should grant?
1

This is what I use for read and write, but with the ParseACL object you can set everything you need.

 ParseACL defaultACL = new ParseACL();
 defaultACL.setPublicReadAccess(true);
 ParseACL.setDefaultACL(defaultACL, true);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.