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

add support for HTTP Basic authentication #4228

Merged
merged 1 commit into from
Mar 7, 2017

Conversation

tomkralidis
Copy link
Contributor

@luipir
Copy link
Contributor

luipir commented Mar 6, 2017

hi @tomkralidis

IMHO A Core plugin should use QGIS Authentication infrastructure, please have a look to:

http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/authentication.html

how to manage and save credentials in AuthDb. Thhere is also a sample code to move from httplib to QgsNetworkAccessManager. It can be used to inspire porting credential (and network management) to a uniform way.

@tomkralidis
Copy link
Contributor Author

thanks @luipir. Will review and update.

@elpaso
Copy link
Contributor

elpaso commented Mar 7, 2017

@tomkralidis if you want a "pythonic" synchronous interface to QgsNetworkAccessManager you can use this class: https://github.com/boundlessgeo/qgis-geoserver-plugin/blob/master/geoserverexplorer/geoserver/networkaccessmanager.py#L78 , it supports proxy QGIS config and auth manager.

@luipir
Copy link
Contributor

luipir commented Mar 7, 2017

@tomkralidis
Copy link
Contributor Author

@luipir @elpaso thanks for the info. MetaSearch's HTTP handling is buried deep inside of OWSLib (which does the heavy lifting of the CSW handling we require for MetaSearch), so using something like QgsNetworkAccessManager will not be possible at this time.

For HTTP basic auth I have implemented QgsAuthManager to input/store credentials. Are there any examples of how to read HTTP Basic credentials?

@luipir
Copy link
Contributor

luipir commented Mar 7, 2017

you can find example in qgis-geoserver-plugin, but conceptually you have to get a AuthConfig (pointed by authid), from AuthManager. The AuthConfig will have credentials stored in it.

the main problem of this way to work, is that is not granted to be ported in QGIS3, due the secure problem to give access with python api to method to access sensible data (also when protected with a master pwd)

Give a look to NetworkAccessManager how expand credentials in a request URL starting from authid.

@elpaso
Copy link
Contributor

elpaso commented Mar 7, 2017

@tomkralidis are you sure that you cannot config/patch owslib to use NetworkAccessManager to access the network? This is what we have done with other libraries, like gsconfig. I don't want to push anyone to use my class, but the "right" way to access the network from a QGIS plugin is to use QgsNetworkAccessManager, from that you get QGIS proxy and authentication support for free and you do need to worry about implementing it yourself like if you were using requests httlib urllib or any other python networking libraries that does not know about QGIS.

@tomkralidis
Copy link
Contributor Author

@elpaso this would need to be an OWSLib enhancement and will take considerable time and effort.

Are folks ok if this pull request goes ahead as is and then implements networking correctly once OWSLib is updated?

@elpaso
Copy link
Contributor

elpaso commented Mar 7, 2017

@tomkralidis yes, sure, go ahead.

@tomkralidis
Copy link
Contributor Author

Travis error is unrelated, merging.

@tomkralidis tomkralidis merged commit 9754590 into qgis:master Mar 7, 2017
@tomkralidis tomkralidis deleted the metasearch-http-basicauth branch March 7, 2017 12:13
@tomkralidis
Copy link
Contributor Author

@elpaso / @luipir merged. Thanks for the feedback and suggestions. FYI new issue to update MetaSearch's HTTP support filed in http://hub.qgis.org/issues/16304.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants