MyNixOS website logo
Description

Raw System Credential Store Access from R.

Aims to support all features of the system credential store, including non-portable ones. Supports 'Keychain' on 'macOS', and 'Credential Manager' on 'Windows'. See the 'keyring' package if you need a portable 'API'.

oskeyring

Raw System Credential Store Access from R

R-CMD-check Codecov testcoverage

Features

  • Windows and macOS support. Read, write, list and search the system credential store.
  • Generic credentials, domain passwords, domain certificates on Windows.
  • Generic passwords and internet passwords on macOS.
  • Multiple keychains on macOS.

Related

Installation

Install the package from CRAN:

install.packages("oskeyring")

Usage

library(oskeyring)

Most oskeyring functions are not portable, and only work on one operating system (OS). The functions that do not use the system credential store can be used on all OSes. E.g. macos_item() and windows_item() are portable. Calling a function on the wrong OS will throw an oskeyring_bad_os_error error.

oskeyring follows the API of the OS closely, and it has a different set of functions on Windows and macOS. E.g. the macOS API can search for keychain items based on item attributes, but there is no similar API on Windows, so oskeyring does not have a windows_item_search() function.

Windows Credential Store

oskeyring uses the API defined in wincred.h on Windows. The Windows credential store contains various credential types. The ones supported by oskeyring are:

windows_item_types()
#> [1] "generic"                 "domain_password"        
#> [3] "domain_certificate"      "domain_visible_password"

windows_item_write() adds or updates a credential in the credential store. It takes objects created with windows_item() :

it <- windows_item("secret", "my-host-password")
it
#> <oskeyring_windows_item: generic>
#>  target_name: my-host-password
#>  persist: local_machine
#>  credential_blob: <-- hidden -->
windows_item_write(it)

windows_item_read() reads a credential from the credential store, the return value includes the secret as well:

windows_item_read("my-host-password")
#> <oskeyring_windows_item: generic>
#>  target_name: my-host-password
#>  persist: local_machine
#>  credential_blob: <-- hidden -->

windows_item_enumerate() lists all credentials that match a prefix.

windows_item_delete() deletes a credential.

See more in the manual: ?windows_credentials.

macOS Keychain Services

Keychain items

oskeyring uses the Keychain API on macOS. macOS keychains can store various classes of items. The item classes supported by oskeyring are:

macos_item_classes()
#> [1] "generic_password"  "internet_password"

macos_item_add() adds a new item to a keychain. It takes objects created with macos_item():

it <- macos_item(
  "secret",
  list(service = "My service", account = "Gabor"),
  class = "generic_password"
)
it
#> <oskeyring_macos_item: generic_password>
#>  account: Gabor
#>  service: My service
#>  value: <-- hidden -->

Items contain the secret itself, and a set of attributes, that depends on the item class. See ?macos_keychain for the list of attributes for each class.

macos_item_add(it)

macos_item_search() searches for a keychain item:

macos_item_search(attributes = list(service = "My service"))
#> [[1]]
#> <oskeyring_macos_item: generic_password>
#>  account: Gabor
#>  creation_date: 2020-10-21 10:01:44
#>  label: My service
#>  modification_date: 2020-10-21 10:01:44
#>  service: My service

It does not return the secret itself, unless it is called with return_data = TRUE. This possibly prompts the user for a password.

macos_item_update() updates the attributes of existing Keychain items.

macos_item_delete() deletes one or more Keychain items.

Keychains

macOS supports multiple keychains. There is always a default keychain, and this is what oskeyring uses by default as well. There is also a keychain search list, where secrets are looked up by default, and this can contain multiple keychains.

macos_item_*() functions have a keychain argument to direct or restrict the operation to a specific keychain.

macos_keychain_create() creates a new keychain.

macos_keychain_list() lists all keychains on the search list.

See more about macOS keychains in the manual: ?macos_keychain.

Code of Conduct

Please note that the oskeyring project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

MIT © RStudio.

Metadata

Version

0.1.6

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows