-
Notifications
You must be signed in to change notification settings - Fork 331
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
Conversation
5928ef6
to
5da8564
Compare
Why can't we just allow attach on all namespaces? To attach a namespace JWT needs an appropriate claim isn't that enough? |
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!( |
There was a problem hiding this comment.
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.
libsql-server/src/auth/authorized.rs
Outdated
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), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
0b8ca95
to
96da442
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR adds support for multi-scope authentication, and fixes attach, and other quirks:
allow_attach
is now a property of the namespace. Ifallow_attach
is set to true, then other database can attach to it, given that they also have the rightallow_attach
can be passed at namespace creation