-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from inbo/20-pass-credentials-via-sys-env
my attempt at allowing storage of password in Sys env
- Loading branch information
Showing
6 changed files
with
124 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: iassetR | ||
Title: Use the iAsset API in R | ||
Version: 0.0.0.9000 | ||
Version: 0.0.1.9000 | ||
Authors@R: c( | ||
person("Pieter", "Huybrechts", , "[email protected]", role = "aut", | ||
comment = c(ORCID = "0000-0002-6658-6062")), | ||
|
@@ -19,12 +19,13 @@ Imports: | |
glue, | ||
httr2, | ||
janitor, | ||
keyring, | ||
magrittr, | ||
openssl, | ||
purrr, | ||
rlang, | ||
stringr | ||
Encoding: UTF-8 | ||
Roxygen: list(markdown = TRUE) | ||
RoxygenNote: 7.2.3 | ||
RoxygenNote: 7.3.1 | ||
BugReports: https://github.com/inbo/iassetR/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#' Get the username associated with the iAsset credentials in the system credentials store. | ||
#' | ||
#' @param service Character. The keyring service to fetch the stored username for. | ||
#' | ||
#' @return A character vector of stored usernames for the service. NA if none. | ||
#' | ||
#' @export | ||
#' | ||
#' @examples | ||
#' \dontrun{get_username("iasset_password")} | ||
get_username <- function(service = "iasset_password") { | ||
# check input params | ||
assertthat::assert_that(assertthat::is.string(service)) | ||
|
||
# check that the system supports keyring | ||
assertthat::assert_that(keyring::has_keyring_support()) | ||
|
||
# check that the queried service is in the keyring | ||
assertthat::validate_that(service %in% keyring::key_list()$service, | ||
msg = glue::glue("{service} not found in keyring") | ||
) | ||
|
||
# fetch the associated usernames | ||
keyring::key_list(service = service)$username | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.