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

Add authorization to Dashboard Controller and include owner #558

Open
wants to merge 1 commit into
base: 4.0
Choose a base branch
from

Conversation

x4d3
Copy link
Contributor

@x4d3 x4d3 commented Nov 1, 2017

Include owner in Dashboard management.
Improve Dashboard Controller to use ability. This unfortunately cannot be spec for now (#560 needs to be merged first)

@x4d3
Copy link
Contributor Author

x4d3 commented Nov 1, 2017

This PR is waiting on #535. Specs needs to be uncommented on DashboardController.

# Fully qualify template path to allow concern to be included in different modules
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ouranos We had to full qualify the template in order to reuse the DashboardController Concern in the TenantDashboard (See maestrano/opal-webstore#51) Do you see problems with that ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The linked PR uses the non-admin concern in an admin controller. Not the best approach as the authorization logics are supposed to be different (not the case in this controller for now - see below)
So don't change the framework but the opal-webstore project

@ouranos
Copy link
Contributor

ouranos commented Nov 3, 2017

Once #535 is merged:

  • please rebase this one to only includes relevant commits. It's a massive merge-fest :)
  • fix the specs
  • update description & title

then assign to me for review.

@x4d3 x4d3 force-pushed the feature/tenant-dashboards branch from b693bcd to 570ee8c Compare November 3, 2017 10:34
@x4d3 x4d3 changed the title Merge Feature/Tenant Dashboards to 4.0 Add Dashboard Owner Relationship + Temporarily fix issue with Alert not being loaded Nov 3, 2017
@x4d3 x4d3 force-pushed the feature/tenant-dashboards branch from 570ee8c to fff0362 Compare November 3, 2017 10:39
@ouranos
Copy link
Contributor

ouranos commented Nov 9, 2017

@xaun @x4d3 #535 is merged, please do the above.

@ouranos ouranos added this to the v4.0 milestone Nov 9, 2017
@x4d3 x4d3 force-pushed the feature/tenant-dashboards branch from fff0362 to 5610e79 Compare November 9, 2017 11:21
@x4d3
Copy link
Contributor Author

x4d3 commented Nov 9, 2017

@ouranos Ready to be merged

@@ -79,21 +90,19 @@ def copy
private

def dashboard(*included)
# TODO: [APIv2] Improve filtering by owner (owner_type?)
@dashboard ||= MnoEnterprise::Dashboard.where(owner_id: current_user.id).includes(included).find(params[:id].to_i).first
@dashboard ||= MnoEnterprise::Dashboard.includes(included).find(params[:id]).first
Copy link
Contributor

Choose a reason for hiding this comment

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

Security issue 😱
If you're removing the scoping, you should then look at implementing the TODO: authorization above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to, as it's checked later in the authorize.

Copy link
Contributor

Choose a reason for hiding this comment

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

This one?

# TODO: enable authorization
# authorize! :manage_dashboard, dashboard

end

def dashboards
# TODO: [APIv2] Improve filtering by owner (owner_type?)
@dashboards ||= MnoEnterprise::Dashboard.includes(*DASHBOARD_DEPENDENCIES).find(owner_id: current_user.id)
@dashboards ||= MnoEnterprise::Dashboard.includes(*DASHBOARD_DEPENDENCIES).where(owner_id: current_user.id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why has the TODO comment been removed?

# Fully qualify template path to allow concern to be included in different modules
Copy link
Contributor

Choose a reason for hiding this comment

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

The linked PR uses the non-admin concern in an admin controller. Not the best approach as the authorization logics are supposed to be different (not the case in this controller for now - see below)
So don't change the framework but the opal-webstore project

@x4d3 x4d3 force-pushed the feature/tenant-dashboards branch from 5610e79 to 9b066b1 Compare November 10, 2017 15:25
@x4d3 x4d3 changed the title Add Dashboard Owner Relationship + Temporarily fix issue with Alert not being loaded Add authorization to Dashboard Controller and include owner Nov 10, 2017
@x4d3
Copy link
Contributor Author

x4d3 commented Nov 10, 2017

@ouranos I've reworked entirely this PR to contains only the change related to the introduction of the owner relationship to Dashboard and reintroducing authorization.
I've udpated the title and description accordingly.

@x4d3 x4d3 force-pushed the feature/tenant-dashboards branch from 9b066b1 to 5e3e05f Compare November 10, 2017 15:33
Copy link
Contributor

@ouranos ouranos left a comment

Choose a reason for hiding this comment

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

Thanks, much better!

I wonder if we still need to authorize the create as a user could craft malicious request to build some random dashboard.
Should be ok as Impac!/IDM is checking access to the organization data before sending it.

I'd be inclined to wait for #560 to be merged so that can be spec'd

@ouranos
Copy link
Contributor

ouranos commented Nov 13, 2017

@cesar-tonnoir you might want to have a look at this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants