-
Notifications
You must be signed in to change notification settings - Fork 180
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
[ADAP-742] [Feature] Grants should handle database and schema level access. #715
Comments
two questions
usecaseif a dbt model is defined with the following grants configs {{
config(
grants = {'select': ['role_a']}
)
}}
select ... current behavior
desired behavior
potential solutiondbt-snowflake currently relies directly on the grants logic implemented in dbt-core's global project via all the The first place I thought where this new logic could be injected is within |
1: I'm not an expert, but I believe yes. 2: Maybe the indentation is messed up, but I believe you can be in a state where you have |
just came across #527 (comment) -- @jaysobel any instinct on what should be done in the case of managed schemas? |
@dataders No intuition |
iirc this is called discretionary access control and is possible (and my preferred way to do future grants) if you create the schema |
the way we handle it is to ignore any grant requests on managed schemas (details in #527). in the native implementation, a dbt warning or error both seems appropriate, but with multiple deployments with different RBAC models it would be nice to have a way to customize what role names are present in a given target, e.g. via a |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
@dataders , I'm commenting to keep this from auto-closing. I'm actually surprised dbt doesn't already do this. |
I think the fix is simpler than what was described above. At the end of the run, dbt can inspect the manifest come up with a list of roles + schemas required. Then just grant usage on those schemas to those roles. There's no harm in repeating the usage grant on every run. Either way you have to do something on every run. Either you are checking existing grants and doing "if else" logic... or, you just repeat the grant in a post-hook-like fashion. Implement it how you see best, but in order for "dbt grants" to be the single place we manage grants, we need this! (The same problem exists in other adaptors that I've used; Redshift for example) |
Is this your first time submitting a feature request?
Describe the feature
The dbt
grants
config presents as a declarative means to grantselect
on the output of a model. However, it does not cover database and schema level grants, resulting in incomplete behavior, relative to the current documentation:Currently dbt can write a model into a
schema
and grant to arole
when therole
does not haveusage
on theschema
, resulting in a 'successful run' that cannot actually be used as described. The docs above are true in only a narrow sense that the "permissions on the database object match the grants", but not the practical sense that therole
can now use the database object.As an example,
If
role_b
does not haveusage
on theint
schema, then they will not be able to select from the table. dbt will have granted select access on the table object, but notusage
on the schema object.This feels like an unexpected outcome given the declarative(-ish?) nature of other configs.
run
.role
did not exist... maybe this is a slippery slopeThis issue suggests that if a model is configured with
grants = {'select': ['role_b']}
thenrole_b
should be able to select from it after it is run, regardless of thedatabase
andschema
, and presumably by grantingusage
on both resources to the role.Fun fact: "schemas" and "schemata" are both valid plurals of
schema
.Describe alternatives you've considered
A job for
grant select on future tables
?Covered in the Appendix here.
grant select on future tables in <database>
can only be invoked bySECURITYADMIN
andACCOUNTADMIN
roles (docs) or delegated asmanage grants
, but it's a powerful global privilege (the role can grant anything to itself). It's unclear why "future stuff in one schema" is the same bucket as "current stuff, everywhere".grant usage on schema
is more than just table access!Yes, and maybe there should be some call-out, or additional opt-in flag to make it clear that
schema usage
is being granted.From my experience struggling with grants, and what I've seen in a few large projects, a common reaction to
insufficient privilege
errors is to sling more and broader grants around 'until it works'. In practice, this feature might have the opposite effect and actually improve the average level of grant specificity by averting rage-grants.Current art
dbt docs Blog: Updating our permissioning guidelines: grants as configs in dbt Core v1.2
This issue basically suggests Option B happen automatically.
Revoking Usage?
The current feature
grants
andrevokes
. If the feature is extended togrant usage
will it alsorevoke usage
from schemas, for example, when a role has no further objects within the schema from which it can select?Make this Snowflake's Problem
As Michael Urrutia points out in this Slack thread this is kind of Snowflake's fault for
grant select on db.schema.table
not doing what it says on the label (and creating yet another opportunity for dbt to be a superior abstraction).I will write a letter to the North Pole suggesting something from the Snowfolk; perhaps a more nuanced form of
manage grants
that allows the owner of aschema
togrant future select
within saidschema
?Who will this benefit?
Primary applications are not mission critical (as far as I know). Some examples:
dbt clone
in 1.6More broadly, Snowflake's
database
andschema
concepts feel like a filing systems with just two level, like the fixedfeature_1/2/3
columns of Activity Schema™️. dbt bakes in plenty of reliance on this addressing system. How many steps are left before aschema
and adatabase
are dbt things? Adding+schema
and+grants
configs indbt_project.yml
folder sections feels dangerously close to just treating these things as things. And this isdbt-snowflake
after all.I'm interested in hearing others' takes on whether dbt should do more Snowflake-y thing in general. Grants seem like a step along a path. At this point, my thinking is that because it is unavoidable, it should at least work well.
Are you interested in contributing this feature?
probably not
Anything else?
No response
The text was updated successfully, but these errors were encountered: