Commit 0eb9ce8d authored by khalid's avatar khalid
Browse files

Authentication is now encrypted

parent 62d3a5fc
......@@ -802,6 +802,21 @@ generate <- function() {
file.copy("./tools/chooser.R", output_dir + "/R/")
file.copy("./tools/chooser-binding.js", output_dir + "/www/")
# create a user base then hash passwords with sodium
# then save to an rds file in app directory
if(passwd != "")
{
library(sodium)
user_base <- tibble::tibble(
user = user,
password = purrr::map_chr(passwd, sodium::password_store),
permissions = "standard",
name = "User One"
)
saveRDS(user_base, paste0(output_dir,"/user_base.rds") )
}
print("Generate End")
}
......@@ -959,7 +974,8 @@ generate_app <- function() {
res <- res + 'server <- function( input, output, session) {\n\n'
if (passwd != "")
{
res <- res + ' credentials <- shinyauthr::loginServer( id = "login",data = user_base, user_col = user, pwd_col = password, log_out = reactive(logout_init()) )\n\n'
res <- res + 'user_base <- readRDS("user_base.rds")\n\n'
res <- res + ' credentials <- shinyauthr::loginServer( id = "login",data = user_base, user_col = user, pwd_col = password,sodium_hashed = TRUE, log_out = reactive(logout_init()) )\n\n'
res <- res + 'logout_init <- shinyauthr::logoutServer( id = "logout",active = reactive(credentials()$user_auth)) \n\n'
res <- res + ' blockDeblock <- function(input_list, enable_inputs=F) {\n\n'
res <- res + ' for(x in setdiff(names(input_list),c("login-user_name","login-password","login-button"))){ \n\n'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment