Skip to content

respect is_hashed_password in create_sql_db #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions R/credentials-db-sql.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,22 @@ write_sql_db <- function(config_db, value, name = "credentials") {
name <- SQL(name)

if("password" %in% colnames(value)){
# store hashed password
value$password <- sapply(value$password, function(x) scrypt::hashPassword(x))
# is_hashed_password is a column from storing credentials in SQLite.
if("is_hashed_password" %in% colnames(value)){
value$password <- mapply(function(pwd, is_hashed){
if(as.logical(is_hashed)){
# So, the passwords may already be hashed.
pwd
} else {
scrypt::hashPassword(pwd)
}
}, value$password, value$is_hashed_password)
value$is_hashed_password <- T
} else {
# Any clients since the addition of SQL support in version 1.0.5 won't have the
# is_hashed_password column (unless they specify it explicitly in their db config)
value$password <- sapply(value$password, function(x) scrypt::hashPassword(x))
}
}

if("MariaDBConnection" %in% class(conn)){
Expand Down