You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
142840: crosscluster/logical: add table level auth for REPLICATIONDEST r=dt a=msbutler
Epic: [CRDB-47102](https://cockroachlabs.atlassian.net/browse/CRDB-47102)
Release note (sql change): this patch allows a user to begin LDR on an existing
table if the user has a table level REPLICATIONDEST priv. Furthermore, this
patch allows a user to begin LDR onto an automatically created table if the
user has the parent database level CREATE privilege. Finally, during
bidirectional replication, this patch allows the user in the OG source URI,
which will begin the reverse stream, to authorize via this table level
REPLICATIONDEST priv.
Co-authored-by: Michael Butler <[email protected]>
testuser.ExpectErr(t, "user testuser does not have REPLICATIONDEST system privilege", createStmt, dbBURL.String())
2028
+
testuser.ExpectErr(t, "failed privilege check: table or system level REPLICATIONDEST privilege required: user testuser does not have REPLICATIONDEST privilege on relation tab", createStmt, dbBURL.String())
2026
2029
dbA.Exec(t, fmt.Sprintf("GRANT SYSTEM REPLICATIONDEST TO %s", username.TestUser))
dbA.Exec(t, `CREATE TABLE tab2 (x INT PRIMARY KEY)`)
2048
+
dbB.Exec(t, `CREATE TABLE tab2 (x INT PRIMARY KEY)`)
2049
+
2050
+
multiTableStmt:=`CREATE LOGICAL REPLICATION STREAM FROM TABLES (tab, tab2) ON $1 INTO TABLES (tab, tab2)`
2051
+
2052
+
testuser.ExpectErr(t, "failed privilege check: table or system level REPLICATIONDEST privilege required: user testuser does not have REPLICATIONDEST privilege on relation tab", multiTableStmt, dbBURL.String())
2053
+
2054
+
dbA.Exec(t, fmt.Sprintf(`GRANT REPLICATIONDEST ON TABLE tab TO %s`, username.TestUser))
2055
+
testuser.ExpectErr(t, "failed privilege check: table or system level REPLICATIONDEST privilege required: user testuser does not have REPLICATIONDEST privilege on relation tab2", multiTableStmt, dbBURL.String())
2056
+
2057
+
dbA.Exec(t, fmt.Sprintf(`GRANT REPLICATIONDEST ON TABLE tab2 TO %s`, username.TestUser))
2058
+
testuser.Exec(t, multiTableStmt, dbBURL.String())
2059
+
dbA.Exec(t, fmt.Sprintf(`REVOKE REPLICATIONDEST ON TABLE tab FROM %s`, username.TestUser))
2060
+
dbA.Exec(t, fmt.Sprintf(`REVOKE REPLICATIONDEST ON TABLE tab2 FROM %s`, username.TestUser))
dbB.Exec(t, fmt.Sprintf("GRANT SYSTEM REPLICATION TO %s", username.TestUser+"3"))
2074
+
createStmtBidi:="CREATE LOGICALLY REPLICATED TABLES (tab_clone_2, tab2_clone_2) FROM TABLES (tab, tab2) ON $1 WITH BIDIRECTIONAL ON $2"
2075
+
testuser.ExpectErr(t, " uri requires REPLICATIONDEST privilege for bidirectional replication: user testuser3 does not have REPLICATIONDEST privilege on relation tab", createStmtBidi, dbBURL2.String(), dbAURL.String())
2076
+
2077
+
dbB.Exec(t, fmt.Sprintf("GRANT SYSTEM REPLICATIONDEST TO %s", username.TestUser+"3"))
0 commit comments