Skip to content
Permalink
Browse files

Better bootstrapping process

  • Loading branch information...
hadley committed Oct 24, 2014
1 parent 81cd0ff commit b279c217e4eca33f9eefdf2a5d430367135bd8d5
Showing with 11 additions and 3 deletions.
  1. +6 −1 R/encryption.R
  2. +5 −2 R/users.R
@@ -76,8 +76,13 @@ my_key <- function(vault, key = local_key()) {
call. = FALSE)
}

my_key <- me[[1]]$key
if (is.null(my_key)) {
return(NULL)
}

private_key <- PKI::PKI.load.key(file = "~/.ssh/id_rsa")
PKI::PKI.decrypt(base64enc::base64decode(me[[1]]$key), private_key)
PKI::PKI.decrypt(base64enc::base64decode(my_key), private_key)
}

is_travis <- function() {
@@ -49,18 +49,21 @@ remove_user <- function(name, vault = ".") {
}

recrypt <- function(vault, key = new_key()) {
message("Re-encrypting all files with new key")
vault <- find_vault(vault)
old_key <- my_key(vault)

# Encrypt new password for each user
message("Generating new master keys")
users <- load_users(vault)
users <- lapply(users, recrypt_user, key = key)
save_users(users, vault = vault)

# Decrypt & reencrypt each file
files <- dir(vault, "\\.rds\\.enc$", full.names = TRUE)
lapply(files, recrypt_file, old_key = old_key, new_key = key)
if (length(files) > 0) {
message("Re-encrypting all files with new key")
lapply(files, recrypt_file, old_key = old_key, new_key = key)
}

invisible(TRUE)
}

0 comments on commit b279c21

Please sign in to comment.
You can’t perform that action at this time.