-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
fix(security): dbs/clusters perm #10130
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
"""deprecate dbs.perm column | ||
|
||
Revision ID: a72cb0ebeb22 | ||
Revises: 743a117f0d98 | ||
Create Date: 2020-06-21 19:50:51.630917 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "a72cb0ebeb22" | ||
down_revision = "743a117f0d98" | ||
|
||
|
||
def upgrade(): | ||
with op.batch_alter_table("dbs") as batch_op: | ||
batch_op.drop_column("perm") | ||
|
||
|
||
def downgrade(): | ||
with op.batch_alter_table("dbs") as batch_op: | ||
batch_op.add_column(sa.Column("perm", sa.String(1000), nullable=True)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -244,7 +244,7 @@ def can_access_database(self, database: Union["Database", "DruidCluster"]) -> bo | |
return ( | ||
self.can_access_all_datasources() | ||
or self.can_access_all_databases() | ||
or self.can_access("database_access", database.perm) | ||
or self.can_access("database_access", database.perm) # type: ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised type checking has to be muted. Apparently mypy isn't comfortable with hybrid properties? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it struggles to identify which method this refers to. |
||
) | ||
|
||
def can_access_schema(self, datasource: "BaseDatasource") -> bool: | ||
|
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.
Is there some reason we want to keep this around and not just reference
perm
wherever needed?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.
@villbro it’s required here. Note the
set_perm
callback is still required as it has other logic besides merely setting theperm
column. For thedbs
andclusters
tableperm
andget_perm
are equivalent and hence no database record will be updated (this has always been the case for theclusters
table).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.
it is also used here: https://github.com/apache/incubator-superset/blob/550e78ff7c02491717960d39ef0bb861aba0f977/superset/security/manager.py#L820
https://github.com/apache/incubator-superset/blob/8e23d4f369f35724b34b14def8a5a8bafb1d2ecb/superset/models/core.py#L659
logic that keeps FAB security in sync with the other models