{"action":"created","comment":{"url":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments/62067286","id":62067286,"diff_hunk":"@@ -402,19 +412,34 @@ void cacheRealmPermsChanged(String realmRef, Set<String> roles, Set<String> perm\n             if (cacheDebug) M_log.info(\"SScache:changed .anon:found in \"+azgRef);\n             for (String perm : permissions) {\n                 if (perm != null) {\n-                    keysToInvalidate.add(makeCacheKey(null, perm, azgRef, false));\n+                    keysToInvalidate.add(makeCacheKey(null, perm, azgRef, false, false));\n                 }\n             }\n         }\n         // now handle all the real users\n+\t// clear both normal and swapped users\n+\t// start with a set of all roles to which one can swap\n+\tSet<String> svRolesFinal = (Set<String>)svRoles.clone();\n+\tsvRolesFinal.retainAll(roles);  \n+\n         Set<Member> members = azg.getMembers();\n         if (members != null && !members.isEmpty()) {\n             for (Member member : members) {\n                 if (member != null && member.isActive() && member.getUserId() != null) {\n+\t\t    boolean canSwap = (member.getRole().isAllowed(SiteService.SITE_ROLE_SWAP));\n                     for (String perm : permissions) {\n                         if (perm != null) {\n-                            keysToInvalidate.add(makeCacheKey(member.getUserId(), perm, azgRef, false));\n-                        }\n+                            keysToInvalidate.add(makeCacheKey(member.getUserId(), perm, azgRef, false, false));\n+\t\t\t    // Only invalidate swapped roles if the user can swap\n+\t\t\t    // This is an approximation. If a user is swapped and their permission to swap is removed\n+\t\t\t    // or the role they are swapped to has been removed from the site\n+\t\t\t    // we will not invalidate their data. Their info may wait until the expiration time to sync up\n+\t\t\t    if (canSwap) {\n+\t\t\t\tfor (String invRole: svRolesFinal) {\n+\t\t\t\t    keysToInvalidate.add(makeCacheKey(invRole + \"!\" + member.getUserId(), perm, azgRef, false, false));","path":"kernel/kernel-impl/src/main/java/org/sakaiproject/authz/impl/SakaiSecurity.java","position":62,"original_position":62,"commit_id":"43d910f6c02d55016106c91612525d7f5bdfcd18","original_commit_id":"43d910f6c02d55016106c91612525d7f5bdfcd18","user":{"login":"ern","id":209420,"avatar_url":"https://avatars.githubusercontent.com/u/209420?v=3","gravatar_id":"","url":"https://api.github.com/users/ern","html_url":"https://github.com/ern","followers_url":"https://api.github.com/users/ern/followers","following_url":"https://api.github.com/users/ern/following{/other_user}","gists_url":"https://api.github.com/users/ern/gists{/gist_id}","starred_url":"https://api.github.com/users/ern/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ern/subscriptions","organizations_url":"https://api.github.com/users/ern/orgs","repos_url":"https://api.github.com/users/ern/repos","events_url":"https://api.github.com/users/ern/events{/privacy}","received_events_url":"https://api.github.com/users/ern/received_events","type":"User","site_admin":false},"body":"I think this could be simpler, just add another segment to the cache key that includes the users role?","created_at":"2016-05-04T16:06:54Z","updated_at":"2016-05-04T16:06:54Z","html_url":"https://github.com/sakaiproject/sakai/pull/2445#discussion_r62067286","pull_request_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/2445","_links":{"self":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments/62067286"},"html":{"href":"https://github.com/sakaiproject/sakai/pull/2445#discussion_r62067286"},"pull_request":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/2445"}}},"pull_request":{"url":"https://api.github.com/repos/sakaiproject/sakai/pulls/2445","id":68764563,"html_url":"https://github.com/sakaiproject/sakai/pull/2445","diff_url":"https://github.com/sakaiproject/sakai/pull/2445.diff","patch_url":"https://github.com/sakaiproject/sakai/pull/2445.patch","issue_url":"https://api.github.com/repos/sakaiproject/sakai/issues/2445","number":2445,"state":"open","locked":false,"title":"KNL-1432; handle caching permissions when role is swapped","user":{"login":"clhedrick","id":1907208,"avatar_url":"https://avatars.githubusercontent.com/u/1907208?v=3","gravatar_id":"","url":"https://api.github.com/users/clhedrick","html_url":"https://github.com/clhedrick","followers_url":"https://api.github.com/users/clhedrick/followers","following_url":"https://api.github.com/users/clhedrick/following{/other_user}","gists_url":"https://api.github.com/users/clhedrick/gists{/gist_id}","starred_url":"https://api.github.com/users/clhedrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clhedrick/subscriptions","organizations_url":"https://api.github.com/users/clhedrick/orgs","repos_url":"https://api.github.com/users/clhedrick/repos","events_url":"https://api.github.com/users/clhedrick/events{/privacy}","received_events_url":"https://api.github.com/users/clhedrick/received_events","type":"User","site_admin":false},"body":"I've copied code from portal and DbAuthz to keep behavior consistent.","created_at":"2016-05-03T19:53:49Z","updated_at":"2016-05-04T16:06:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"17180ee63a588d7d65c309a286232c320a6263d2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/2445/commits","review_comments_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/2445/comments","review_comment_url":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sakaiproject/sakai/issues/2445/comments","statuses_url":"https://api.github.com/repos/sakaiproject/sakai/statuses/43d910f6c02d55016106c91612525d7f5bdfcd18","head":{"label":"clhedrick:KNL-1432","ref":"KNL-1432","sha":"43d910f6c02d55016106c91612525d7f5bdfcd18","user":{"login":"clhedrick","id":1907208,"avatar_url":"https://avatars.githubusercontent.com/u/1907208?v=3","gravatar_id":"","url":"https://api.github.com/users/clhedrick","html_url":"https://github.com/clhedrick","followers_url":"https://api.github.com/users/clhedrick/followers","following_url":"https://api.github.com/users/clhedrick/following{/other_user}","gists_url":"https://api.github.com/users/clhedrick/gists{/gist_id}","starred_url":"https://api.github.com/users/clhedrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clhedrick/subscriptions","organizations_url":"https://api.github.com/users/clhedrick/orgs","repos_url":"https://api.github.com/users/clhedrick/repos","events_url":"https://api.github.com/users/clhedrick/events{/privacy}","received_events_url":"https://api.github.com/users/clhedrick/received_events","type":"User","site_admin":false},"repo":{"id":30562316,"name":"sakai","full_name":"clhedrick/sakai","owner":{"login":"clhedrick","id":1907208,"avatar_url":"https://avatars.githubusercontent.com/u/1907208?v=3","gravatar_id":"","url":"https://api.github.com/users/clhedrick","html_url":"https://github.com/clhedrick","followers_url":"https://api.github.com/users/clhedrick/followers","following_url":"https://api.github.com/users/clhedrick/following{/other_user}","gists_url":"https://api.github.com/users/clhedrick/gists{/gist_id}","starred_url":"https://api.github.com/users/clhedrick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clhedrick/subscriptions","organizations_url":"https://api.github.com/users/clhedrick/orgs","repos_url":"https://api.github.com/users/clhedrick/repos","events_url":"https://api.github.com/users/clhedrick/events{/privacy}","received_events_url":"https://api.github.com/users/clhedrick/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/clhedrick/sakai","description":"Sakai is a freely available, feature-rich technology solution for learning, teaching, research and collaboration. Sakai is an open source software suite developed by a diverse and global adopter community.","fork":true,"url":"https://api.github.com/repos/clhedrick/sakai","forks_url":"https://api.github.com/repos/clhedrick/sakai/forks","keys_url":"https://api.github.com/repos/clhedrick/sakai/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clhedrick/sakai/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clhedrick/sakai/teams","hooks_url":"https://api.github.com/repos/clhedrick/sakai/hooks","issue_events_url":"https://api.github.com/repos/clhedrick/sakai/issues/events{/number}","events_url":"https://api.github.com/repos/clhedrick/sakai/events","assignees_url":"https://api.github.com/repos/clhedrick/sakai/assignees{/user}","branches_url":"https://api.github.com/repos/clhedrick/sakai/branches{/branch}","tags_url":"https://api.github.com/repos/clhedrick/sakai/tags","blobs_url":"https://api.github.com/repos/clhedrick/sakai/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clhedrick/sakai/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clhedrick/sakai/git/refs{/sha}","trees_url":"https://api.github.com/repos/clhedrick/sakai/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clhedrick/sakai/statuses/{sha}","languages_url":"https://api.github.com/repos/clhedrick/sakai/languages","stargazers_url":"https://api.github.com/repos/clhedrick/sakai/stargazers","contributors_url":"https://api.github.com/repos/clhedrick/sakai/contributors","subscribers_url":"https://api.github.com/repos/clhedrick/sakai/subscribers","subscription_url":"https://api.github.com/repos/clhedrick/sakai/subscription","commits_url":"https://api.github.com/repos/clhedrick/sakai/commits{/sha}","git_commits_url":"https://api.github.com/repos/clhedrick/sakai/git/commits{/sha}","comments_url":"https://api.github.com/repos/clhedrick/sakai/comments{/number}","issue_comment_url":"https://api.github.com/repos/clhedrick/sakai/issues/comments{/number}","contents_url":"https://api.github.com/repos/clhedrick/sakai/contents/{+path}","compare_url":"https://api.github.com/repos/clhedrick/sakai/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clhedrick/sakai/merges","archive_url":"https://api.github.com/repos/clhedrick/sakai/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clhedrick/sakai/downloads","issues_url":"https://api.github.com/repos/clhedrick/sakai/issues{/number}","pulls_url":"https://api.github.com/repos/clhedrick/sakai/pulls{/number}","milestones_url":"https://api.github.com/repos/clhedrick/sakai/milestones{/number}","notifications_url":"https://api.github.com/repos/clhedrick/sakai/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clhedrick/sakai/labels{/name}","releases_url":"https://api.github.com/repos/clhedrick/sakai/releases{/id}","deployments_url":"https://api.github.com/repos/clhedrick/sakai/deployments","created_at":"2015-02-09T22:32:39Z","updated_at":"2016-01-12T19:27:43Z","pushed_at":"2016-05-04T15:06:27Z","git_url":"git://github.com/clhedrick/sakai.git","ssh_url":"git@github.com:clhedrick/sakai.git","clone_url":"https://github.com/clhedrick/sakai.git","svn_url":"https://github.com/clhedrick/sakai","homepage":"https://www.sakaiproject.org","size":243276,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"old-master"}},"base":{"label":"sakaiproject:master","ref":"master","sha":"72052fbc927600670bf3c089f63b2e20e922edb9","user":{"login":"sakaiproject","id":314726,"avatar_url":"https://avatars.githubusercontent.com/u/314726?v=3","gravatar_id":"","url":"https://api.github.com/users/sakaiproject","html_url":"https://github.com/sakaiproject","followers_url":"https://api.github.com/users/sakaiproject/followers","following_url":"https://api.github.com/users/sakaiproject/following{/other_user}","gists_url":"https://api.github.com/users/sakaiproject/gists{/gist_id}","starred_url":"https://api.github.com/users/sakaiproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sakaiproject/subscriptions","organizations_url":"https://api.github.com/users/sakaiproject/orgs","repos_url":"https://api.github.com/users/sakaiproject/repos","events_url":"https://api.github.com/users/sakaiproject/events{/privacy}","received_events_url":"https://api.github.com/users/sakaiproject/received_events","type":"Organization","site_admin":false},"repo":{"id":28589709,"name":"sakai","full_name":"sakaiproject/sakai","owner":{"login":"sakaiproject","id":314726,"avatar_url":"https://avatars.githubusercontent.com/u/314726?v=3","gravatar_id":"","url":"https://api.github.com/users/sakaiproject","html_url":"https://github.com/sakaiproject","followers_url":"https://api.github.com/users/sakaiproject/followers","following_url":"https://api.github.com/users/sakaiproject/following{/other_user}","gists_url":"https://api.github.com/users/sakaiproject/gists{/gist_id}","starred_url":"https://api.github.com/users/sakaiproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sakaiproject/subscriptions","organizations_url":"https://api.github.com/users/sakaiproject/orgs","repos_url":"https://api.github.com/users/sakaiproject/repos","events_url":"https://api.github.com/users/sakaiproject/events{/privacy}","received_events_url":"https://api.github.com/users/sakaiproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sakaiproject/sakai","description":"Sakai is a freely available, feature-rich technology solution for learning, teaching, research and collaboration. Sakai is an open source software suite developed by a diverse and global adopter community.","fork":false,"url":"https://api.github.com/repos/sakaiproject/sakai","forks_url":"https://api.github.com/repos/sakaiproject/sakai/forks","keys_url":"https://api.github.com/repos/sakaiproject/sakai/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sakaiproject/sakai/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sakaiproject/sakai/teams","hooks_url":"https://api.github.com/repos/sakaiproject/sakai/hooks","issue_events_url":"https://api.github.com/repos/sakaiproject/sakai/issues/events{/number}","events_url":"https://api.github.com/repos/sakaiproject/sakai/events","assignees_url":"https://api.github.com/repos/sakaiproject/sakai/assignees{/user}","branches_url":"https://api.github.com/repos/sakaiproject/sakai/branches{/branch}","tags_url":"https://api.github.com/repos/sakaiproject/sakai/tags","blobs_url":"https://api.github.com/repos/sakaiproject/sakai/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sakaiproject/sakai/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sakaiproject/sakai/git/refs{/sha}","trees_url":"https://api.github.com/repos/sakaiproject/sakai/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sakaiproject/sakai/statuses/{sha}","languages_url":"https://api.github.com/repos/sakaiproject/sakai/languages","stargazers_url":"https://api.github.com/repos/sakaiproject/sakai/stargazers","contributors_url":"https://api.github.com/repos/sakaiproject/sakai/contributors","subscribers_url":"https://api.github.com/repos/sakaiproject/sakai/subscribers","subscription_url":"https://api.github.com/repos/sakaiproject/sakai/subscription","commits_url":"https://api.github.com/repos/sakaiproject/sakai/commits{/sha}","git_commits_url":"https://api.github.com/repos/sakaiproject/sakai/git/commits{/sha}","comments_url":"https://api.github.com/repos/sakaiproject/sakai/comments{/number}","issue_comment_url":"https://api.github.com/repos/sakaiproject/sakai/issues/comments{/number}","contents_url":"https://api.github.com/repos/sakaiproject/sakai/contents/{+path}","compare_url":"https://api.github.com/repos/sakaiproject/sakai/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sakaiproject/sakai/merges","archive_url":"https://api.github.com/repos/sakaiproject/sakai/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sakaiproject/sakai/downloads","issues_url":"https://api.github.com/repos/sakaiproject/sakai/issues{/number}","pulls_url":"https://api.github.com/repos/sakaiproject/sakai/pulls{/number}","milestones_url":"https://api.github.com/repos/sakaiproject/sakai/milestones{/number}","notifications_url":"https://api.github.com/repos/sakaiproject/sakai/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sakaiproject/sakai/labels{/name}","releases_url":"https://api.github.com/repos/sakaiproject/sakai/releases{/id}","deployments_url":"https://api.github.com/repos/sakaiproject/sakai/deployments","created_at":"2014-12-29T11:14:17Z","updated_at":"2016-04-28T11:17:27Z","pushed_at":"2016-05-04T15:56:53Z","git_url":"git://github.com/sakaiproject/sakai.git","ssh_url":"git@github.com:sakaiproject/sakai.git","clone_url":"https://github.com/sakaiproject/sakai.git","svn_url":"https://github.com/sakaiproject/sakai","homepage":"https://www.sakaiproject.org","size":269576,"stargazers_count":137,"watchers_count":137,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":243,"mirror_url":null,"open_issues_count":86,"forks":243,"open_issues":86,"watchers":137,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/2445"},"html":{"href":"https://github.com/sakaiproject/sakai/pull/2445"},"issue":{"href":"https://api.github.com/repos/sakaiproject/sakai/issues/2445"},"comments":{"href":"https://api.github.com/repos/sakaiproject/sakai/issues/2445/comments"},"review_comments":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/2445/comments"},"review_comment":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sakaiproject/sakai/pulls/2445/commits"},"statuses":{"href":"https://api.github.com/repos/sakaiproject/sakai/statuses/43d910f6c02d55016106c91612525d7f5bdfcd18"}}}}