Support http authentication in parasol
acabrol opened this issue · 3 comments
Add "withCredentials" parameters on http ajax queries to support http basic auth through Reverse Proxy.
$http({ url: 'url of service', method: "POST", data: {test : name }, withCredentials: true, headers: { 'Content-Type': 'application/json; charset=utf-8' } });
https://stackoverflow.com/questions/21455045/angularjs-http-cors-and-http-authentication
There's a new fetchOptions parameter to to allow sending credentials to other domains with CORS : https://github.com/github/fetch#sending-cookies
Here is a setting example with LoaderJson:
<div
class="parasol"
data-settings='{
"networks": [
{
"url": "/docs/assets/data/les-miserables.json",
"fetchOptions": {"credentials": "include"},
"name": "LDA for movie reviews",
"options": {
"layout": "forcelink",
Let me know if working and if issue can be closed.
# html setting:
data-settings='{ "networks": [ { "url": "/api/graph", "name": "dfm", "fetchOptions": {"credentials": "include"}, "options": { "layout": "forcelink", "loader": { "name": "json" } } } ], "ui": { "drawers": [ { "id": "left", "open": true, "components": [ {"name": "Legend"}, {"name": "Divider"}, {"name": "SearchInput"}, {"name": "NetworkList"}, {"name": "Divider"}, {"name": "ForceLinkSettings"} ] }, { "id": "right", "open": true, "openSecondary": true, "components": [ {"name": "AppBar"}, {"name": "Divider"}, {"name": "SelectedNode"} ] } ] } }'
# apache setting:
Header set Access-Control-Allow-Credentials "true" Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"
# result:
`
Unauthorized
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
Apache at dfm `
Stacktrace:
GET https://***/api/graph 401 (Unauthorized) run @ parasol.js:164600 loadNetwork @ parasol.js:157715 initNetwork @ parasol.js:157740 (anonymous) @ parasol.js:157647 initSettings @ parasol.js:157644 initParasol @ parasol.js:154850 (anonymous) @ parasol.js:154886 Object.defineProperty.value @ parasol.js:154872 __webpack_require__ @ parasol.js:20 (anonymous) @ parasol.js:250947 __webpack_require__ @ parasol.js:20 (anonymous) @ parasol.js:66 (anonymous) @ parasol.js:69 explore:1 Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0