How to get parent url in brilliant app

I have enabled the Shiny application with an iframe on my website, and now I am trying to protect my Shiny application: I want the iframe to be available only on my website, and not directly with its URL.

<iframe name="rshiny" src="http://url-of-my-shiny-app/" style="border: none; width: 100%;height:800px;"> </iframe> 

To do this, I am trying to get the URL of the parent that contains the iframe inside my Shiny application and block it if it is a good website.

The problem is this: I found how to get the parent URL in many languages, but R. Does anyone know how I can do this?

I had another possible solution that is currently not working:

 postForm('http://url.php', .params = params, curl = curl, style="POST") 

I thought I could send the post variable from my site to my R application, for example a key, to allow access only to those websites that know the key. But I can’t make it work.

EDIT: I think this question is different from the link provided in the comments. Indeed, the proposed option does not seem to be applicable in R Shiny.

+4
source share
1 answer

I have found a solution!

Here you can find a way to get the "GET" variables in your brilliant app. https://github.com/brianbolt/rShinyApps/tree/master/getParameters.shiny . In my PHP code, I calculate the md5 password, which depends on the date, to change every day, and I use it as a GET parameter in my iframe:

 <iframe name="rshiny" src="youradress?bins=<?php echo $md5password;?"> </iframe> 

From this perspective, I can use it directly inside my code (see input$n_breaks in the code I shared). I create a reactive function on my .R server that calculates the same md5 password.

At the end, we compare it with the password specified in the parameters. If this is the same, we open the graphs, read the data ... Otherwise, we just stop the process.

0
source

All Articles