Embedded QuickSight dashboard with URL Action to another dashboard - amazon-quicksight

Scenario:
I have a QuickSight dashboard embedded into the web application which is appearing correctly.
This dashboard (Dashboard A) contains a URL action which links to a seperate dashboard (Dashboard B).
I used Chrome Tools to grab the embed URL for dashboard B and configured it as the URL Action in the Analysis:
https://eu-west-1.quicksight.aws.amazon.com/embed/yyyyyyyyyyyYYYYYYYYYYYyyyy/dashboards/xxxxxxx-xxxx-xxxx-xxxxxxxxxx
Now when the URL Action is clicked on the embedded Dashboard A, it correctly links to Dashboard B.
However if another user accesses the same embedded Dashboard A and clics the link, it results in
We can't display this page (Not authorized).
It seems like the first parameter yyyyyyyyyyyYYYYYYYYYYYyyyy is user specific, so the URL Action for Dashboard B cannot be hardcoded like this.
What is the correct approach for linking between embedded QuickSight dashboards. Is URL Actions the way to go, or is an alternative approach required?
Solution
The "embed token" (yyyyyyyyyyyYYYYYYYYYYYyyyy) for the URL Action must be passed from the client side embed script as a parameter. The value to be passed can be retreived by parsing the session URL from Dashboard A.
const embed = () => {
const options = {
url: props.sessionUrl,
...
parameters: {
embedToken: props.sessionUrl.split('/')[4]
},
...
};
QuickSightEmbedding.embedDashboard(options);
};
Then in QuickSight the parameter can be used to form the URL for the URL Action as follows. (Make sure to add embedToken as a string as parameter in the Quicksight analysis).
https://eu-west-1.quicksight.aws.amazon.com/embed/<<$embedToken>>/dashboards/xxxxxxx-xxxx-xxxx-xxxxxxxxxx
Embedded Dashboard A then correctly links to embedded Dashboard B when viewed by any user.

One alternative could be to generate the embed URL for dashboards A and B separately in your web application and pass the embed URL of Dashboard B as an external parameter for Dashboard A. Since you can use parameters inside an action URL, it should work.

Related

Where do I get the value for `shopOrigin` when using Shopify app bridge?

Throughout the documentation for the new App Bridge, Shopify refers to the shopOrigin value and how it's used to configure the Provider from app-bridge-react but they never specify how to get this value?
The react app is loaded inside of an iframe and the src includes the shopOrigin value as a query string param called shop, but when I try the following code I get the error window is not defined:
const params = queryString.parse(window.location.search);
const config = {
apiKey: process.env.SHOPIFY_API_KEY,
shopOrigin: params.shop,
};
1) Why would I be getting window is not defined in javascript code running in a browser?! This makes no sense to me
2) If this value can be read from of the provided libraries such as #shopufy/app-bridge-react please tell me how
Unless you're using a library tailored specifically to Shopify, you have to manually save the shop origin during OAuth authorization.
Hopefully this Shopify tutorial is of some assistance
The shopOrigin is available within your browser cookies.
If you followed the Shopify development for react and Node.js, you should already saved this after the Shopify authentification.
I am not sure what exactly is the need for shopOrigin, if you just wanted to go to admin section of the shop from client side you can use Redirect in app bridge. otherwise you can store the shop detail on server during auth process and create a get api to retrive the details on client side as needed.

Laravel 5.1 use session to restrict direct access using urls users based on user role

