-
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
*: implement auth plugin support in the extension framework #53494
Conversation
Hi @yzhan1. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Hi @yzhan1. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@lcwangchao @CbcWestwolf Would like to gather some early feedback from you. Thanks in advance! |
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.
I saw that in privilege.go
there are two functions called for verifying privileges of a non-current user:
RequestDynamicVerificationWithUser
RequestVerificationWithUser
Where 1 is used for checking system/admin privileges such as SUPER_USER
, RESTRICTED_USER_ADMIN
when performing ALTER USER
/SET PASSWORD
for super/admin users. 2 is used only for verifying view definer's privilege.
I think it might be too restricted to impose the same restriction on 1, that is - to not allow plugin users to be a super/admin user. Maybe we should allow this, and just call out explicitly that the verify privilege functions in the plugin will only be executed for the current user. And it's up to the plugin owner/operator to revoke unnecessary MySQL privileges.
What do you think? @lcwangchao
Do you mean if a user is created with a plugin, some privilege can only be revoked by himself? I think it is also some what restricted. I A plugin user may have two sets of privileges:
The real privileges of a session should be an intersection of those two sets. But in the |
@lcwangchao Please let me clarify. I meant that for revoking/checking those special privileges for a plugin user, TiDB should only check the priv set 1 (stored in TiDB) since it lacks information about priv set 2 at the execution time, unless the user being verified is the currently connected user itself. For example:
I think by implementing what you suggested, we are not only doing this, but also not allowing an admin user to change a plugin user's privilege too. That's because inside |
Maybe we can talk about some scenes. Suppose we have below user1:
And we have some sessions:
Currently, my though is: If For dropping table:
|
@lcwangchao Thanks for the review! I have addressed most of the comments and added more test cases to cover the scenario you described. Also submitted an issue for a potential bug found along the way: #54039. Would appreciate it if you could take a look too. Thanks! |
@lcwangchao Could you please take a look at the latest diffs? Thank you! |
@bb7133 could you also take a look? |
@bb7133 Could you please take a look at your convenience? Thank you! @lcwangchao Could we mark this PR as |
/ok-to-test |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #53494 +/- ##
=================================================
- Coverage 74.7618% 56.6448% -18.1170%
=================================================
Files 1523 1656 +133
Lines 361464 621501 +260037
=================================================
+ Hits 270237 352048 +81811
- Misses 71581 245928 +174347
- Partials 19646 23525 +3879
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bb7133, lcwangchao The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
@yzhan1: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What problem does this PR solve?
Implements the extension authentication plugin support. Refer to #53182 for design.
Issue Number: close #53181
Problem Summary:
TiDB developers can now implement new authentication plugin using the extension framework to keep proprietary code out of the core TiDB folders.
What changed and how does it work?
A new struct
extension.AuthPlugin
is created, where developers can implement their own authentication/authorization logic on top of TiDB. It achieves similar things to MySQL auth plugin by allowing developers implementing customized plugins.Functions defined in
extension.AuthPlugin
will be executed duringprivilege.ConnectionVerification
for authentication check during loginsprivilege.RequestVerification
andprivilege.DynamicRequestVerification
for extra authorization checks on top of existing MySQL privilege checksCheck List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.