Coder Social home page Coder Social logo

oskeyring's Introduction

oskeyring

Raw System Credential Store Access from R

R-CMD-check Codecov test coverage

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.

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

oskeyring's People

Contributors

gaborcsardi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

oskeyring's Issues

Upkeep for oskeyring

Pre-history

  • usethis::use_readme_rmd()
  • usethis::use_roxygen_md()
  • usethis::use_github_links()
  • usethis::use_pkgdown_github_pages()
  • usethis::use_tidy_github_labels()
  • usethis::use_tidy_style()
  • usethis::use_tidy_description()
  • urlchecker::url_check()

2020

  • usethis::use_package_doc()
    Consider letting usethis manage your @importFrom directives here.
    usethis::use_import_from() is handy for this.
  • usethis::use_testthat(3) and upgrade to 3e, testthat 3e vignette
  • Align the names of R/ files and test/ files for workflow happiness.
    usethis::rename_files() can be helpful.

2021

  • usethis::use_tidy_dependencies()
  • usethis::use_tidy_github_actions() and update artisanal actions to use setup-r-dependencies
  • Remove check environments section from cran-comments.md
  • Bump required R version in DESCRIPTION to 3.4
  • Use lifecycle instead of artisanal deprecation messages, as described in Communicate lifecycle changes in your functions
  • Add RStudio to DESCRIPTION as funder, if appropriate

2022

Release oskeyring 0.1.1

To fix the Windows crash.

Prepare for release:

  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • revdepcheck::revdep_check(num_workers = 4)
  • Polish NEWS
  • If new failures, update email.yml then revdepcheck::revdep_email_maintainers()

Perform release:

  • Bump version (in DESCRIPTION and NEWS)
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Tag release
  • Bump dev version
  • Write blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Tests

Only run them on CI?

  • Windows
  • macOS

Release oskeyring 0.1.2

Prepare for release:

  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • revdepcheck::cloud_check()
  • Update cran-comments.md

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • usethis::use_github_release()
  • usethis::use_dev_version()

Release oskeyring 0.1.3

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel() Took too long...
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers() Included in check_for_cran().
  • revdepcheck::cloud_check() revdepcheck::revdep_check(num_workers=4)
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push

Move `master` branch to `main`

The master branch of this repository will soon be renamed to main, as part of a coordinated change across several GitHub organizations (including, but not limited to: tidyverse, r-lib, tidymodels, and sol-eng). We anticipate this will happen by the end of September 2021.

That will be preceded by a release of the usethis package, which will gain some functionality around detecting and adapting to a renamed default branch. There will also be a blog post at the time of this master --> main change.

The purpose of this issue is to:

  • Help us firm up the list of targetted repositories
  • Make sure all maintainers are aware of what's coming
  • Give us an issue to close when the job is done
  • Give us a place to put advice for collaborators re: how to adapt

message id: euphoric_snowdog

Crashes the gitcreds tests on macOS

Something to do with creancall:

โฏ CI=true R
โฏ .t
โ„น Loading gitcreds
โ„น Testing gitcreds
โœ” | F W S  OK | Context
โ  |         0 | cache

This testsuite will delete your git credentials and config !!!

1: Yeah, fine.
2: Wait, what?

Selection: 1
2022-03-11 11:00:37.756 R[17434:231961] -[__NSCFConstantString _getValue:forType:]: unrecognized selector sent to instance 0x2020f87f8
2022-03-11 11:00:37.767 R[17434:231961] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString _getValue:forType:]: unrecognized selector sent to instance 0x2020f87f8'
*** First throw call stack:
(
	0   CoreFoundation                      0x00000001a79001cc __exceptionPreprocess + 240
	1   libobjc.A.dylib                     0x00000001a76517b8 objc_exception_throw + 60
	2   CoreFoundation                      0x00000001a79931a0 -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00000001a7860360 ___forwarding___ + 1728
	4   CoreFoundation                      0x00000001a785fbe0 _CF_forwarding_prep_0 + 96
	5   oskeyring.so                        0x0000000105724830 as_sexp + 304
	6   oskeyring.so                        0x00000001057254a8 oskeyring_as_item + 680
	7   oskeyring.so                        0x000000010572558c oskeyring_as_item_list + 76
	8   oskeyring.so                        0x0000000105725b50 oskeyring_macos_search + 400
	9   libR.dylib                          0x0000000103510810 R_doDotCall + 1808
	10  libR.dylib                          0x00000001035110fc do_dotcall + 316

Release oskeyring 0.1.4

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::revdep_check(num_workers = 8)
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push

Release oskeyring 0.1.5

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::revdep_check(num_workers = 8)
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push

Release oskeyring 0.1.6

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • rhub::check(platform = 'ubuntu-rchk')
  • rhub::check_with_sanitizers()
  • revdepcheck::cloud_check()
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted ๐ŸŽ‰
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.