If a session has set a role X, revoking this role X from the user does not revoke the grants it provided.
I am not 100% sure whether it's design or oversight, but I suspect the latter because a) revoking the grants from the role does revoke them from an open session; b) dropping the role also revokes the grants from an open session. However, it's obviously not practical to do modify a role this way if you only want to deny it for a particular user, and do it immediately.
by design. also, revoking or dropping a role which is enabled (directly or indirectly) does not affect user's global privileges or privileges on the current database, but does affect privileges on the non-current database, table, column, and routine privileges. this is identical to how revoking privileges directly from a user work — which also doesn't affect privileges, cached in the THD.
Sergei Golubchik
added a comment - by design. also, revoking or dropping a role which is enabled (directly or indirectly) does not affect user's global privileges or privileges on the current database, but does affect privileges on the non-current database, table, column, and routine privileges. this is identical to how revoking privileges directly from a user work — which also doesn't affect privileges, cached in the THD.
>> revoking or dropping a role which is enabled (directly or indirectly) does not affect user's global privileges or privileges on the current database, but does affect privileges on the non-current database, table, column, and routine privileges
But the example above was about a non-current database, was it not?
>> this is identical to how revoking privileges directly from a user work
Strange, I don't see the symmetry here. Please consider the following example. user1 is given two symmetrical grants, one for db1 through role1, another one for db2 directly. Then the grants are revoked at the same time; but access to db1 remains, while access to db2 doesn't.
create user user1@localhost;
create role role1;
grant role1 to user1@localhost;
grant all on db1.* to role1;
grant all on db2.* to user1@localhost;
--connect (con1,localhost,user1,,)
set role role1;
show grants;
create table db1.t1 (i int);
create table db2.t2 (i int);
--connection default
revoke role1 from user1@localhost;
revoke all on db2.* from user1@localhost;
--connection con1
show grants;
drop table db1.t1;
drop table db2.t2;
The end of output:
Grants for user1@localhost
GRANT USAGE ON . TO 'user1'@'localhost'
GRANT USAGE ON . TO 'role1'
GRANT ALL PRIVILEGES ON `db1`.* TO 'role1'
drop table db1.t1;
drop table db2.t2;
mysqltest: At line 24: query 'drop table db2.t2' failed: 1142: DROP command denied to user 'user1'@'localhost' for table 't2'
Elena Stepanova
added a comment - >> revoking or dropping a role which is enabled (directly or indirectly) does not affect user's global privileges or privileges on the current database, but does affect privileges on the non-current database, table, column, and routine privileges
But the example above was about a non-current database, was it not?
>> this is identical to how revoking privileges directly from a user work
Strange, I don't see the symmetry here. Please consider the following example. user1 is given two symmetrical grants, one for db1 through role1, another one for db2 directly. Then the grants are revoked at the same time; but access to db1 remains, while access to db2 doesn't.
--enable_connect_log
create database db1;
create database db2;
create user user1@localhost;
create role role1;
grant role1 to user1@localhost;
grant all on db1.* to role1;
grant all on db2.* to user1@localhost;
--connect (con1,localhost,user1,,)
set role role1;
show grants;
create table db1.t1 (i int);
create table db2.t2 (i int);
--connection default
revoke role1 from user1@localhost;
revoke all on db2.* from user1@localhost;
--connection con1
show grants;
drop table db1.t1;
drop table db2.t2;
The end of output:
Grants for user1@localhost
GRANT USAGE ON . TO 'user1'@'localhost'
GRANT USAGE ON . TO 'role1'
GRANT ALL PRIVILEGES ON `db1`.* TO 'role1'
drop table db1.t1;
drop table db2.t2;
mysqltest: At line 24: query 'drop table db2.t2' failed: 1142: DROP command denied to user 'user1'@'localhost' for table 't2'
"access to db1 remains" was a bug that I've fixed recently, but hasn't pushed yet.
Access to the current database will remain, access to the non-current database is affected by grant/revoke — independently whether it was a grant to a role or to a user.
Sergei Golubchik
added a comment - "access to db1 remains" was a bug that I've fixed recently, but hasn't pushed yet.
Access to the current database will remain, access to the non-current database is affected by grant/revoke — independently whether it was a grant to a role or to a user.
People
Sergei Golubchik
Elena Stepanova
Votes:
0Vote for this issue
Watchers:
2Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":811.6999999880791,"ttfb":196.19999998807907,"pageVisibility":"visible","entityId":26111,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"0c172d74-0a7e-4d0d-8736-3c81c1961b38","navigationType":0,"readyForUser":892.3000000119209,"redirectCount":0,"resourceLoadedEnd":912.6999999880791,"resourceLoadedStart":201.5,"resourceTiming":[{"duration":55.09999996423721,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":201.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":201.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":256.5999999642372,"responseStart":0,"secureConnectionStart":0},{"duration":61.69999998807907,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":201.80000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":201.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":263.5,"responseStart":0,"secureConnectionStart":0},{"duration":117.30000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":201.89999997615814,"connectEnd":201.89999997615814,"connectStart":201.89999997615814,"domainLookupEnd":201.89999997615814,"domainLookupStart":201.89999997615814,"fetchStart":201.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":201.89999997615814,"responseEnd":319.19999998807907,"responseStart":319.19999998807907,"secureConnectionStart":201.89999997615814},{"duration":178.9000000357628,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":202.0999999642372,"connectEnd":202.0999999642372,"connectStart":202.0999999642372,"domainLookupEnd":202.0999999642372,"domainLookupStart":202.0999999642372,"fetchStart":202.0999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":202.0999999642372,"responseEnd":381,"responseStart":381,"secureConnectionStart":202.0999999642372},{"duration":182.39999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":202.30000001192093,"connectEnd":202.30000001192093,"connectStart":202.30000001192093,"domainLookupEnd":202.30000001192093,"domainLookupStart":202.30000001192093,"fetchStart":202.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":202.30000001192093,"responseEnd":384.69999998807907,"responseStart":384.69999998807907,"secureConnectionStart":202.30000001192093},{"duration":182.69999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":202.5,"connectEnd":202.5,"connectStart":202.5,"domainLookupEnd":202.5,"domainLookupStart":202.5,"fetchStart":202.5,"redirectEnd":0,"redirectStart":0,"requestStart":202.5,"responseEnd":385.19999998807907,"responseStart":385.19999998807907,"secureConnectionStart":202.5},{"duration":182.80000001192093,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":202.69999998807907,"connectEnd":202.69999998807907,"connectStart":202.69999998807907,"domainLookupEnd":202.69999998807907,"domainLookupStart":202.69999998807907,"fetchStart":202.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":202.69999998807907,"responseEnd":385.5,"responseStart":385.5,"secureConnectionStart":202.69999998807907},{"duration":257.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":202.80000001192093,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":202.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":460.30000001192093,"responseStart":0,"secureConnectionStart":0},{"duration":182.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":203,"connectEnd":203,"connectStart":203,"domainLookupEnd":203,"domainLookupStart":203,"fetchStart":203,"redirectEnd":0,"redirectStart":0,"requestStart":203,"responseEnd":385.89999997615814,"responseStart":385.89999997615814,"secureConnectionStart":203},{"duration":257.30000001192093,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":203.0999999642372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":203.0999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":460.39999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":183.0999999642372,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":203.30000001192093,"connectEnd":203.30000001192093,"connectStart":203.30000001192093,"domainLookupEnd":203.30000001192093,"domainLookupStart":203.30000001192093,"fetchStart":203.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":203.30000001192093,"responseEnd":386.39999997615814,"responseStart":386.39999997615814,"secureConnectionStart":203.30000001192093},{"duration":473.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":208.80000001192093,"connectEnd":208.80000001192093,"connectStart":208.80000001192093,"domainLookupEnd":208.80000001192093,"domainLookupStart":208.80000001192093,"fetchStart":208.80000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":208.80000001192093,"responseEnd":682.6999999880791,"responseStart":682.6999999880791,"secureConnectionStart":208.80000001192093},{"duration":531.6999999880791,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":208.89999997615814,"connectEnd":208.89999997615814,"connectStart":208.89999997615814,"domainLookupEnd":208.89999997615814,"domainLookupStart":208.89999997615814,"fetchStart":208.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":208.89999997615814,"responseEnd":740.5999999642372,"responseStart":740.5999999642372,"secureConnectionStart":208.89999997615814},{"duration":211.69999998807907,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":471.30000001192093,"connectEnd":471.30000001192093,"connectStart":471.30000001192093,"domainLookupEnd":471.30000001192093,"domainLookupStart":471.30000001192093,"fetchStart":471.30000001192093,"redirectEnd":0,"redirectStart":0,"requestStart":471.30000001192093,"responseEnd":683,"responseStart":683,"secureConnectionStart":471.30000001192093},{"duration":50,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bv2/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":721.0999999642372,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":721.0999999642372,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":771.0999999642372,"responseStart":0,"secureConnectionStart":0},{"duration":186.5999999642372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":722,"connectEnd":722,"connectStart":722,"domainLookupEnd":722,"domainLookupStart":722,"fetchStart":722,"redirectEnd":0,"redirectStart":0,"requestStart":722,"responseEnd":908.5999999642372,"responseStart":908.5999999642372,"secureConnectionStart":722},{"duration":190.39999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/53a43b6764f587426c7bb9a150184c00-CDN/lu2bv2/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":722.3000000119209,"connectEnd":722.3000000119209,"connectStart":722.3000000119209,"domainLookupEnd":722.3000000119209,"domainLookupStart":722.3000000119209,"fetchStart":722.3000000119209,"redirectEnd":0,"redirectStart":0,"requestStart":722.3000000119209,"responseEnd":912.6999999880791,"responseStart":912.6999999880791,"secureConnectionStart":722.3000000119209},{"duration":124.19999998807907,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":805.8000000119209,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":805.8000000119209,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":930,"responseStart":0,"secureConnectionStart":0},{"duration":157.30000001192093,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":826,"connectEnd":826,"connectStart":826,"domainLookupEnd":826,"domainLookupStart":826,"fetchStart":826,"redirectEnd":0,"redirectStart":0,"requestStart":826,"responseEnd":983.3000000119209,"responseStart":983.3000000119209,"secureConnectionStart":826}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":21,"responseStart":196,"responseEnd":201,"domLoading":199,"domInteractive":965,"domContentLoadedEventStart":966,"domContentLoadedEventEnd":1007,"domComplete":1232,"loadEventStart":1232,"loadEventEnd":1233,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":931.8000000119209},{"name":"bigPipe.sidebar-id.end","time":932.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":932.6999999880791},{"name":"bigPipe.activity-panel-pipe-id.end","time":934.3000000119209},{"name":"activityTabFullyLoaded","time":1026.0999999642372}],"measures":[],"correlationId":"85e98dfd126e15","effectiveType":"4g","downlink":9.7,"rtt":0,"serverDuration":109,"dbReadsTimeInMs":14,"dbConnsTimeInMs":24,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
by design. also, revoking or dropping a role which is enabled (directly or indirectly) does not affect user's global privileges or privileges on the current database, but does affect privileges on the non-current database, table, column, and routine privileges. this is identical to how revoking privileges directly from a user work — which also doesn't affect privileges, cached in the THD.