Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show only Slices and Dashboards users have access to (#404)
* Introducing more security features * Many to many owners for slices and dashboards * Slices are filtered to only slices that the user has access to * Adding unit tests
- Loading branch information
1 parent
ab64a26
commit b634d03
Showing
5 changed files
with
205 additions
and
42 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
caravel/migrations/versions/4fa88fe24e94_owners_many_to_many.py
This file contains 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,38 @@ | ||
"""owners_many_to_many | ||
Revision ID: 4fa88fe24e94 | ||
Revises: b4456560d4f3 | ||
Create Date: 2016-04-15 17:58:33.842012 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '4fa88fe24e94' | ||
down_revision = 'b4456560d4f3' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
def upgrade(): | ||
op.create_table('dashboard_user', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('user_id', sa.Integer(), nullable=True), | ||
sa.Column('dashboard_id', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['dashboard_id'], [u'dashboards.id'], ), | ||
sa.ForeignKeyConstraint(['user_id'], [u'ab_user.id'], ), | ||
sa.PrimaryKeyConstraint('id'), | ||
) | ||
op.create_table('slice_user', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('user_id', sa.Integer(), nullable=True), | ||
sa.Column('slice_id', sa.Integer(), nullable=True), | ||
sa.ForeignKeyConstraint(['slice_id'], [u'slices.id'], ), | ||
sa.ForeignKeyConstraint(['user_id'], [u'ab_user.id'], ), | ||
sa.PrimaryKeyConstraint('id'), | ||
) | ||
|
||
|
||
def downgrade(): | ||
op.drop_table('slice_user') | ||
op.drop_table('dashboard_user') |
33 changes: 33 additions & 0 deletions
33
caravel/migrations/versions/c3a8f8611885_materializing_permission.py
This file contains 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,33 @@ | ||
"""Materializing permission | ||
Revision ID: c3a8f8611885 | ||
Revises: 4fa88fe24e94 | ||
Create Date: 2016-04-25 08:54:04.303859 | ||
""" | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'c3a8f8611885' | ||
down_revision = '4fa88fe24e94' | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from caravel import db | ||
from caravel import models | ||
|
||
|
||
def upgrade(): | ||
bind = op.get_bind() | ||
op.add_column('slices', sa.Column('perm', sa.String(length=2000), nullable=True)) | ||
session = db.Session(bind=bind) | ||
|
||
for slc in session.query(models.Slice).all(): | ||
if slc.datasource: | ||
slc.perm = slc.datasource.perm | ||
session.merge(slc) | ||
session.commit() | ||
db.session.close() | ||
|
||
|
||
def downgrade(): | ||
op.drop_column('slices', 'perm') |
This file contains 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 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
Oops, something went wrong.