authz: Drop requirement for installing authz providers in every service#63743
Conversation
081686b to
541ac80
Compare
c1fc0b7 to
8788a18
Compare
There was a problem hiding this comment.
this join was missing, the authzquery conds could generate an invalid query here
There was a problem hiding this comment.
Is this an unrelated fix that you just noticed?
There was a problem hiding this comment.
no, now that perms are actually enforced in tests by default this showed in a SQL error during tests 🙈
There was a problem hiding this comment.
this matches how this is invoked at runtime
276943f to
56a265c
Compare
56a265c to
70d5438
Compare
70d5438 to
235c970
Compare
ggilmore
left a comment
There was a problem hiding this comment.
This looks good overall, but I'm a bit lost on some of the changes (the ones I commented on) - hard for me to tell if those changes are unrelated fixes or of I'm missing something about the impact of the change here
235c970 to
20e7396
Compare
pjlast
left a comment
There was a problem hiding this comment.
Seems good to me. Trusting tests and manual testing here as well
20e7396 to
89f2377
Compare
89f2377 to
e4136ae
Compare

This is a register call that is easy to forget. When forgotten, all queries against the repo store will block forever.
In addition, this adds a hard-dependency on conf to every services startup, plus a busy loop. With multi-tenant, this will not work great because authz providers would be a global, and we instead want most things to be ephemeral so they're per-provider. This is a step toward that, but doesn't yet remove the providers global variable.
Good news, it turns out that we don't actually need to register the providers in every service! The reason they were required was to check if zero providers are configured, or if authzbypass mode is enabled.
Authz bypass mode is usually ON, except when there are problems with the authz providers, meaning some authz providers might not be able to sync permissions. Bypassing of permissions is only ever happening if there are ALSO zero providers configured.
So this is basically an optimization for the case where an instance has zero authz configured so that the SQL queries are a bit simpler. This also helps in tests because with bypass mode on and no providers configured, authz enforcement is effectively off in the repo store.
This makes it so that in tests we need to do slightly more work, but also makes for a more realistic test vs at runtime setup. Also, it's highly recommended to use mocks for DB wherever possible in more high-level components to keep tests fast.
To never have a scenario where we accidentally mess up here and enable bypass mode erroneously, this PR drops that entirely. Authz is always enforced, but when a code host connection is unrestricted (i.e., will not spawn a provider) the repos are still visible, so this should be no change over before.
Test plan
The stack starts and works, and all CI tests are still passing. Code review should help as well.