Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

authz: Drop requirement for installing authz providers in every service#63743

Merged
eseliger merged 1 commit into
mainfrom
es/no-authz-everywhere
Jul 30, 2024
Merged

authz: Drop requirement for installing authz providers in every service#63743
eseliger merged 1 commit into
mainfrom
es/no-authz-everywhere

Conversation

@eseliger

@eseliger eseliger commented Jul 10, 2024

Copy link
Copy Markdown
Member

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.

@cla-bot cla-bot Bot added the cla-signed label Jul 10, 2024
@github-actions github-actions Bot added team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all labels Jul 10, 2024
@eseliger eseliger force-pushed the es/no-authz-everywhere branch from 081686b to 541ac80 Compare July 19, 2024 09:59

eseliger commented Jul 19, 2024

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @eseliger and the rest of your teammates on Graphite Graphite

@eseliger eseliger force-pushed the es/no-authz-everywhere branch 3 times, most recently from c1fc0b7 to 8788a18 Compare July 19, 2024 18:54
@eseliger eseliger changed the title experiment: Drop requirement for installing authz providers everywhere authz: Drop requirement for installing authz providers in every service Jul 19, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this join was missing, the authzquery conds could generate an invalid query here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an unrelated fix that you just noticed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, now that perms are actually enforced in tests by default this showed in a SQL error during tests 🙈

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this matches how this is invoked at runtime

Comment thread internal/authz/providers/bitbucketcloud/authz.go Outdated

@ggilmore ggilmore left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@eseliger eseliger force-pushed the es/no-authz-everywhere branch from 235c970 to 20e7396 Compare July 28, 2024 14:44

@pjlast pjlast left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me. Trusting tests and manual testing here as well

@eseliger eseliger force-pushed the es/no-authz-everywhere branch from 20e7396 to 89f2377 Compare July 30, 2024 00:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/product-platform team/source Tickets under the purview of Source - the one Source to graph it all

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants