Skip to content

Basic structure of a R Shiny application for use on Synapse

License

Notifications You must be signed in to change notification settings

Wandrys-dev/SynapseShinyApp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic Shiny application for use on Sage Bionetwork's Synapse web portal.

Credits

Introduction

Shiny applications are a powerful way to develop interactive data visualization and manipulation interfaces. However, when using with Synapse, user authentication is an issue - whomever the Shiny application is running as will determine the access that users visiting the application will have.

This solution allows to determine which user is currently logged into Synapse through the web browser. These credentials are passed on to the Shiny app, and that specific user is logged in. Subsequent interactions with Synapse to pull data for the Shiny interface then happens as that user.

⚠️HOWEVER⚠️ The Synapse R client, synapser, stores authentication information in a location that is global to the R process. This means that if one user connects to a Shiny app, and then another user connects from another browser or computer, the second user's authentication will supersede the first's. This can cause hard-to-diagnose errors, and is a security issue. There are 3 ways to work around this issue:

  1. Ensure that each user gets a separate R process by customizing the utilization scheduler (only available for Shiny Server Pro).

  2. Write your app so that it logs in before doing any operation that interacts with Synapse. Essentially this means writing wrappers for every synapser function you use, e.g.:

    authSynGet <- function(...) {
      synLogin(sessionToken = input$cookie)
      synGet(...)
    }

    Placing a call to synLogin() before synGet() directly in your server function is not necessarily sufficient, as it is still possible someone else could log in between when your synLogin() and synGet() are executed.

  3. Instead of using synapser, use the Synapse Python client + reticulate. The Python client allows for creating multiple client objects, and therefore multiple authenticated users. Please see the reticulate branch for implementation details.

Usage

To create a new Shiny application based on this structure, do not fork this repository directly on GitHub. Instead, please use GitHub's importer following the instructions below.

Creating a New Shiny App Repository

  1. Go to GitHub's importer and paste in this repository's clone URL (https://github.com/Sage-Bionetworks/SynapseShinyApp.git).
  2. Choose a name for your repository.
  3. Select the owner for your repository (This will probably be you, but may instead be an organization you belong to).

You can now click "Begin Import". When the process is done, you can click "Continue to repository" to visit your newly-created repository.

Notes

If you are using a navbarPage instead of a fluidPage in your ui.R, use of this code:

tags$head(
    singleton(
      includeScript("www/readCookie.js")
    )
  ),

will cause create a default ghost tab. Instead, you should replace the above code with this snippet:

header=list(tags$head(includeScript("www/readCookie.js"))),

About

Basic structure of a R Shiny application for use on Synapse

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 83.0%
  • JavaScript 17.0%