phac-nml / irida

Canada’s Integrated Rapid Infectious Disease Analysis Platform for Genomic Epidemiology
https://irida.ca
Apache License 2.0
40 stars 31 forks source link

REST API cannot handle http redirects #398

Open apetkau opened 5 years ago

apetkau commented 5 years ago

Describe the bug

Some IRIDA installations have http redirected to https. While this works in the browser, it looks like the REST API does not handle these situations and fails.

Steps to reproduce the problem

  1. Setup IRIDA so that it is behind a reverse proxy (e.g., Apache or nginx).
  2. Redirect http requests from one location to another (e.g, http -> https).
  3. Try accessing IRIDA web from http, should work.
  4. The REST API will not work.

Expected behaviour

I expected the REST API to be able to handle http redirects.

Additional context

None.

ksierks commented 3 years ago

I tried installing both NGINX and Apache2 locally. Tested with browser, curl, and Postman. As the logs show below, both work as expected:

NGINX

==> /var/log/nginx/reverse-access.log <== ::1 - - [30/Apr/2021:13:22:03 -0500] "POST /api/oauth/token?client_id=testClient&client_secret=testClientSecret&grant_type=password&username=admin&password=password1 HTTP/1.1" 301 178 "-" "PostmanRuntime/7.26.8"

==> /var/log/nginx/ssl-reverse-access.log <== 127.0.0.1 - - [30/Apr/2021:13:22:03 -0500] "GET /api/oauth/token?client_id=testClient&client_secret=testClientSecret&grant_type=password&username=admin&password=password1 HTTP/1.1" 200 128 "http://localhost/api/oauth/token?client_id=testClient&client_secret=testClientSecret&grant_type=password&username=admin&password=password1" "PostmanRuntime/7.26.8"

APACHE2

==> /var/log/apache2/irida_access.log <== ::1 - - [30/Apr/2021:09:48:25 -0500] "POST /api/oauth/token?client_id=testClient&client_secret=testClientSecret&grant_type=password&username=admin&password=password1 HTTP/1.1" 301 739 "-" "PostmanRuntime/7.26.8"

==> /var/log/apache2/irida_access_ssl.log <== 127.0.0.1 - - [30/Apr/2021:09:48:25 -0500] "GET /api/oauth/token?client_id=testClient&client_secret=testClientSecret&grant_type=password&username=admin&password=password1 HTTP/1.1" 200 1003 "http://localhost/api/oauth/token?client_id=testClient&client_secret=testClientSecret&grant_type=password&username=admin&password=password1" "PostmanRuntime/7.26.8"