-
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
*: create a user using tidb_auth_token
authentication
#38585
Changes from 30 commits
7f6f17f
d21fab3
28b9548
7be6f51
ca7a000
a1e3c5f
d559001
ab25f46
10476c2
13a4b0f
c50c762
241aea7
16a8ec5
a5adcf7
23156c9
a2b0cf9
13c7567
536ec01
dd8b19a
01d21df
ff20723
b09987b
b3034f4
c39474b
50b54bd
a758fb6
daed722
b2f1d75
5f3294d
340811b
ffc937c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -712,6 +712,29 @@ func TestUser(t *testing.T) { | |
dropUserSQL = `DROP USER IF EXISTS 'test1'@'localhost' ;` | ||
tk.MustExec(dropUserSQL) | ||
|
||
// Test create/alter user with `tidb_auth_token` | ||
tk.MustExec(`CREATE USER token_user IDENTIFIED WITH 'tidb_auth_token' REQUIRE token_issuer 'issuer-abc'`) | ||
tk.MustQuery(`SELECT plugin, token_issuer FROM mysql.user WHERE user = 'token_user'`).Check(testkit.Rows("tidb_auth_token issuer-abc")) | ||
tk.MustExec(`ALTER USER token_user REQUIRE token_issuer 'issuer-123'`) | ||
tk.MustQuery(`SELECT plugin, token_issuer FROM mysql.user WHERE user = 'token_user'`).Check(testkit.Rows("tidb_auth_token issuer-123")) | ||
tk.MustExec(`ALTER USER token_user IDENTIFIED WITH 'tidb_auth_token'`) | ||
tk.MustExec(`CREATE USER token_user1 IDENTIFIED WITH 'tidb_auth_token'`) | ||
tk.MustQuery(`show warnings`).Check(testkit.RowsWithSep("|", "Warning|1105|TOKEN_ISSUER is needed for 'tidb_auth_token' user, please use 'alter user' to declare it")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is the original specification of this feature, could you double confirm if this is expected?(Although the behavior is different, IMHO this is fine). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO, I think it is expected. The warning is just for the missing To be honest I think all the warning for this auth plugin is not necessary for our general users. If they indeed miss something in |
||
tk.MustExec(`CREATE USER temp_user IDENTIFIED WITH 'mysql_native_password' BY '1234' REQUIRE token_issuer 'issuer-abc'`) | ||
tk.MustQuery(`show warnings`).Check(testkit.RowsWithSep("|", "Warning|1105|TOKEN_ISSUER is not needed for 'mysql_native_password' user")) | ||
tk.MustExec(`ALTER USER temp_user IDENTIFIED WITH 'tidb_auth_token' REQUIRE token_issuer 'issuer-abc'`) | ||
tk.MustQuery(`show warnings`).Check(testkit.Rows()) | ||
tk.MustExec(`ALTER USER temp_user IDENTIFIED WITH 'mysql_native_password' REQUIRE token_issuer 'issuer-abc'`) | ||
tk.MustQuery(`show warnings`).Check(testkit.RowsWithSep("|", "Warning|1105|TOKEN_ISSUER is not needed for the auth plugin")) | ||
tk.MustExec(`ALTER USER temp_user IDENTIFIED WITH 'tidb_auth_token'`) | ||
tk.MustQuery(`show warnings`).Check(testkit.RowsWithSep("|", "Warning|1105|Auth plugin 'tidb_auth_plugin' needs TOKEN_ISSUER")) | ||
tk.MustExec(`ALTER USER token_user REQUIRE SSL`) | ||
tk.MustQuery(`show warnings`).Check(testkit.Rows()) | ||
tk.MustExec(`ALTER USER token_user IDENTIFIED WITH 'mysql_native_password' BY '1234'`) | ||
tk.MustQuery(`show warnings`).Check(testkit.Rows()) | ||
tk.MustExec(`ALTER USER token_user IDENTIFIED WITH 'tidb_auth_token' REQUIRE token_issuer 'issuer-abc'`) | ||
tk.MustQuery(`show warnings`).Check(testkit.Rows()) | ||
|
||
// Test alter user. | ||
createUserSQL = `CREATE USER 'test1'@'localhost' IDENTIFIED BY '123', 'test2'@'localhost' IDENTIFIED BY '123', 'test3'@'localhost' IDENTIFIED BY '123', 'test4'@'localhost' IDENTIFIED BY '123';` | ||
tk.MustExec(createUserSQL) | ||
|
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.