[teams 4/5] SQL authorization #3525
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Permissions for evaluating SQL/DML are not generally "actions", but more a set of permissions that are checked during evaluation.
To make this work with the teams feature, this patch extends
AuthCtxto allow checking a set of permissions as mandated by the spec. This set is a bit more fine-grained than "is owner", so as to avoid baking in the concept of teams/collaborators, or assumptions about what a role might entail. Both are likely to evolve in the future, so evaluation of permissions / capabilities should be confined to the impl of theAuthorizationtrait.Unlike "actions", the
AuthCtxmust be able to evaluate permission checks quickly and without side-effects, nor can it enter anasynccontext. In that sense, it is precomputed (if you will), and stored as a closure in theAuthCtxfor external authorization.A challenge posed is how to thread through the constructed
AuthCtxfor subscriptions.A tempting approach would have been to equip the
HostControllerwith the ability to summon anAuthCtx. That, however, would have created a gnarly circular dependency, because theHostControlleralso controls the controldb, which itself demands anAuthCtx.Instead, the
AuthCtxis obtained in the endpoint handler and passed to each method call that requires one. That's less pretty, but more effective.