Could someone adapt the code below to be used on a remote server? I couldn't find any simple example on the package pages or on the internet that addressed this issue. Here's the code:
global.r
# 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 = "www/database.sqlite", # will be created
passphrase = key_get("R-shinymanager-key", "obiwankenobi")
)
ui.r
library(shiny)
library(shinymanager)
ui <- fluidPage(
tags$h2("My secure application"),
verbatimTextOutput("auth_output")
)
ui <- secure_app(ui, enable_admin = TRUE)
server.r
server <- function(input, output, session) {
# check_credentials directly on sqlite db
res_auth <- secure_server(
check_credentials = check_credentials(
"www/database.sqlite",
passphrase = key_get("R-shinymanager-key", "obiwankenobi")
# passphrase = "passphrase_wihtout_keyring"
)
)
output$auth_output <- renderPrint({
reactiveValuesToList(res_auth)
})
# your classic server logic
}
The file .log
in /var/log/shiny-server/testeshimanager is:
su: ignore --preserve-environment, it's mutually exclusive to --login.
Error in b_file_set(self, private, service, username, keyring, prompt) :
Aborted setting keyring key
Calls: runApp ... ..stacktraceon.. -> key_set -> <Anonymous> -> b_file_set
Execution halted
I didn't find anything doable to unravel such error. Just for information, the shiny server is running perfectly. Another example, very simple, works. Therefore, all folders and files have maximum execution permission, that is, chmod -R 777
. The difficulty lies precisely in using the shinymanager
package on the remote server.