【问题标题】:Passing SQL credentials to shinyproxy app将 SQL 凭据传递给 shinyproxy 应用程序
【发布时间】:2021-02-09 00:53:30
【问题描述】:

我有一个使用 ldap 身份验证的 Shinyproxy 应用程序。但是,为了从 SQL 数据库中检索数据,我现在在我的 R 代码中使用(不推荐)硬编码的连接字符串以及此处提到的凭据(我使用服务用户,因为我的最终用户无权查询数据库):

con <- DBI::dbConnect(odbc::odbc(), encoding = "latin1", .connection_string = 'Driver={Driver};Server=Server;Database=dbb;UID=UID;PWD=PWD') 

我试图用一个环境变量替换连接字符串,我从我的 linux 主机传递到容器。这在 ShinyProxy 外部运行容器时有效,因此通过在运行时使用以下 docker 命令传递环境变量:

docker run -it --env-file env.list app123

但是,当使用 ShinyProxy 时,我不清楚如何在 yaml 配置文件中进行配置。如何在此级别传递语句 --env-file env.list 以便在链接的容器中提取它?

感谢您的帮助!

【问题讨论】:

    标签: r docker shiny credentials shinyproxy


    【解决方案1】:

    来自这个已关闭的问题:https://github.com/openanalytics/shinyproxy/issues/99

    您的application.yaml 可能如下所示:

    proxy:
    
      title: Open Analytics Shiny Proxy
      logo-url: http://www.openanalytics.eu/sites/www.openanalytics.eu/themes/oa/logo.png
      landing-page: /
      heartbeat-rate: 10000
      heartbeat-timeout: 60000
      port: 8080
      authentication: simple
      admin-groups: admin
      # Example: 'simple' authentication configuration
      users:
      - name: admin
        password: password
        groups: admin
      # Docker configuration
      docker:    
        internal-networking: true
    
      specs:
      - id: 01_hello
        display-name: Hello Application
        description: Application which demonstrates the basics of a Shiny app
        container-cmd: ["R", "-e", "shinyproxy::run_01_hello()"]
        container-image: openanalytics/shinyproxy-demo
        container-env-file: /app/shinyproxy/test.env
        container-env:
           bar: baz
        access-groups: admin  
        container-network: shinyproxy_reprex_default  
    
    
    logging:
      file:
        shinyproxy.log
    

    具体来说,您似乎可以使用container-env-file 为文件设置环境变量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-19
      • 2017-06-25
      相关资源
      最近更新 更多