datastorm-open / shinymanager

Simple and secure authentification mechanism for single shiny applications.
https://datastorm-open.github.io/shinymanager/
386 stars 79 forks source link

shinymanager not working with Shiny Modules #76

Closed bjungbogati closed 3 years ago

bjungbogati commented 3 years ago

Here is an example, of shiny module. I've tried addding shinymanager but the UI won't get visible.

https://gist.github.com/bjungbogati/34b0de3720ba3e93deebf568caf964ca

@pvictor Is there any way around, how to integrate shinymanager in shiny moudles.

pvictor commented 3 years ago

Not sure what you want to do, in your example you actually don't use any shinymanager functionnalities.

Victor

bjungbogati commented 3 years ago

@pvictor I was trying example given in the Readme, however I'm not able to get UI functionality once I run it. I was curious which part in my code, do I need to put the shinymanager functions.

app_ui <- function() {

  fluidPage(
    ymdUI(id = "1", label = "Find AGE")
    )

}

app_server <- function(input, output, session) {

  ymdServer(id = "1")

  res_auth <- shinymanager::secure_server(
    check_credentials = shinymanager::check_credentials(
      data.frame(
        user = c("shiny", "shinymanager"), # mandatory
        password = c("shiny", "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
      )
    )
  )
  output$auth_output <- renderPrint({
    reactiveValuesToList(res_auth)
  })

}

shinyApp(ui =  secure_app(app_ui), server = app_server)

Full App Code: https://gist.github.com/bjungbogati/34b0de3720ba3e93deebf568caf964ca

calderonsamuel commented 3 years ago

You don't need your ui inside a function() call.

app_ui <- fluidPage(
    ymdUI(id = "1", label = "Find AGE")
    ) 

Should be enough