Closed shankar-JK closed 3 years ago
The pop up window is caused by calling the function key_set of the keyring library. It is used to set the passphrase for the encrypted user database. The password you enter here is saved into your computers credential store (e.g. keychain access on macOS). You should check out keyring's documentation, by typing ?keyring::key_set into the R console.
This is not an issue in shinymanager, just a feature of the example code. You don't have to use keyring, you can instead set the passphrase by hand, as shown in the commented bits of the example code.
Hello while running SQLite Admin code, a window pop up for a password. I don't know what password I should use here. Because of this, I am getting the following error.
Error: Could not connect to database: unable to open database file
I am using this below code
Please help me ASAP
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
... }
shinyApp(ui, server)