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

[security] improving the security scheme #1587

Merged
merged 9 commits into from Nov 17, 2016

Conversation

mistercrunch
Copy link
Member

No description provided.

sm.add_permission_role(gamma, p)
if PUBLIC_ROLE_LIKE_GAMMA:
sm.add_permission_role(public, p)
else:
Copy link
Member

Choose a reason for hiding this comment

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

could you add a todo to remove else case once the DB state is fixed ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm thinking we move to fully control these base roles, if people alter them they will be overwritten. People should create and compose new roles in their environment instead of altering the ones provided by Superset

Copy link
Member

Choose a reason for hiding this comment

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

gotcha

sm.add_permission_role(public_role, perm)
p.view_menu.name in {'SQL Lab'} or
p.permission.name in {'can_sql_json'}
):
Copy link
Member

Choose a reason for hiding this comment

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

add download csv endpoint here and maybe query search

qry = query.filter(self.model.perm.in_(self.get_perms()))
return qry
perms = self.get_view_menus('datasource_access')
logging.info(perms)
Copy link
Member

Choose a reason for hiding this comment

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

will be too noisy, could you remove logging here?

public_role = appbuilder.sm.find_role('Public')
perms = db.session.query(ab_models.PermissionView).all()
for perm in perms:
if (perm.permission.name == 'datasource_access' and
perm.view_menu and table_name in perm.view_menu.name):
perm.view_menu and table.perm in perm.view_menu.name):
print('-==-'*20)
Copy link
Member

Choose a reason for hiding this comment

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

s/print/logging.info

.filter_by(table_name='birth_names')
.one()
)
print(table.perm)
Copy link
Member

Choose a reason for hiding this comment

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

ditto s/print/logging.info

@@ -1841,29 +1858,6 @@ def sqllab_viz(self):
return redirect(url)

@has_access
@expose("/sql/<database_id>/")
Copy link
Member

Choose a reason for hiding this comment

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

is it intended ?

Copy link
Member Author

Choose a reason for hiding this comment

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

that's an old obsolete endpoint

@@ -1967,38 +1961,6 @@ def cached_key(self, key):
return "nope"

@has_access_api
@expose("/results/<key>/")
Copy link
Member

Choose a reason for hiding this comment

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

is it intended ?

Copy link
Member Author

Choose a reason for hiding this comment

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

oops

@@ -1967,7 +1960,6 @@ def cached_key(self, key):
return "nope"

@has_access_api
@expose("/results/<key>/")
Copy link
Member

Choose a reason for hiding this comment

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

you may need keep @expose

@bkyryliuk
Copy link
Member

LGTM once test is fixed and @expose is back.

@@ -23,6 +30,12 @@ class DatabaseSelect extends React.PureComponent {
const options = data.result.map((db) => ({ value: db.id, label: db.database_name }));
this.setState({ databaseOptions: options, databaseLoading: false });
this.props.actions.setDatabases(data.result);
if (data.result.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

it would be great to pass the server response here / check the response status

print("Starting server with command: " + cmd)
Popen(cmd, shell=True).wait()

@manager.command
Copy link
Member

Choose a reason for hiding this comment

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

Expected 2 blank lines, found 1

"""Inits the Superset application"""
security.sync_role_definitions()

@manager.option(
Copy link
Member

Choose a reason for hiding this comment

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

Expected 2 blank lines, found 1

if verbose:
print("[DB] : " + "{}".format(db.engine))

@manager.option(
Copy link
Member

Choose a reason for hiding this comment

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

Expected 2 blank lines, found 1

print("Loading [Unicode test data]")
data.load_unicode_test_data()

@manager.option(
Copy link
Member

Choose a reason for hiding this comment

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

Expected 2 blank lines, found 1

@@ -2178,6 +2206,9 @@ def get_having_filters(self, raw_filters):
filters = cond
return filters

sqla.event.listen(DruidDatasource, 'before_insert', set_perm)
Copy link
Member

Choose a reason for hiding this comment

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

datasource_name / cluster rename will change the permission and will revoke the user access to it, just an observation.

@@ -964,6 +983,19 @@ class LogModelView(SupersetModelView):
icon="fa-list-ol")


class QueryView(SupersetModelView):
datamodel = SQLAInterface(models.Query)
list_columns = ['user', 'database', 'status', 'start_time', 'start_time']
Copy link
Member

Choose a reason for hiding this comment

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

s/start_time/end_time
what about showing sql?

@@ -2263,7 +2273,6 @@ def show_traceback(self):
title=ascii_art.stacktrace,
art=ascii_art.error), 500

@has_access
Copy link
Member

Choose a reason for hiding this comment

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

I would keep @has_access for welcome too and would add it by default to the public role

@bkyryliuk
Copy link
Member

Great changes, code is more structured now ! Having more tests around basic roles would be great, but can be done later in separate PR.

@bkyryliuk
Copy link
Member

LGTM

@mistercrunch mistercrunch merged commit bce02e3 into apache:master Nov 17, 2016
@mistercrunch mistercrunch deleted the security branch November 17, 2016 19:58
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.14.0 labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants