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

Child table creation fails silently if user does not have admin permissions for the schema containing the parent table #1161

Open
mdmelin opened this issue Jul 8, 2024 · 6 comments
Assignees
Labels

Comments

@mdmelin
Copy link

mdmelin commented Jul 8, 2024

Bug Report

Description

Thanks for all your work on datajoint! I noticed some strange behavior when trying to define dependent tables.

When creating a new table inside my own schema, I would like to be able to inherit from tables within a parent schema. However, this does not appear to work unless I have admin level privileges on the parent schema. This makes it hard for non-admin users to create their own tailored analysis schemas that might inherit tables from a parent schema shared by a lab.

When I run the code with the table definition, no error is thrown, but a SQL query reveals that the table is never created. When trying to query the table later, datajoint will then raise an error saying it does not exist.

I am not sure if this is a problem related to datajoint, or if I need to grant additional permissions on the database side of things. We're currently only granting SELECT and INSERT to the main schema for non-admin users.

Reproducibility

Include:

  • Windows 10
  • Python 3.11.5
  • MySQL Version 8.0.35
  • MySQL Deployment Strategy: Amazon RDS
  • DataJoint Version 0.14.1

Code to reproduce problem

Here is the code to reproduce the issue

Expected Behavior

When running the attached code, the Desk table should be created. However, this silently fails and it is not created on the database. Modifying the Desk definition to not include a parent table fixes the issue.

Additional Research and Context

  • Table dependencies from different schemas works fine when ALL PRIVILEGES are granted on both schemas
@mdmelin mdmelin added the bug label Jul 8, 2024
@dimitri-yatsenko
Copy link
Member

Thank you. Yes, the correct behavior is to raise an error.

@dimitri-yatsenko dimitri-yatsenko self-assigned this Jul 8, 2024
@mdmelin
Copy link
Author

mdmelin commented Jul 8, 2024

Hi @dimitri-yatsenko, thanks for clarifying. Are there permissions I can change that would make it possible to inherit from the main schema without granting admin-level permissions (e.g. DROP)? Thanks!

@dimitri-yatsenko
Copy link
Member

You can have another user with CREATE privilege run the code to create the table. Then the user with SELECT and INSERT privilege can use the code.

@mdmelin
Copy link
Author

mdmelin commented Jul 9, 2024

I did some poking around and ended up giving the non-admin user the REFERENCES privilege (giving CREATE allowed the user to create the table one time, but upon dropping it, the table could not be recreated under the same name). This appears to be sufficient for developing a personal schema with full permissions that references a lab/collaboration-wide schema with only SELECT, INSERT, and REFERENCES privileges granted.

Do you think there are any security risks giving this REFERENCES permission to all users on the lab-wide database? As far as I can tell, all it allows is foreign key references to the database.

@dimitri-yatsenko
Copy link
Member

Oh, yes, that's correct. REFERENCES should be included for the core tables where other tables can reference.

@mdmelin
Copy link
Author

mdmelin commented Jul 9, 2024

Great, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants