-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathutils.R
More file actions
69 lines (62 loc) · 1.61 KB
/
utils.R
File metadata and controls
69 lines (62 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
library(openssl)
library(jose)
source("configs.R")
get_libraries <- function(){
str(allPackages <- installed.packages(.Library, priority = "high"))
lib_matrix <- allPackages[, c(1,3:5)]
lib_info <- lib_matrix[,c(1,2)]
lib_info
}
resolve_drivers <- function(script, drivers){
for(name in names(drivers)) {
value <- drivers[[name]]
original <- paste0('\\$P\\{', name , '\\}')
final <- paste0('drivers_[[\\"', name, '\\"]]')
script <- gsub(original,final,script)
}
script
}
build_parameters <- function(parameters){
to_return <- list()
if(length(parameters) > 0) {
parameters_df <- as.data.frame(parameters)
for(i in 1:nrow(parameters_df)) {
row <- parameters_df[i,]
name <- row[["name"]]
value <- row[["value"]]
type <- row[["type"]]
if(value == "") {
value <- row[["defaultValue"]]
}
if(type == "Number") {
value <- as.numeric(value)
}
to_return[[name]] <- value
}
}
to_return
}
resolve_parameters <- function(script, parameters){
for(name in names(parameters)) {
value <- parameters[[name]]
original <- paste0('\\$P\\{', name , '\\}')
final <- paste0('parameters_[[\\"', name, '\\"]]')
script <- gsub(original,final,script)
}
script
}
decode_jwt_token <- function(script){
token <- jwt_decode_hmac(script, secret = hmac_key)
token
}
get_script_from_token <- function(token){
script <- token[["script"]]
script
}
is_dataset_request_authorized <- function(token){
expirationTime <- token[["exp"]]
now <- as.numeric(as.POSIXct(Sys.time()))
if (now > expirationTime)
FALSE
TRUE
}