datastorm-open / shinymanager

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

is admin module not enabled yet? #164

Closed sanjmeh closed 1 year ago

sanjmeh commented 1 year ago

The GitHub page shows a graphical user interface (GUI) for managing users, but it doesn't clarify how to enable this in a Shiny app, nor does the package documentation. Is the admin module a feature under development or an illustration of what could be achieved with additional custom coding? Or is it existing?

This section of the documentation is confusing. Can the developers of shinymanager elaborate a little this part? https://github.com/datastorm-open/shinymanager#admin-mode

sanjmeh commented 1 year ago

Seems no action on this repository for a long time. It is so sad that such a great product is left half way through by the developers. Could any one of you drop a line about the future strategy for this package please? @indubio @pvictor @erikson84 @ucg8j

pvictor commented 1 year ago

Package works fine and admin mode too, have you tried the code in readme ? Further documentation is available here : https://datastorm-open.github.io/shinymanager/articles/SQLite_Admin.html

sanjmeh commented 1 year ago

Yes I tried. Unfortunately it didn't show me the admin options. Here is a working code which uses the various sections and authenticates the user but still does not show any UI for user management,

library(shiny)
library(data.table)
library(shinymanager)
library(DT)
library(RSQLite)

# 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 = "/data/test.database.sqlite", # will be created
    passphrase = "testpass"
)

ui <- fluidPage(
    selectInput("test1","Select User",choices = c("jack","tom","harry"),selected = "tom"),
    DTOutput("testtable")
)
# 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(
            "/data/test.database.sqlite",
            passphrase = "testpass"
        )
    )

    output$auth_output <- renderPrint({
        reactiveValuesToList(res_auth)
    })
 output$testtable <- renderDT({
     data.table(name = input$test1, x = 1:10)  |>
     datatable()
 })
}

shinyApp(ui = ui,server = server)
sanjmeh commented 1 year ago

In above code after I authenticate as shinymanager I see the test UI that I built but no sign of any admin ui.

pvictor commented 1 year ago

If you log in with "shinymanager" account you should see a button available in the right corner (when hovering the "plus" icon) to go to admin mode :

image

sanjmeh commented 1 year ago

Oh my goodness, the gems were hidden there !! Thank you so much. You saved me so much time as I was about to start building my own user management module. This issue can be closed. Have a nice day.