I have 2 laravel projects, 1 for the front end where i m using html css angularjs. The second for api controllers. I call using http post and get the api controllers functions using angularjs to get content data.
In the front end i have a menu this menu appears differently based on user role, if admin or no.
This is done. My problem is the access for views using the url in the browser.
So I have a query where I get for each user what modules in the menu can he see. Now I'm putting the result in Laravel session.
$menu = DB::select menu by user id ... //Getting menu query based on user if admin or no
session(["menu" => $menu);
return session('menu');
I'm getting the results and the menu is showing good in the website based on the logged user if he s admin or no.
Now, to solve the direct url access issue, I want to use this session and compare the url to this session, if the url exists in the session i will let him access, if no i will redirect him to somewhere.
any idea?
I would strongly suggest looking at the Laravel documentation on Authorization before going too far down a custom implementation:
https://laravel.com/docs/5.1/authorization
Without knowing more about how your front-end and back-end applications interact with each other, it is a little difficult to get into speciifics but i shall do my best.
Each page returned by Laravel has access to a Request object which contains information about the request which returned the page. You can access this Request and its assocaited Route using Laravels helper functions (if you are not passing it to the view already). The getPrefix() method will return the root relative url which you can then use as you see fit. For example:
// Return and store the URL as a string
$url = request()->route()->getPrefix();
// Check your session for the URL/s you want to allow and compare to the stored URL
if (session()->get('URL') == $url) {
// User is allowed access to the page
// Do something ...
} else {
// User is not allowed access to this page
// Redirect back or to a route of your choice
return redirect()->back();
}
I hope this gives you some ideas, good luck!

$urlRouteProvider, simple routing

Can't get my head around $urlRouterPovider...
basically whenever I go to a link it should load associated view and controller. So that works.
$urlRouterProvider.when("/","/home")
$urlRouterProvider.otherwise("/error")
$stateProvider.state('views', {
url: "/:view",
templateUrl: function(stateParams, formResolver) {
return "views/" + stateParams.view + "/" + stateParams.view + "-view.html";
},
controllerProvider: function($stateParams) {
return "" + $stateParams.view + "Ctrl";
}
});
So whenever user goes to http://localhost:3030/#/foo, it loads "views/foo/foo.html" with controller as "fooCtrl", and goes to home by default, and for all other cases errror.
That is cool. What I need though, whenever user goes to http://localhost:3030/#/auth it would redirect to "/auth" on the server, skipping stateProvider. Currently it sees that as a state and tries to find corresponding view and controller.
If you need to redirect them to the server you need to leave out the #/ part of the URL.
The browser ignores the the #/ portion of the URL, which is how AngularJS is able to allow the page you server from localhost:3030/#/ handle the request. This is essentially still just requesting localhost:3030/
If you are wanting to do a true redirect or navigation to /auth on your server, ignore state for that request - you want your browser to make a straight-up HTTP request pointed directly at your server. Use /auth as the action in your form, or post to /auth from within your controller. When you are done on the server, redirect the user back to your Angular application.
Remember as well that you need to have some mechanism for your AngularJS application to know ehnIn our applications, we have the server set a cookie with a JWT token in it that is then used by the AngularJS application to retrieve the user information. This way the AngularJS application knows how to tell when a the user is really logged in (vs. a user going to a URL that represents a logged-in state).

Backbone routing - direct URL

I'm building an app where I have a server that works on REST API and returns me list of users.
I build an backbone module where I render the list of user I get from the server and display it on a page. I question the server about the users according to date, for example -
http://localhost/getUsers/20021989/20021990 - So I get only the users that were born between those dates.
I added the backbone router that each time that I choose a date it navigates to a function getUsers(start, end):
routes: {
"getUsers/:start/:end": "getUsersPreview",
},
and the function is:
getUsersPreview: function(start, end) {
some code here
}
The event is fired whenever I press the button, but when I copy-paste the URL into other tab (http://localhost/#getUsers/20021989/20021990) - It just redirects to the main page or something.
I'm using also Laravel framework for the server side coding.
When a Router is created, you should call Backbone.history.start() to begin monitoring hashchange events, and dispatching routes. Have you called it?

Extracting values that appear in URLs after a post in JMeter

I have an app that I am trying to load test with JMeter, and I am unable to extract a value from an URL, that is generated after HTTP POST.
The app flow (simplified) goes something like this, with corresponding URLs:
Login: http://host:port/login
Go to Dashboard (HTTP GET): http://host:port/dashboard
Click "Create Content" (HTTP GET): http://host:port/$string1/$string2=/create
Enter data, click "Submit" (HTTP POST) now URL is: http://host:port/$string1/$string2=/content/$string3
$string1, $string2 & $string3 are randomly generated; $string1 & $string2 are available in the body at the dashboard URL (which are easily extracted using regex); $string3 however is returned after content is created. I need $string3 at Step 4 above to view the newly created content, and proceed with next steps in my script.
I don't have access to the internals of the app or the server it is on.
Sanity check:
Is this a chicken-egg situation?
Or am I missing something in JMeter?
Any way around this problem?
I assume after you click "submit" it's a post request that will start the create content process, then get a redirect reply from the server. (you can verify if it's a redirect reply in tree view)
Uncheck the redirect option in Jmeter and add a regex extractor element to the same request.
Then extract the redirect URL with something like Object moved to <a href="/(.+?)">here and in the next HTTP request element you can use that extracted as variable to Path like ${string3}!

Resources