This commit is contained in:
Hong Ooi 2020-06-03 17:00:58 +10:00
Родитель 82f6d2f0f7
Коммит da78f53895
2 изменённых файлов: 28 добавлений и 0 удалений

2
R/AzureCosmosR.R Normal file
Просмотреть файл

@ -0,0 +1,2 @@
# assorted imports of friend functions
sign_sha256 <- get("sign_sha256", getNamespace("AzureStor"))

26
R/sign_request.R Normal file
Просмотреть файл

@ -0,0 +1,26 @@
sign_request.table_endpoint <- function(endpoint, verb, url, headers, api, ...)
{
make_sig <- function(key, verb, acct_name, resource, headers)
{
names(headers) <- tolower(names(headers))
sigstr <- paste(verb,
as.character(headers[["content-md5"]]),
as.character(headers[["content-type"]]),
as.character(headers[["date"]]),
resource, sep = "\n")
sigstr <- sub("\n$", "", sigstr)
paste0("SharedKey ", acct_name, ":", sign_sha256(sigstr, key))
}
acct_name <- sub("\\..+$", "", url$host)
resource <- paste0("/", acct_name, "/", url$path)
resource <- gsub("//", "/", resource)
if (is.null(headers$date) || is.null(headers$Date))
headers$date <- httr::http_date(Sys.time())
if (is.null(headers$`x-ms-version`))
headers$`x-ms-version` <- api
sig <- make_sig(endpoint$key, verb, acct_name, resource, headers)
modifyList(headers, list(Host = url$host, Authorization = sig))
}