Skip to content

DD-31 dashboard anonymous accessible only with hash#56

Merged
9 commits merged intodashboardfrom
DD-31-dashboard-hash
Sep 18, 2018
Merged

DD-31 dashboard anonymous accessible only with hash#56
9 commits merged intodashboardfrom
DD-31-dashboard-hash

Conversation

@ghost
Copy link

@ghost ghost commented Sep 13, 2018

  • add hash to instance in order to access the dashboard report page with a special hash code, when not logged in
  • change default routes from RouteConfig
  • edit TimeZoneController action, because the id, which is a string in the timezone case, is mistaken as an action controller
  • change report angular controller, to allow the page to be loaded if the user is logged and the page to be loaded in anonymous mode if the user is not logged and only if the hash is correct for that specific report page

- add hash to instance in order to access the dashboard report page with a special hash code, when not logged in
- change default routes from RouteConfig
@ghost ghost changed the title DD-31 DD-31 dashboard anonymous accessible only with hash Sep 13, 2018
@ghost ghost requested a review from Sebyd September 13, 2018 10:49
report: function ($http, $location, $route) {
var params = { instanceId: $route.current.params.instanceId, hash: $route.current.params.hash };

$http.get('api/report/isDashboardAvailable', { params: params })
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this? Can't we just have the page with a message instead? Like "No content yet" or something like that.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, but before that I need to make sure the whole url is ok (instanceId and instance hash). Because I could just guess the instanceId, and just put a random string instead of hash. This method checks if the url is ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not put directly the hash as a query string param? So it needs to match that in order to get you to the dashboard.

Copy link
Author

Choose a reason for hiding this comment

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

I don't exactly understand. I still need to make a call to the server to check on that side if the hash is ok. The alternative would be to get the hash before and store it in the js, but that's just bad. Another alternative is to make the get of the dashboard with hash as well, and to throw an error which will come on js and check if it's the one related to the hash.

Are you talking about the last option?

Copy link

Choose a reason for hiding this comment

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

yes, i think he is thinking about the last option. it's kind of weird to have an endpoint that checks if the dashboard is available. when you request the dashboard, if it's not available, just return there a boolean or something

Copy link
Author

Choose a reason for hiding this comment

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

Ok, roger.

routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
defaults: new { id = RouteParameter.Optional },
constraints: new { id = @"^$|\d+"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this is the best solution. The id is not necessarily long. There can be string id's as well in the future.

Copy link
Author

Choose a reason for hiding this comment

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

I came across this problem, but I found no other way to make it generic. If the id should be a string, then the method should be named exactly and the parameter received with FromUri.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this problem occur? So that I can have a look at the controller

Copy link
Author

Choose a reason for hiding this comment

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

App.js, Timezone. I changed in this pull request as well.

Copy link
Contributor

@Sebyd Sebyd Sep 14, 2018

Choose a reason for hiding this comment

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

The instances controller works the same way. There is one method with Get() and one with Get(id). And they worked both.
The mistake that you do is that you pass the name of the method and it is considered to be the id. If you want the get the resources you do: http.get(api/controller) -> this gets the list. http.get(api/controller/id) -> gets the element. Try this way without the routes changed. It should work.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, and what happens if I want multiple parameters? Also, there is one hardcoded route for the account controller, so making a generic change for the difference between the id and action seems like a good thing to do.

Georgian Tanase added 7 commits September 14, 2018 19:53
- update logic to verify the validity of the url in the request for getting the dashboard, instead of making another pre-request
- update the api url
- update the conditions for dashboard availability
- restore routes changes
- update the angular call for getting the dashboard
- add parameter to get the unavailable page for dashboard
- restore some changes
- restore unwanted change
- refactor code
ctrl.isLoading = true;

$http.get("/api/report/" + ctrl.instanceId)
$http.get("/api/report/?instanceId=" + ctrl.instanceId + "&hash=" + ctrl.hash + "&isAuthenticated=" + isAuth)
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the "/" here. it should be "report?instanceId="

public List<DashboardItem> Items { get; set; }


public static DashboardData Unavailable
Copy link
Contributor

Choose a reason for hiding this comment

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

make this a method instead of a property. not all objects of type DashboardData have an invalid DashboardData property on them.
Instead, just make this as a method that returns the same thing. Also keep the name.

- refactor
@ghost ghost merged commit 286fea0 into dashboard Sep 18, 2018
@ghost ghost deleted the DD-31-dashboard-hash branch September 18, 2018 07:50
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant