All Projects → datastorm-open → Shinymanager

datastorm-open / Shinymanager

Simple and secure authentification mechanism for single shiny applications.

Programming Languages

r
7636 projects

Labels

Projects that are alternatives of or similar to Shinymanager

Collapsibletree
Create Interactive Collapsible Tree Diagrams in R using D3.js
Stars: ✭ 126 (-40.85%)
Mutual labels:  shiny
Googleauthr
Google API Client Library for R. Easy authentication and help to build Google API R libraries with OAuth2. Shiny compatible.
Stars: ✭ 150 (-29.58%)
Mutual labels:  shiny
Fresh
Fresh shiny themes
Stars: ✭ 170 (-20.19%)
Mutual labels:  shiny
Shinyfiles
A shiny extension for server side file access
Stars: ✭ 133 (-37.56%)
Mutual labels:  shiny
Colourpicker
🎨 A colour picker tool for Shiny and for selecting colours in plots (in R)
Stars: ✭ 144 (-32.39%)
Mutual labels:  shiny
Explor
Interfaces for Multivariate Analysis in R
Stars: ✭ 157 (-26.29%)
Mutual labels:  shiny
Bsplus
Shiny and R Markdown addons to Bootstrap 3
Stars: ✭ 120 (-43.66%)
Mutual labels:  shiny
Shinystudio
A fully Dockerized, self-hosted development environment for teams. Develop where you serve.
Stars: ✭ 204 (-4.23%)
Mutual labels:  shiny
Shinyalert
🗯️ Easily create pretty popup messages (modals) in Shiny
Stars: ✭ 148 (-30.52%)
Mutual labels:  shiny
Electricshine
Create Standalone Installable Shiny Apps
Stars: ✭ 165 (-22.54%)
Mutual labels:  shiny
Scatterd3
R scatter plot htmlwidget based on D3.js
Stars: ✭ 135 (-36.62%)
Mutual labels:  shiny
Shinyfeedback
display user feedback next to Shiny inputs
Stars: ✭ 143 (-32.86%)
Mutual labels:  shiny
Gglabeller
Shiny gadget for labeling points on ggplot
Stars: ✭ 161 (-24.41%)
Mutual labels:  shiny
Cicerone
🏛️ Give tours of your Shiny apps
Stars: ✭ 131 (-38.5%)
Mutual labels:  shiny
Bslib
Tools for theming shiny and rmarkdown from R via Bootstrap (3 or 4) Sass.
Stars: ✭ 197 (-7.51%)
Mutual labels:  shiny
Yonder
A reactive web framework built on shiny
Stars: ✭ 121 (-43.19%)
Mutual labels:  shiny
Isee
R/shiny interface for interactive visualization of data in SummarizedExperiment objects
Stars: ✭ 155 (-27.23%)
Mutual labels:  shiny
Shinyeffectforugui
Shiny effect of uGUI, which does not need mask or normal map.
Stars: ✭ 204 (-4.23%)
Mutual labels:  shiny
Taganomaly
Anomaly detection analysis and labeling tool, specifically for multiple time series (one time series per category)
Stars: ✭ 200 (-6.1%)
Mutual labels:  shiny
Plotly
An interactive graphing library for R
Stars: ✭ 2,096 (+884.04%)
Mutual labels:  shiny

shinymanager

Travis build status version cranlogs cran checks Project Status: Active – The project has reached a stable, usable state and is being actively developed.

Simple and secure authentication mechanism for single 'Shiny' applications. Credentials are stored in an encrypted 'SQLite' database. Password are hashed using 'scrypt' R package. Source code of main application is protected until authentication is successful.

Live demo:

You can authenticate with:

  • user: shiny / password: shiny
  • user: shinymanager / password: shinymanager (Admin)

Online documentation : https://datastorm-open.github.io/shinymanager/

