superset icon indicating copy to clipboard operation
superset copied to clipboard

How to create datasources and tables using curl ?

Open AnithaMurugesan opened this issue 8 years ago • 8 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [ ] I have checked the superset logs for python stacktraces and included it here as text if any
  • [ ] I have reproduced the issue with at least the latest released version of superset
  • [ ] I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.20.6

Expected results

Creating datasources and tables using curl.

Actual results

I have tried with the following. What are the datas to be passed here? curl -H "Content-Type: application/json" -X POST -d '{ ? }' http://localhost:8088/tablemodelview/api/create

I got this error: { "message": "Access is Denied", "severity": "danger" }

Also in logs: "POST /tablemodelview/api/create HTTP/1.1" 401 -

Steps to reproduce

What is the api endpoint for creating datasources and tables?? What are the datas to be passed along with curl?

AnithaMurugesan avatar Dec 06 '17 10:12 AnithaMurugesan

Also I am using REMOTE_USER authentication type. So there is no password for the users. Can remote user access this endpoint ?? - /tablemodelview/api/create I have tried with the following curl also: curl -i -H 'Authorization: Basic XXX' -H "Content-type: application/json" -X POST --data '{"database_id" : "2" , "schema" : "public" , "table_name" : "aa"}' http://localhost:8088/tablemodelview/api/create

Error: < HTTP/1.0 401 UNAUTHORIZED { "message": "Access is Denied", "severity": "danger" }

AnithaMurugesan avatar Dec 07 '17 08:12 AnithaMurugesan

REMOTE_USER assumes you have headers added by a proxy. So from behind the proxy you would spoof these headers, just find the CURL feature to set headers on the request. Of course you have to be behind the proxy to do this, the proxy shouldn't let you spoof or that would be a security hole.

mistercrunch avatar Dec 07 '17 16:12 mistercrunch

Thanks.. Will try with that headers..

AnithaMurugesan avatar Dec 08 '17 06:12 AnithaMurugesan

I hereby understood this. Please correct it if I am wrong.

In config.py file, we can add static headers like HTTP_HEADERS = {'X-Frame-Options': 'SAMEORIGIN'}

And in curl pass those same headers also. I tried this.. It is not working.

If wrong how to add those headers by proxy??

AnithaMurugesan avatar Dec 08 '17 07:12 AnithaMurugesan

more like HTTP_HEADERS = {'REMOTE_USER': 'username_you_want_to_spoof'}

mistercrunch avatar Dec 08 '17 08:12 mistercrunch

But I can use users/api/create for creating users without this authorization problem as REMOTE_USER. Is there any connection between this?

AnithaMurugesan avatar Dec 08 '17 09:12 AnithaMurugesan

Ok....thanks..Will give it a try.

AnithaMurugesan avatar Dec 08 '17 09:12 AnithaMurugesan

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

stale[bot] avatar Apr 11 '19 05:04 stale[bot]