pramsey / pgsql-ogr-fdw

PostgreSQL foreign data wrapper for OGR
MIT License
237 stars 34 forks source link

Connect to protected WFS with user mapping #241

Closed danceb closed 9 months ago

danceb commented 1 year ago

Hello there,

I am trying to implement a WFS service, where the access is restricted with a user and a password. Creating the server itselfs like this works fine.

CREATE SERVER wfs_server
    FOREIGN DATA WRAPPER ogr_fdw
    OPTIONS (
        datasource 'WFS:http://wfs.server.com',
        format 'WFS' );

I thought, that I could create a user mapping then in this way like with other foreign data wrappers:

CREATE USER MAPPING FOR postgres SERVER wfs_server
OPTIONS (user 'user', password 'password');

But then I get the error: invalid option "user". There are no valid options in this context. So is it not possible to connect to a WFS service with user credentials? Or is it done in another way?

Thanks for your help!

pramsey commented 1 year ago

You know, I had never really considered doing user mapping in ogr-fdw, but now you mention it, it makes some sense... as it stands right now the "way" to do it would be to encode user and password into appropriate GDAL options.

pramsey commented 9 months ago

It's still the "right way", but unfortunately we are limited by the OGR API and there is no way to set a username/password for an OGC connection in a driver-independent way, and that's our bottom line: everything in our code must use the public OGR API, so that we support all formats equally.