News on shinymanager 1.0.300

  • Add autofocus on username input.
  • Fix some (strange) bug with input$shinymanager_where
  • Fix inputs_list with some shiny version
  • auth_ui() now accept a choose_language arguments.
  • Rename br language into pt-BR (iso code)
  • add user info in downloaded log file
  • add set_labels() for customize labels
  • Fix simultaneous admin session
  • (#37) hashing password using scrypt

Installation

Install from CRAN with :

install.packages("shinymanager")

Or install development version from GitHub :

remotes::install_github("datastorm-open/shinymanager")

Usage

Secure your Shiny app to control who can access it :

  • secure_app() & auth_ui() (customization)
  • secure_server() & check_credentials()
# define some credentials
credentials <- data.frame(
  user = c("shiny", "shinymanager"), # mandatory
  password = c("azerty", "12345"), # mandatory
  start = c("2019-04-15"), # optinal (all others)
  expire = c(NA, "2019-12-31"),
  admin = c(FALSE, TRUE),
  comment = "Simple and secure authentification mechanism 
  for single ‘Shiny’ applications.",
  stringsAsFactors = FALSE
)

library(shiny)
library(shinymanager)

ui <- fluidPage(
  tags$h2("My secure application"),
  verbatimTextOutput("auth_output")
)

# Wrap your UI with secure_app
ui <- secure_app(ui)


server <- function(input, output, session) {
  
  # call the server part
  # check_credentials returns a function to authenticate users
  res_auth <- secure_server(
    check_credentials = check_credentials(credentials)
  )
  
  output$auth_output <- renderPrint({
    reactiveValuesToList(res_auth)
  })
  
  # your classic server logic
  
}

shinyApp(ui, server)

Starting page of the application will be :

Once logged, the application will be launched and a button added to navigate between the app and the admin panel (SQL credentials only and if user is authorized to access it), and to logout from the application :

Secure database

Store your credentials data in SQL database protected with a symmetric AES encryption from openssl, and password hashing using scrypt :

  • create_db()
# Init DB using credentials data
credentials <- data.frame(
  user = c("shiny", "shinymanager"),
  password = c("azerty", "12345"),
  # password will automatically be hashed
  admin = c(FALSE, TRUE),
  stringsAsFactors = FALSE
)

# you can use keyring package to set database key
library(keyring)
key_set("R-shinymanager-key", "obiwankenobi")

# Init the database
create_db(
  credentials_data = credentials,
  sqlite_path = "path/to/database.sqlite", # will be created
  passphrase = key_get("R-shinymanager-key", "obiwankenobi")
  # passphrase = "passphrase_wihtout_keyring"
)

# Wrap your UI with secure_app, enabled admin mode or not
ui <- secure_app(ui, enable_admin = TRUE)


server <- function(input, output, session) {
  
  # check_credentials directly on sqlite db
  res_auth <- secure_server(
    check_credentials = check_credentials(
        "path/to/database.sqlite",
        passphrase = key_get("R-shinymanager-key", "obiwankenobi")
        # passphrase = "passphrase_wihtout_keyring"
    )
  )
  
  output$auth_output <- renderPrint({
    reactiveValuesToList(res_auth)
  })
  
  # your classic server logic
  ...
}

Admin mode

Using SQL database protected, an admin mode is available to manage access to the application, features included are

  • manage users account : add, modify and delete users
  • ask the user to change his password
  • see logs about application usage

shiny input

Two inputs are created :

observe({
    print(input$shinymanager_where)
    print(input$shinymanager_language)
})

Customization

You can customize the module (css, image, language, ...).

?secure_app
?auth_ui
?set_labels

Flexdasboard

It's possible to use shinymanager authentification on flexdashboard (but not admin console at moment). You can find information on this discussion. But it's not a really secure way because user can overpass the authentification using developper console... Prefer use shiny application with secure_app function.

Troubleshooting

The application works fine without shinymanager but not you have trouble using shinymanager.

There is a lag between your ui and the server, since shinymanger hides the ui part until authentication is successful. It is therefore possible that some of `ui element`` (input) are not defined and are NULL. In this case, you'll see some warning / error message in your R console.

So we recommend to use in all your reactive/observer functions the req instruction to validate the inputs.

One more global and brutal solution can be :

server <- function(input, output, session) {
  
  auth_out <- secure_server(....)
  
  observe({
    if(is.null(input$shinymanager_where) || (!is.null(input$shinymanager_where) && input$shinymanager_where %in% "application")){
      
      # your server app code
    }
  })
}

But it's better to use req solution. More discussion on https://github.com/datastorm-open/shinymanager/issues/36

HTTP request

shinymanager use http request and sha256 tokens to grant access to the application, like this the source code is protected without having the need to change your UI or server code.

About security

The credentials database is secured with a pass phrase and the openssl package. Hashed password using scrypt. If you have concern about method we use, please fill an issue.

Related work

Package shinyauthr provides a nice shiny module to add an authentication layer to your shiny apps.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].