-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
externalconn: grant ALL
on CREATE EXTERNAL CONNECTION
#86336
Conversation
} | ||
|
||
// Grant user `ALL` on the newly created External Connection. | ||
grantStatement := fmt.Sprintf(`GRANT ALL ON EXTERNAL CONNECTION "%s" TO %s`, |
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.
This should be Normalized
and not SQLIdentifier
// Normalized returns the normalized username, suitable for equality
// comparison and lookups. The username is unquoted.
func (s SQLUsername) Normalized() string { return s.u }
// SQLIdentifier returns the normalized username in a form
// suitable for parsing as a SQL identifier.
// The identifier is quoted if it contains special characters
// or it is a reserved keyword.
func (s SQLUsername) SQLIdentifier() string {
var buf bytes.Buffer
lexbase.EncodeRestrictedSQLIdent(&buf, s.u, lexbase.EncNoFlags)
return buf.String()
}
I think if you add a test by creating a username with "SELECT" it'll error out here
@RichardJCai if we use
Is the correct pattern to use |
Previously, the user that created the external connection was not granted any privileges as the creator/owner of the object. This diff changes this by granting the user `ALL` privileges. When synthetic privileges have a concept of owners, we should also set the owner of the External Connection object to the creator. This can happen once cockroachdb#86181 is addressed. There was also a small bug in the grant/revoke code where external connection names that required to be wrapped in `""` egs: `"foo-kms"` were being incorrectly stringified when creating the synthetic privilege path. This resulted in: ``` CREATE EXTERNAL CONNECTION "foo-kms" AS ... GRANT USAGE ON EXTERNAL CONNECTION "foo-kms" TO baz ``` To fail with a "foo-kms" cannot be found, even though it was infact created before attempting the grant. Tests have been added to test this case. Fixes: cockroachdb#86261 Release note (bug fix): Users that create an external connection are now granted `ALL` privileges on the object.
3d4400a
to
8b149a0
Compare
Oops you're right, I was thinking of it in the context of actually writing it to the |
Failures are unrelated and being tracked in #86376. TFTRs! bors r+ |
Build failed (retrying...): |
Build failed (retrying...): |
Build succeeded: |
Previously, the user that created the external connection
was not granted any privileges as the creator/owner of the
object. This diff changes this by granting the user
ALL
privileges.
When synthetic privileges have a concept of owners, we should
also set the owner of the External Connection object to the
creator. This can happen once #86181
is addressed.
There was also a small bug in the grant/revoke code where
external connection names that required to be wrapped in
""
egs:"foo-kms"
were being incorrectly stringified whencreating the synthetic privilege path. This resulted in:
To fail with a "foo-kms" cannot be found, even though it was
infact created before attempting the grant. Tests have been added to
test this case.
Fixes: #86261
Release note (bug fix): Users that create an external connection
are now granted
ALL
privileges on the object.Release justification: bug fix for new functionality