Using SQL database protected (create_db()
), an admin mode is available to manage access to the application, features included are
# Credentials data
<- data.frame(
credentials 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
<- secure_app(ui, enable_admin = TRUE)
ui
<- function(input, output, session) {
server
# check_credentials directly on sqlite db
<- secure_server(
res_auth check_credentials = check_credentials(
"path/to/database.sqlite",
passphrase = key_get("R-shinymanager-key", "obiwankenobi")
# passphrase = "passphrase_wihtout_keyring"
)
)
$auth_output <- renderPrint({
outputreactiveValuesToList(res_auth)
})
# your classic server logic
... }
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 (if user is authorized to access it), and to logout from the application :
The first table lists all current users :
A user is defined (at least) by the following information :
TRUE
/ FALSE
)Using Add user button. So you can edit user information in the modal box :
Notes :
Finally, the creation is effective clicking on validation button.
It’s possible to edit user information clicking on the blue button
on the table.
You can remove one user using red button
on table.
The second table allows password management :
Moreover, by defaut, the module uses some security rules :
Additive information :
You can visualize and download connexion logs on the second tab.