Skip to content

Commit

Permalink
Add openssl
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Oct 25, 2014
1 parent b084417 commit d7d97f7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ Imports:
evaluate (>= 0.5.1),
httpuv (>= 1.3),
knitr (>= 1.4),
jsonlite (>= 0.9.12),
jsonlite (>= 0.9.13),
devtools (>= 1.5),
httr (>= 0.3),
brew,
pander
pander,
openssl
Suggests:
RAppArmor,
sendmailR,
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by roxygen2 (4.0.1): do not edit by hand
# Generated by roxygen2 (4.0.2): do not edit by hand

S3method(print,opencpu)
S3method(print,rhttpd)
Expand All @@ -21,4 +21,5 @@ importFrom(jsonlite,toJSON)
importFrom(jsonlite,validate)
importFrom(knitr,knit)
importFrom(knitr,pandoc)
importFrom(openssl,rand_bytes)
importFrom(pander,pander)
4 changes: 3 additions & 1 deletion R/session.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#create the regex to identify session keys

session_regex <- function(){
paste0("^x[0-9a-f]{", config("key.length") + 1, "}$")
}

#' @importFrom openssl rand_bytes
session <- local({

#generates a random session hash
generate <- function(){
characters <- c(0:9, letters[1:6]);
while(file.exists(sessiondir(
hash <- paste(c("x0", sample(characters, config("key.length"), replace=TRUE)), collapse="")
hash <- substring(paste(rand_bytes(config("key.length")), collapse=""), 1, config("key.length"))

This comment has been minimized.

Copy link
@behrica

behrica Oct 28, 2014

Contributor

This change broke something ... I tried now against http://public.opencpu.org and I cannot access the session from a previous call anymore.

 curl https://public.opencpu.org/ocpu/library/stats/R/rnorm -d "n=10&mean=6"
/ocpu/tmp/ad6d22db5/R/.val
/ocpu/tmp/ad6d22db5/stdout
/ocpu/tmp/ad6d22db5/source
/ocpu/tmp/ad6d22db5/console
/ocpu/tmp/ad6d22db5/info
/ocpu/tmp/ad6d22db5/files/DESCRIPTION

curl -X POST https://public.opencpu.org/ocpu/library/base/R/summary -d "object=ad6d22db5"
object 'ad6d22db5' not found

In call:
summary(object = ad6d22db5)

If I look at line 4 (method session_regexp), it seems to me that a session key is assumed to start with "x0", which is not the case any more.

))){}
hash;
}
Expand Down

5 comments on commit d7d97f7

@jeroen
Copy link
Member Author

@jeroen jeroen commented on d7d97f7 Oct 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@behrica
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote a regression test suite for my Clojure library for opencpu:
https://github.com/behrica/opencpu-clj

I run it from time to time against the public instance , so I found it easily.

@jeroen
Copy link
Member Author

@jeroen jeroen commented on d7d97f7 Oct 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeroen
Copy link
Member Author

@jeroen jeroen commented on d7d97f7 Oct 28, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed a new version to the demo server. Can you check if this is fixed?

@behrica
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works now.

Please sign in to comment.