-
Notifications
You must be signed in to change notification settings - Fork 32
Function user permissions ✨ 🗃️ #7764
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
Merged
mergify
merged 22 commits into
ITISFoundation:master
from
wvangeit:func_user_permissions
May 30, 2025
Merged
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
db36ccf
Add user permission tables and rpc service
wvangeit 00f61ee
Shorten func foreign key
wvangeit 63f76a3
Shorten foreign key
wvangeit 71e62b7
All web and api tests working with func permissions
wvangeit 731687e
Add more function permission tests
wvangeit 35235ed
Fix last commit
wvangeit 784827c
Merge branch 'master' into func_user_permissions
wvangeit 97c2272
Add db migration script for function access rights
wvangeit 9970b4d
Update openapi specs
wvangeit 2895da8
Work around mypy bug
wvangeit 1906e8f
Merge branch 'master' into func_user_permissions
wvangeit 0ab2a55
Address comments in the PR
wvangeit cb53ca1
Merge branch 'func_user_permissions' of github.com:wvangeit/osparc-si…
wvangeit 9f1e354
Remove the user_id column from function access tables
wvangeit 222b59d
Removed user_id column from function access tables
wvangeit 7f63f95
Merge branch 'master' into func_user_permissions
wvangeit 6971be0
Replace more positiveint with userid
wvangeit 6caac7c
Merge branch 'func_user_permissions' of github.com:wvangeit/osparc-si…
wvangeit bed6155
Last switch to UserID
wvangeit 330943d
Merge branch 'master' into func_user_permissions
wvangeit 3395246
Remove func migration script
wvangeit 3dfd738
Fix function db migration after master merge
wvangeit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
191 changes: 191 additions & 0 deletions
191
...c/simcore_postgres_database/migration/versions/d3982ce629b9_add_function_access_rights.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| """Add function access rights | ||
| Revision ID: d3982ce629b9 | ||
| Revises: 278daef7e99d | ||
| Create Date: 2025-05-28 06:29:49.436254+00:00 | ||
| """ | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
| from sqlalchemy.dialects import postgresql | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "d3982ce629b9" | ||
| down_revision = "278daef7e99d" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_table( | ||
| "funcapi_function_job_collections_access_rights", | ||
| sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), | ||
| sa.Column( | ||
| "function_job_collection_uuid", | ||
| postgresql.UUID(as_uuid=True), | ||
| nullable=False, | ||
| ), | ||
| sa.Column("user_id", sa.BigInteger(), nullable=True), | ||
wvangeit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sa.Column("group_id", sa.BigInteger(), nullable=True), | ||
| sa.Column("read", sa.Boolean(), nullable=True), | ||
| sa.Column("write", sa.Boolean(), nullable=True), | ||
| sa.Column("execute", sa.Boolean(), nullable=True), | ||
| sa.Column( | ||
| "created", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.text("now()"), | ||
| nullable=False, | ||
| ), | ||
| sa.Column( | ||
| "modified", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.text("now()"), | ||
| nullable=False, | ||
| ), | ||
| sa.CheckConstraint( | ||
| "user_id IS NULL AND group_id IS NOT NULL OR user_id IS NOT NULL AND group_id IS NULL", | ||
wvangeit marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| name="ck_user_or_group_exclusive", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["function_job_collection_uuid"], | ||
| ["funcapi_function_job_collections.uuid"], | ||
| name="fk_func_access_to_func_job_colls_to_func_job_coll_uuid", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["group_id"], | ||
| ["groups.gid"], | ||
| name="fk_func_access_to_groups_group_id", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["user_id"], | ||
| ["users.id"], | ||
| name="fk_func_access_to_users_user_id", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.PrimaryKeyConstraint("id"), | ||
| sa.UniqueConstraint( | ||
| "user_id", | ||
| "group_id", | ||
| name="uq_funcapi_function_job_colls_access_rights_user_group", | ||
| ), | ||
| ) | ||
| op.create_table( | ||
| "funcapi_function_jobs_access_rights", | ||
| sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), | ||
| sa.Column("function_job_uuid", postgresql.UUID(as_uuid=True), nullable=False), | ||
| sa.Column("user_id", sa.BigInteger(), nullable=True), | ||
| sa.Column("group_id", sa.BigInteger(), nullable=True), | ||
| sa.Column("read", sa.Boolean(), nullable=True), | ||
| sa.Column("write", sa.Boolean(), nullable=True), | ||
| sa.Column("execute", sa.Boolean(), nullable=True), | ||
| sa.Column( | ||
| "created", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.text("now()"), | ||
| nullable=False, | ||
| ), | ||
| sa.Column( | ||
| "modified", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.text("now()"), | ||
| nullable=False, | ||
| ), | ||
| sa.CheckConstraint( | ||
| "user_id IS NULL AND group_id IS NOT NULL OR user_id IS NOT NULL AND group_id IS NULL", | ||
| name="ck_user_or_group_exclusive", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["function_job_uuid"], | ||
| ["funcapi_function_jobs.uuid"], | ||
| name="fk_func_access_to_func_jobs_to_func_job_uuid", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["group_id"], | ||
| ["groups.gid"], | ||
| name="fk_func_access_to_groups_group_id", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["user_id"], | ||
| ["users.id"], | ||
| name="fk_func_access_to_users_user_id", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.PrimaryKeyConstraint("id"), | ||
| sa.UniqueConstraint( | ||
| "user_id", | ||
| "group_id", | ||
| name="uq_funcapi_function_jobs_access_rights_user_group", | ||
| ), | ||
| ) | ||
| op.create_table( | ||
| "funcapi_functions_access_rights", | ||
| sa.Column("id", sa.Integer(), autoincrement=True, nullable=False), | ||
| sa.Column("function_uuid", postgresql.UUID(as_uuid=True), nullable=False), | ||
| sa.Column("user_id", sa.BigInteger(), nullable=True), | ||
| sa.Column("group_id", sa.BigInteger(), nullable=True), | ||
| sa.Column("read", sa.Boolean(), nullable=True), | ||
| sa.Column("write", sa.Boolean(), nullable=True), | ||
| sa.Column("execute", sa.Boolean(), nullable=True), | ||
| sa.Column( | ||
| "created", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.text("now()"), | ||
| nullable=False, | ||
| ), | ||
| sa.Column( | ||
| "modified", | ||
| sa.DateTime(timezone=True), | ||
| server_default=sa.text("now()"), | ||
| nullable=False, | ||
| ), | ||
| sa.CheckConstraint( | ||
| "user_id IS NULL AND group_id IS NOT NULL OR user_id IS NOT NULL AND group_id IS NULL", | ||
| name="ck_user_or_group_exclusive", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["function_uuid"], | ||
| ["funcapi_functions.uuid"], | ||
| name="fk_func_access_to_func_to_func_uuid", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["group_id"], | ||
| ["groups.gid"], | ||
| name="fk_func_access_to_groups_group_id", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["user_id"], | ||
| ["users.id"], | ||
| name="fk_func_access_to_users_user_id", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.PrimaryKeyConstraint("id"), | ||
| sa.UniqueConstraint( | ||
| "user_id", "group_id", name="uq_funcapi_functions_access_rights_user_group" | ||
| ), | ||
| ) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_table("funcapi_functions_access_rights") | ||
| op.drop_table("funcapi_function_jobs_access_rights") | ||
| op.drop_table("funcapi_function_job_collections_access_rights") | ||
| # ### end Alembic commands ### | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.