-
Notifications
You must be signed in to change notification settings - Fork 100
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
fix: allow members of source table to create vectorizer #254
Conversation
b9d68d3
to
b8ead49
Compare
-- don't let anyone but the owner of the source table call this | ||
select k.relowner operator(pg_catalog.=) pg_catalog.session_user()::pg_catalog.regrole | ||
-- don't let anyone but the owner (or members of the owner's role) of the source table call this | ||
select pg_catalog.pg_has_role(_vectorizer_create_dependencies.caller, k.relowner, 'MEMBER') |
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.
weird attribute qualification (_vectorizer_create_dependencies.caller instead of just caller), why?
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
drop function if exists ai._vectorizer_create_dependencies(integer); | ||
|
||
-- https://stackoverflow.com/a/42011279 | ||
create domain whoami as name |
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.
don't we want to schema qualify it as well?
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.
yes, done
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.
Looks good (a few nits)
1b1c839
to
bdc11b5
Compare
bdc11b5
to
12082d3
Compare
@@ -0,0 +1 @@ | |||
drop function if exists ai._vectorizer_create_dependencies(integer); |
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.
Wait why do we need this
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.
doh - we don't. It was a stray leftover from before I removed some other bits.
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.
fixed.
In f68e73a we added support for cascading the source/target table drop to the queue and other dependent objects. In adding this, we added a security definer function which asserts that the owner of the source table is calling the security definer function. Due to how security definer functions work with `current_user`, the ownership check opted to use `session_user` to check ownership. This is problematic because in connections which use `SET ROLE`, the `session_user` may not be the same as `current_user`. This commit relaxes the ownership check to check whether the current user is a member of the role that owns the source table.
12082d3
to
a0fa061
Compare
In f68e73a we added support for cascading the source/target table drop to the queue and other dependent objects. In adding this, we added a security definer function which asserts that the owner of the source table is calling the security definer function.
Due to how security definer functions work with
current_user
, the ownership check opted to usesession_user
to check ownership. This is problematic because in connections which useSET ROLE
, thesession_user
may not be the same ascurrent_user
.This commit relaxes the ownership check to check whether the current
user is a member of the role that owns the source table.