Skip to content

Commit

Permalink
Fixing druid culster perms to mirror sqla databases (#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 16, 2016
1 parent 2adc8a0 commit edcc2a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions caravel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,9 @@ def refresh_datasources(self):
for datasource in self.get_datasources():
if datasource not in config.get('DRUID_DATA_SOURCE_BLACKLIST'):
DruidDatasource.sync_to_db(datasource, self)
@property
def perm(self):
return "[{obj.cluster_name}].(id:{obj.id})".format(obj=self)


class DruidDatasource(Model, AuditMixinNullable, Queryable):
Expand Down
7 changes: 6 additions & 1 deletion caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,11 @@ class DruidClusterModelView(CaravelModelView, DeleteMixin): # noqa
'broker_port': _("Broker Port"),
'broker_endpoint': _("Broker Endpoint"),
}
def pre_add(self, db):
utils.merge_perm(sm, 'database_access', db.perm)

def pre_update(self, db):
self.pre_add(db)


if config['DRUID_IS_ACTIVE']:
Expand Down Expand Up @@ -1613,7 +1618,7 @@ def csv(self, client_id):

if not self.database_access(query.database):
flash(get_database_access_error_msg(query.database.database_name))
redirect('/')
return redirect('/')

sql = query.select_sql or query.sql
df = query.database.get_df(sql, query.schema)
Expand Down

0 comments on commit edcc2a1

Please sign in to comment.