如何在闪亮的应用程序中获取父URL [英] How to get parent URL in a shiny-app

查看:277
本文介绍了如何在闪亮的应用程序中获取父URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站中嵌入了一个带有iframe的Shiny应用程序,我现在正在尝试保护我的Shiny应用程序:我希望iframe只能在我的网站上访问,而不是直接使用其URL。

I embedded a Shiny application with an iframe in my website, and I am now trying to protect my Shiny application : I want the iframe to be reachable only in my website, not directly with its URL.

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

为此,我试图获取包含我内部iframe的父级的URL闪亮的应用程序,并阻止它是否不是一个好的网站。

To do that, I am trying to get the URL of the parent which contains the iframe inside of my Shiny-app, and block it whether it's not the good website.

问题是:我找到了如何用多种语言获取URL父级,但是R.有人知道我该怎么办吗?

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

我有另一个可能的解决方案,暂时不起作用:

I had another possible solution, which doesn't work for the moment :

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



<我认为我可以从我的网站向我的R应用程序发送一个post变量,就像一把钥匙,只能访问知道密钥的网站。
但我无法使其发挥作用。

I thought I could send a post variable from my website to my R application, like a key, to give the access only to the websites who know the key. But I can't make it work.

编辑:我认为这个问题与评论中建议的链接不同。实际上,建议的选项似乎不适用于R Shiny。

EDIT : I think this question is different from the link suggested in the comments. Indeed, the suggested option doesn't seem to be usable in R Shiny.

推荐答案

我找到了解决方案!

在这里,您可以找到一种方法来获取闪亮应用中的GET变量。
https://github.com/brianbolt/rShinyApps/tree/master /getParameters.shiny
在我的PHP代码中,我计算了一个md5密码,它取决于日期,每天都要更改,我在iframe中用它作为GET参数:

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

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

从那时起,我可以直接在我的代码中使用它(参见在我共享的代码中输入$ n_breaks
我在我的server.R中创建一个反应函数,它计算相同的md5密码。

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

最后,我们将它与密码中给出的密码进行比较。参数。如果它是相同的,我们打开图表,读取数据......否则,我们只是停止这个过程。

In the end, we compare it to the password given in the parameters. If it's the same, we open the plots, read the data... Otherwise, we just stop the process.

这篇关于如何在闪亮的应用程序中获取父URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