etherpad-lite icon indicating copy to clipboard operation
etherpad-lite copied to clipboard

User getting kicked out when sessionId for a group being used by another.

Open kernelfreak opened this issue 10 years ago • 3 comments

Hello friends,

I am currently trying to integrate Etherpad into our application and having a problem with GroupPads. Currently I am creating a single group, a single author and then creating a session with those two. Then once I have the sessionID, I am creating a GroupPad for that group. Now all the users who have permission to add/edit the Pad, receive the sessionID from the session created in step 1. Then I am setting the cookie for same. Unfortunately, when 2 users are trying to access the same pad, the 2nd user is kicked out and any 3rd user joining gets an error insufficient permissions.

How can I have multiple users working on a single pad with a SessionID. What is the exact strategy required? I have still not understood the security model of Etherpad completely, any light on that might help.

Code : Here I am just creating a session and returning it for setting cookie. ``` Map group = client.createGroup(); Map author = client.createAuthor(String.valueOf(person.getFirstName())); DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dfm.setTimeZone(TimeZone.getTimeZone("Europe/Berlin")); Date longTime = dfm.parse("2099-01-15 20:15:00"); Map sessionData = client.createSession(String.valueOf(group.get("groupID")), String.valueOf(author.get("authorID")), longTime);


In the next step, I am getting the groupID and create a groupPad. As it's a groupPad, I presumed that multiple people should be able to work on it. This action should be achieved via sessionID from step 1. But that's now how its working. I am getting permission error.

Creating a groupPad from groupID from step 1 : 

`                        Map pad = client.createGroupPad(String.valueOf(map.get("groupID")), str, text);`
How can I make it so multiple users can work on a GroupPad at the same time? Thank you

kernelfreak avatar Nov 02 '16 12:11 kernelfreak

You have to create a sessionID and author for each user who should enter the pad. Every single user who enters a pad needs his own author.

Gared avatar Nov 03 '16 07:11 Gared

@Gared : Hi, This is what we did afterwards, and still we are getting the same error. First, for the GroupAccount which we have in our GroupAdmin. So, In Etherpad I create a Group, author object with the admins first name, then for the admin I created a session. This sessionData was saved in GroupMembers object. Similarly, by keeping GroupID same, I created new authors and session for every member. Then a cookie was set for the same in front-end when loading groups. Now, when a groupPAd was created, the GroupID is same throughout, but more than 1 user still doesn't have access, permissionDenied error.

Code :


`  List<GroupAccount> groupAccountList = this.groupAccountService.getAllGroupAccounts();
            for(GroupAccount groupAccount : groupAccountList){
                Person person = this.personService.findPersonByUsername(groupAccount.getAdminUsername());
                Map group = client.createGroup();
                System.out.println("Group to string is " + group.toString());
                Map author = client.createAuthor(String.valueOf(person.getFirstName()));
                System.out.println("Author is " + author.toString());
                DateFormat dfm = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                dfm.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
                Date longTime = dfm.parse("2099-01-15 20:15:00");
                Map sessionData = client.createSession(String.valueOf(group.get("groupID")), String.valueOf(author.get("authorID")), longTime);
                if (sessionData != null) {
                    sessionData.put("groupID", group.get("groupID"));
                    sessionData.put("authorID", author.get("authorID"));
                    GroupMembers adminMember = this.groupMembersService.returnMembersMatchingUsernameAccountId(person.getUsername(),groupAccount.getGroupId());
                    adminMember.setSessionData(sessionData.toString());
                    this.groupMembersService.directUpdateGroupMembers(adminMember);
                    List<GroupMembers> groupMembersList = this.groupMembersService.returnGroupMembers(groupAccount.getGroupId());
                    for(GroupMembers groupMember : groupMembersList){
                        if(!groupMember.getMemberUsername().equals(person.getUsername())){
                            System.out.println("GroupMember memberuserbname is "+groupMember.getMemberUsername());
                            Person authorPerson = this.personService.findPersonByUsername(groupMember.getMemberUsername());
                            if(authorPerson!=null) {
                                System.out.println("Author person uis " + authorPerson.getUsername());
                                Map etherpadAuthor = client.createAuthor(String.valueOf(authorPerson.getFirstName()));
                                DateFormat authorDFM = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                authorDFM.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
                                Date authorLongTime = authorDFM.parse("2099-01-15 20:15:00");
                                Map authorSessionData = client.createSession(String.valueOf(group.get("groupID")), String.valueOf(etherpadAuthor.get("authorID")),
                                        authorLongTime);
                                if (authorSessionData != null) {
                                    authorSessionData.put("groupID", group.get("groupID"));
                                    authorSessionData.put("authorID", etherpadAuthor.get("authorID"));
                                    groupMember.setSessionData(authorSessionData.toString());
                                    this.groupMembersService.directUpdateGroupMembers(groupMember);
                                }
                            }
                        }
                    }
                    //return client.createGroupPad(String.valueOf(group.get("groupID")),String.valueOf(noteId),noteText);
                }
            }`

kernelfreak avatar Nov 03 '16 08:11 kernelfreak

The problem was with how Tomcat was returning the cookie data in comma separated strings. We encoded the entire string and then it was fine.

kernelfreak avatar Nov 04 '16 12:11 kernelfreak