Commit bfc299f4 authored by Conor Anderson's avatar Conor Anderson

Use basic auth with plumber to mitigate nasty actors.

parent 43079e5e
get_bounds <- function(var) {
if (debug_flag) message(sprintf("Getting model bounds for %s", var))
r <- POST(URLencode(paste0(plumber_address, "/bounds?var=", var)),
config = list(add_headers(accept = "application/json")))
config = list(add_headers(accept = "application/octet-stream")),
authenticate(plumber_user, plumber_password))
stop_for_status(r)
unserialize(content(r))
}
\ No newline at end of file
get_cache <- function(key) {
if (debug_flag) message("Asking plumber for ", key)
r <- POST(URLencode(paste0(plumber_address, "/cacheget?key=", key)),
config = list(add_headers(accept = "application/json")))
config = list(add_headers(accept = "application/octet-stream")),
authenticate(plumber_user, plumber_password))
stop_for_status(r)
unserialize(content(r))
}
......@@ -9,8 +10,9 @@ get_cache <- function(key) {
set_cache <- function(key, table) {
if (debug_flag) message("Asking plumber to save ", key)
r <- POST(URLencode(paste0(plumber_address, "/cacheset?key=", key)),
body = jsonlite::toJSON(table), encoding = "json",
config = list(add_headers(accept = "application/json")))
config = list(add_headers(accept = "application/octet-stream")),
authenticate(plumber_user, plumber_password),
body = jsonlite::toJSON(table), encoding = "json")
stop_for_status(r)
if (r$status_code != 200) warning("There was an error saving this table.")
}
......@@ -2,7 +2,8 @@ get_choices <- function(var, lim = FALSE) {
if (debug_flag) message(sprintf("Getting choices for %s", var))
r <- POST(URLencode(paste0(plumber_address, "/choices?var=", var,
"&lim=", as.character(lim))),
config = list(add_headers(accept = "application/json")))
config = list(add_headers(accept = "application/octet-stream")),
authenticate(plumber_user, plumber_password))
stop_for_status(r)
unserialize(content(r))
}
......@@ -22,7 +22,8 @@ get_gcm_ts <- function(meta) {
key <- paste(fs[f], lat_cell, lon_cell, sep = "_")
r <- POST(URLencode(paste0(plumber_address, "/timeseries?key=", key)),
config = list(add_headers(accept = "application/json")))
config = list(add_headers(accept = "application/octet-stream")),
authenticate(plumber_user, plumber_password))
stop_for_status(r)
time_tmp <- unserialize(content(r))
......
......@@ -8,16 +8,14 @@ debug_flag = FALSE
# If you don' t have a key, get one at https://developers.google.com/maps/documentation/javascript/get-api-key
google_key = ""
## Cache configuration
# The metadata lookups are still cached locally (for now).
cache = storr::storr_rds(".cache", default_namespace = "meta")
cache_ver = "2018-12-06"
## Plumber Address
# There is a plumber api that interacts with the netCDF files.
# If you want to self-host, change the address here.
## Plumber Settings
# There is a plumber API that interacts with the netCDF files on the server.
# Contact the Conjuntool author for credentials.
# If you want to self-host the plumber API, change the address here.
plumber_address = "https://api.conr.ca/conjuntool/"
plumber_user = ""
plumber_password = ""
## Number of cores to use
# Conjuntool parallelizes some heavy functions. Set the number of cores to use.
no_of_cores = detectCores() - 1
no_of_cores = detectCores()/2
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment