passwords: Functions to access password in user's keychain

Description Usage Arguments Details Value Note Author(s) Examples

Description

getPassword retireves a password stored in the keychain

setPassword adds or modifies a password stored in the keychain

rmPassword removes a password from the kaychain

Usage

1
2
3
getPassword(service, user = NULL, quiet = FALSE, keychain = NULL)
setPassword(service, user = NULL, password, keychain = NULL)
 rmPassword(service, user = NULL, keychain = NULL)

Arguments

service

Name (arbitrary string) identifying the service

user

User name (if NULL the current login name of the user is used)

quiet

if FALSE then the function fails in case no password is found, if TRUE then NULL is returned in that case. Note that the function can still fail for other reasons (invalid parameters, keychain or denied access) regardless of the quiet flag.

password

new password (single string)

keychain

Keychain to operate on. If NULL then the default user keychain is used (recommended). In the current implementation that is the only valid value.

Details

The above functions access and modify passwords in the current user's keychain. A keychain is a secure storage of information that can be locked and ulocked by the user. The functions above manipulate passwords associated with (service, user) pairs.

The actual storage and method of determining user authorization is system-dependent. The current implementation uses the Security framework to work with users' keychain.

Value

getPassword: the currently stored password (decrypted) or NULL of quiet=TRUE and no password was found.

setPassword: previous password or NULL if the password was just created.

rmPassword: previous password

Note

The current implementation uses default system keychain where supported. The system may ask the user for authentication to open the keychain.

The passwords are stored as generic passwords. Note that the actual service name used at the system level is prefixed with an R-specific prefix to prevent abuse by reading other passwords (such as your internet passwords etc.). However, malicious users could modify the package to allow arbitrary access, so be wary of the source from which you install this package.

Please note that once you authorize R to access the keychain, it may be open for subsequent access.

Author(s)

Simon Urbanek

Examples

1
2
3
4
5
  pwd <- getPassword("foo", quiet=TRUE)
  if (is.null(pwd)) cat("foo doesn't exist yet\n")
  setPassword("foo",, "bar")
  pwd <- getPassword("foo")
  rmPassword("foo")

hirenj/keychain documentation built on May 17, 2019, 3:59 p.m.