Skip to content
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

Multi-scopes auth & Attach fix #1076

Merged
merged 14 commits into from
Feb 26, 2024
Merged

Multi-scopes auth & Attach fix #1076

merged 14 commits into from
Feb 26, 2024

Conversation

MarinPostma
Copy link
Contributor

@MarinPostma MarinPostma commented Feb 22, 2024

This PR adds support for multi-scope authentication, and fixes attach, and other quirks:

  • allow_attach is now a property of the namespace. If allow_attach is set to true, then other database can attach to it, given that they also have the right
  • allow_attach can be passed at namespace creation
  • before, authentication was only enabled if it was enabled globally, now, if a namespace has a verifying key, then a token is expected, otherwise, we fallback to global auth. This allows guarding namespaces, even if global auth is not set.
  • add a bunch of tests

@MarinPostma MarinPostma force-pushed the multi-ns-auth branch 5 times, most recently from 5928ef6 to 5da8564 Compare February 24, 2024 10:19
@MarinPostma MarinPostma marked this pull request as ready for review February 24, 2024 10:23
@MarinPostma MarinPostma changed the title WIP: multi-ns auth Multi-scopes auth & Attach fix Feb 24, 2024
@haaawk
Copy link
Contributor

haaawk commented Feb 26, 2024

Why can't we just allow attach on all namespaces? To attach a namespace JWT needs an appropriate claim isn't that enough?

@MarinPostma
Copy link
Contributor Author

From the dicussion we had, we all had, I understood that we wanted a killswitch for that feature. Furthermore, until we solve the issue I raised on Slack, I'd rather leave the ability to disable attach altogether.

@haaawk
Copy link
Contributor

haaawk commented Feb 26, 2024

From the dicussion we had, we all had, I understood that we wanted a killswitch for that feature. Furthermore, until we solve the issue I raised on Slack, I'd rather leave the ability to disable attach altogether.

That's fine. Let's leave it as is for now but eventually we might want to be able to set default for it per group so that each new namespace is allowed/not allowed automatically depending on what the owner of the group finds more useful.

)),
Authenticated::Authorized(a) => {
if !a.has_right(Scope::Namespace(namespace.clone()), perm) {
return Err(crate::Error::NotAuthorized(format!(
Copy link
Contributor

Choose a reason for hiding this comment

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

ultra nit: No need for return here.

pub fn merge_legacy(&mut self, namespace: NamespaceName, perm: Permission) {
let scope = match perm {
Permission::Read => self.read_only.get_or_insert_with(Default::default),
Permission::Write => self.read_only.get_or_insert_with(Default::default),
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be self.read_write?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch

Copy link
Contributor

@haaawk haaawk left a comment

Choose a reason for hiding this comment

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

LGTM

@MarinPostma MarinPostma added this pull request to the merge queue Feb 26, 2024
Merged via the queue into main with commit 52d8b8f Feb 26, 2024
17 checks passed
@MarinPostma MarinPostma deleted the multi-ns-auth branch February 26, 2024 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants