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

Client Unauthorised when using opal.post to run a report #4

Open
sam-story opened this issue Jun 11, 2019 · 1 comment
Open

Client Unauthorised when using opal.post to run a report #4

sam-story opened this issue Jun 11, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@sam-story
Copy link

I am able to run a report from an R environment but the same script errors when run as a report.

To reproduce:

Upload the attached "test_report.Rmd" file to the CLSA project on https://opal-demo.obiba.org.
Put the file in the folder "/projects/CLSA"
Create a report template in the project CLSA

image

Name: target_report
R Markdown File: /projects/CLSA/test_report.Rmd
The report contains the authentication info so no need to set up the R options

Save the report and run it. It should run fine.

Next open the file "Run_report.Rmd" in an R environment with opalr installed. Run the file and it should execute the target_report in the CLSA project in opal.

Now upload the file "Run_report.Rmd" to Opal and set it up as a report. Execute the report and it will fail and will not start the target_report. "Error : Client error: (401) Unauthorized"

The whole process is being run as the Administrator user so not sure what is making it unauthorized.

Report_files.zip

@ymarcon ymarcon self-assigned this Jun 12, 2019
@ymarcon ymarcon added the bug Something isn't working label Jun 12, 2019
@ymarcon
Copy link
Member

ymarcon commented Jun 12, 2019

I have tested on my local instance (http://localhost:8080) and by adding R command in the report: options(verbose=TRUE). The output in /var/lib/rserver/logs/Rserve.log is:

> GET /ws/system/subject-profile/_current HTTP/1.1
Host: localhost:8080
Accept: application/json, application/octet-stream
Authorization: X-Opal-Auth YWRtaW5pc3RyYXRvcjpwYXNzd29yZA==

< HTTP/1.1 200 OK
< Date: Wed, 12 Jun 2019 15:09:44 GMT
< X-Opal-Version: 2.14.0-SNAPSHOT
* cookie size: name/val 7 + 36 bytes
* cookie size: name/val 4 + 1 bytes
* cookie size: name/val 7 + 29 bytes
* cookie size: name/val 7 + 4 bytes
* Added cookie opalsid="23de6457-de34-416c-a01f-70d5cbbb2bf2" for domain localhost, path /, expire 1560353984
< Set-Cookie: opalsid=23de6457-de34-416c-a01f-70d5cbbb2bf2;Path=/;Expires=Wed, 12-Jun-2019 15:39:44 GMT;Max-Age=1800
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Allow: GET, OPTIONS
< Cache-Control: no-cache
< Content-Type: application/json
< Expires: -1
< Pragma: no-cache
< Vary: Accept-Encoding, User-Agent
< Transfer-Encoding: chunked
< 
* Connection #0 to host localhost left intact
now dyn.load("/usr/local/lib/R/site-library/curl/libs/curl.so") ...
-> POST /ws/project/CLSA/commands/_report HTTP/1.1
-> Host: localhost:8080
-> User-Agent: libcurl/7.58.0 r-curl/3.3 httr/1.4.0
-> Accept-Encoding: gzip, deflate
-> Accept: application/json, text/xml, application/xml, */*
-> Content-Type: application/json
-> Content-Length: 41
-> 
>> {"name":"target_report","project":"CLSA"}
<- HTTP/1.1 401 Unauthorized
<- Date: Wed, 12 Jun 2019 15:09:44 GMT
<- X-Opal-Version: 2.14.0-SNAPSHOT
<- Set-Cookie: opalsid=;Path=/;Expires=Thu, 01-Jan-1970 00:00:00 GMT;Max-Age=0
<- Expires: Thu, 01 Jan 1970 00:00:00 GMT
<- Cache-Control: no-cache
<- Expires: -1
<- Pragma: no-cache
<- WWW-Authenticate: X-Opal-Auth realm="Opal"
<- Content-Length: 0
<- 
Quitting from lines 21-34 (Run_report.Rmd) 

Error : Client error: (401) Unauthorized

This means that despite there was a Set-Cookie in the first response, the subsequent request does not have a opalsid Cookie header. Then opal considers that this is not an authenticated request and responds that it is unauthorized.

Normally it's curl (httr package) job to handle the http session and have a followup with the cookies. It's strange that it works when running test_report.Rmd in opal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants