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

[RFE] Getting Unauthorized and CORS issue while making a post call to automation_requests API #18517

Open
Raghvendra1987 opened this issue Mar 4, 2019 · 7 comments

Comments

@Raghvendra1987
Copy link

Raghvendra1987 commented Mar 4, 2019

I am trying making post call to API using UI which is written in reactJS.

it works through postman. It's failing in OPTIONS

Background.js:38 OPTIONS https://abc.com/api/automation_requests 401 (Unauthorized)

abc.com/:1 Access to fetch at 'https://abc/api/automation_requests' from origin 'https://abc.xx.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

@Fryguy
Copy link
Member

Fryguy commented Aug 3, 2019

@himdel @martinpovolny @abellotti Thoughts here?

@Fryguy Fryguy added the bug label Aug 3, 2019
@himdel
Copy link
Contributor

himdel commented Aug 5, 2019

EDIT: this is probably not relevant at all

There are 2 different ways of authenticating against the API:

Most likely, the problem is that you have a manageiq cookie (vmdb) and not sending any other authentication data.
In that case, authentication will try to use the cookie, and fail on bad csrf.

If you explicitly provide username & password via HTTP Basic to the API call, it should work.
(Or, you can send them to the api login endpoint, receive a token, and use that on all subsequent requests.)

@himdel
Copy link
Contributor

himdel commented Aug 5, 2019

Sorry, I was reading this wrong... this is a CORS issue.

Postman does not check cors, because it's a development tool.
But the browser does.

So, 2 options:

  • access the API from the same domain - that's how manageiq appliances work, the API is listening on the same domain+port as the UI, thus, no cors issues

  • add a way to configure the API so that it will allow specific domains - so that you would have a place to add the domain as allowed in manageiq advanced configuration (@abellotti - does such a way already exist by any chance?)

@chessbyte
Copy link
Member

@abellotti any ideas?

@himdel himdel removed their assignment Apr 24, 2020
@gtanzillo
Copy link
Member

@himdel Do you think this is an issue that needs to be fixed or can it be closed?

@himdel
Copy link
Contributor

himdel commented Jun 22, 2020

Well .. we don't need to support it for anything we're doing, and it was never possible before, so this is really a feature request.

@himdel
Copy link
Contributor

himdel commented Jun 22, 2020

So, we can decide not to support it,
and/or document how to update the appliance to achieve this when desired,
or add product settings or UI to enable specific domains (possibly complicated given the appliance/pods split).

EDIT: I think for pods, this would have to be a build-time setting, not a runtime one

@chessbyte chessbyte changed the title Getting Unauthorized and CORS issue while making a post call to automation_requests API [RFE] Getting Unauthorized and CORS issue while making a post call to automation_requests API Jun 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants