cloudbeaver icon indicating copy to clipboard operation
cloudbeaver copied to clipboard

Allow preconfiguring connection type value in data-sources.json (e.g. PostgreSQL Passfile) and/or document how to do this

Open webketje opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe. It looks like it's currently not possible to preconfigure a connection to use a .pgpass file. The use case is a Dockerfile extending dbeaver/cloudbeaver:latest, setting ENV PGPASSFILE='/opt/cloudbeaver/conf/pgpass.conf', intended to be deployed on Openshift (using volume mounts and/or docker run --env and/or docker build --build-arg args)

Describe the solution you'd like I would like to be able to preconfigure the value "PostGreSQL Passfile" in the dropdown in the screenshot below as part of the data-sources.json connection spec. It already allows host, port, user, if it had a connectionType it could easily match a .pgpass file line with the rest of the connection's parameters. If this solution does exist, please make it easier to find in the docs? I've searched them for about an hour. image

Currently this is the only obstacle standing in the way of a fully automated containerized DB GUI solution. Another acceptable solution would be a way to pre-generate the credentials-config.json

webketje avatar Sep 11 '24 16:09 webketje

Hello @webketje

I am confused about your authentication screen. Did you try to use the PostgreSQL PgPass authentication type? Why do you use pgpass + database native type?

2024-09-12 11_10_56-CloudBeaver Community — Mozilla Firefox

LonwoLonwo avatar Sep 12 '24 09:09 LonwoLonwo

@LonwoLonwo The screenshot just indicates the location of the field that I wish to show "PostgreSQL PgPass" by default, the first time it is opened. In the context of a Docker container, you don't want to have to do post-deploy configuration in the dashboard, my request is to pre-set this value programmatically via env vars/ config at the server-side.

I've searched some more and found: https://dbeaver.com/docs/dbeaver/Database-authentication-models/#pgpass, which mentions the model ID of the value (I think) postgres_pgpass. However, https://dbeaver.com/docs/cloudbeaver/Create-Connection/#use-the-pre-configured-connections only mentions data-sources.json briefly and it is not explained anywhere which "model ID's" map to the fields in the Create connection UI.

So I created a connection via the UI, then went into the container to see how the values were updated. What I believe I am looking for is:

{
  "connections": {
    "postgres-1": {
        "auth-model": "postgres_pgpass",
        ...otherProperties
      }
   }
}

Haven't tested yet, but just as much in the dark as to where Cloudbeaver will look for the pgpass file... Does it take into account the PGPASSFILE env var? PS: this is not only about PGSQL, this is about a lack of clarity on how to preconfigure /opt/cloudbeaver/workspace/GlobalConfiguration/.dbeaver/data-sources.json

webketje avatar Sep 12 '24 16:09 webketje

Hello @webketje

Sorry for the late response.

We've created an article for you about PGPass. Please take a look: https://github.com/dbeaver/cloudbeaver/wiki/Authentication-PostgreSQL-Pgpass

LonwoLonwo avatar Dec 10 '24 14:12 LonwoLonwo

Thank you @LonwoLonwo, one of the doubts I have was whether, just like postgresql, Cloudbeaver would respect the env var PGPASSFILE as instructed at https://www.postgresql.org/docs/current/libpq-pgpass.html#LIBPQ-PGPASS linked to from https://dbeaver.com/docs/dbeaver/Authentication-PostgreSQL-Pgpass/:

the password file to use can be specified using the connection parameter passfile or the environment variable PGPASSFILE.

Having a connection with "auth-model": "postgres_pgpass" and an env var PGPASSFILE=/opt/cloudbeaver/conf/pgpass.conf with a valid PGPASS file seems to work (credentials are retrieved) but the UI displays as if "auth-model": "native" was in the connection config.

Another oddity (unrelated to this issue) I noticed while creating a depending container image is that defining serverName in cloudbeaver.conf is not enough to "skip" Cloudbeaver setup, but it works when CB_SERVER_NAME is defined as env var:

FROM dbeaver/cloudbeaver:latest

# ... other setup stuff

# must specify this in the Dockerfile and not as 'serverName' in cloudbeaver.conf
# in order to skip manual setup at first visit after container creation
ENV CB_SERVER_NAME='DB ADMIN'

webketje avatar Dec 20 '24 16:12 webketje

Hi, @webketje ! PgPass authentication model is displayed in the UI only for administrators.

I can't reproduce the issue with defining the serverName parameter and the configuration mode. Could you please provide the server logs?

yagudin10 avatar Feb 25 '25 13:02 yagudin10

It's been a while since there has been an update here. Please let me know if the issue is still present and provide additional information.

LonwoLonwo avatar Sep 09 '25 10:09 LonwoLonwo