-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
privilege,executor: update DBIsVisible() function for RBAC #10261
Conversation
`USE DB` check privileges using the DBIsVisible function, that function should take role into consideration CREATE DATABASE app_db CREATE ROLE 'app_developer' GRANT ALL ON app_db.* TO 'app_developer CREATE USER 'dev'@'localhost GRANT 'app_developer' TO 'dev'@'localhost' SET DEFAULT ROLE 'app_developer' TO 'dev'@'localhost' login as 'dev'@'localhost' Before: mysql> use app_db ERROR 1044 (42000): Access denied for user 'dev'@'localhost' to database 'app_db' After: mysql> use app_db; Database changed
Codecov Report
@@ Coverage Diff @@
## master #10261 +/- ##
===========================================
Coverage ? 77.3838%
===========================================
Files ? 412
Lines ? 85713
Branches ? 0
===========================================
Hits ? 66328
Misses ? 14352
Partials ? 5033 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
if SkipWithGrant { | ||
return true | ||
} | ||
mysqlPriv := p.Handle.Get() | ||
return mysqlPriv.DBIsVisible(p.user, p.host, db) | ||
if mysqlPriv.DBIsVisible(p.user, p.host, db) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If r_1
has privilege, r_2
doesn't have, and has relationship like r_1 -> r_2 -> user
, user should have privilege to visit db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean user has role r_2
r_2 has role r_1 ?
I think activeRoles
contains both r_1 and r_2 ? @imtbkcat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctx.ActiveRoles
just contain r_1, you could use MySQLPrivileges.FindAllRole
to get r_1 and r_2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
PTAL @imtbkcat
8e5e12d
to
9d2a773
Compare
/run-all-tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What problem does this PR solve?
login as 'dev'@'localhost'
Before:
After:
What is changed and how it works?
USE DB
check privileges using theDBIsVisible()
function, that function should takerole
into considerationCheck List
Tests