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

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

Open
webketje opened this issue Sep 11, 2024 · 4 comments

Comments

@webketje
Copy link

webketje commented Sep 11, 2024

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

@LonwoLonwo
Copy link
Member

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

@webketje
Copy link
Author

webketje commented Sep 12, 2024

@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

@LonwoLonwo
Copy link
Member

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

@webketje
Copy link
Author

webketje commented Dec 20, 2024

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'

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

No branches or pull requests

3 participants