Skip to content
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

Locate credentials doc #798

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions paws.common/R/credential_providers.R
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ sso_credential_process <- function(sso_session,
input_str <- sso_session %||% sso_start_url
cache_key <- digest::digest(enc2utf8(input_str), algo = "sha1", serialize = FALSE)
json_file <- paste0(cache_key, ".json")
root <- ifelse(
Sys.info()[[1]] == "Windows",
file.path(Sys.getenv("HOMEDRIVE"), Sys.getenv("HOMEPATH")),
root <- switch(Sys.info()[[1]],
"Windows" = file.path(Sys.getenv("HOMEDRIVE"), Sys.getenv("HOMEPATH")),
"~"
)
sso_cache <- file.path(root, ".aws", "sso", "cache", json_file)
Expand Down
27 changes: 6 additions & 21 deletions paws.common/R/credential_sso.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
# Get SSO temporary credentials for a role using the sso get_role_credentials
# operation.
#
# We need to re-implement the SSO GetRoleCredentials operation to avoid
# circular dependency: paws depends on paws.common, therefore we can't
# make paws.common also depend on paws.

# SSO service client.
sso <- function(config = list()) {
svc <- .sso$operations
svc <- set_config(svc, config)
return(svc)
}

# Private API objects: metadata, handlers, interfaces, etc.
.sso <- list()

.sso$operations <- list()
Expand Down Expand Up @@ -44,12 +29,6 @@ sso <- function(config = list()) {
return(populate(args, shape))
}

# Returns a set of temporary security credentials that you can use to
# access AWS resources that you might not normally have access to. These
# temporary credentials consist of an access key ID, a secret access key,
# and a security token. You use `GetRoleCredentials` after you have signed
# in via SSO, cf. `aws sso login`.

sso_get_role_credentials <- function(roleName, accountId, accessToken) {
op <- new_operation(
name = "GetRoleCredentials",
Expand All @@ -66,3 +45,9 @@ sso_get_role_credentials <- function(roleName, accountId, accessToken) {
return(response)
}
.sso$operations$get_role_credentials <- sso_get_role_credentials

sso <- function(config = list()) {
svc <- .sso$operations
svc <- set_config(svc, config)
return(svc)
}
8 changes: 8 additions & 0 deletions paws.common/R/credentials.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ get_credentials <- function(credentials) {
#' @param profile The name of a profile to use. If not given, then the default profile is used.
#' @param anonymous Set anonymous credentials.
#' @return list containing AWS credentials
#' \itemize{
#' \item access_key_id - (character) AWS access key ID
#' \item secret_access_key - (character) AWS secret access key
#' \item session_token - (character) AWS temporary session token
#' \item access_token - (character) A token that gives a user permission to access certain resources
#' \item expiration - (numeric) Indicates the Unix time when an access token will expire.
#' \item region - (character) The AWS Region used in instantiating the client.
#' }
#' @export
locate_credentials <- function(profile = "", anonymous = FALSE) {
credentials <- Credentials(profile = profile, anonymous = anonymous)
Expand Down
4 changes: 2 additions & 2 deletions paws.common/R/error.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Error <- struct(
ERROR_MSG_TEMPLATE <- "An error occurred (%s) when calling the %s operation: %s"

serialization_error <- function(request) {
error_message <- http_statuses[
error_message <- http_statuses[[
as.character(request$http_response$status_code)
]
]]
Error(
"SerializationError",
sprintf(
Expand Down
12 changes: 6 additions & 6 deletions paws.common/R/head_bucket.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
s3 <- function(config = list()) {
svc <- .s3$operations
svc <- set_config(svc, config)
return(svc)
}

.s3 <- list()

.s3$operations <- list()
Expand Down Expand Up @@ -51,3 +45,9 @@ s3_head_bucket <- function(Bucket, ExpectedBucketOwner = NULL) {
return(response)
}
.s3$operations$head_bucket <- s3_head_bucket

s3 <- function(config = list()) {
svc <- .s3$operations
svc <- set_config(svc, config)
return(svc)
}
8 changes: 8 additions & 0 deletions paws.common/man/locate_credentials.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading