如何使用Kerberos连接到Postgres

发布于 2025-01-22 13:11:29 字数 985 浏览 4 评论 0原文

我有使用Kerberos身份验证的Postgres DB。因此,我配置了我的/etc/krb5.conf文件,运行kinit现在可以使用它,例如在Python代码中:

import psycopg2

conn = psycopg2.connect(
    host="database.address.com",
    database="tested",
    user="username",
    port=5472
)

# Get version
cursor = conn.cursor()
cursor.execute('SELECT VERSION()')
row = cursor.fetchone()
print(row)

它可以完美地工作,但是有时它非常有用有能力在表中观看数据。我想使用Datagrip,但是我无法弄清楚如何将其连接到DB。

我发现了一些关于它的古老问题: https://intellij-support.jetbrains.com/hc/en-us/community/community/posts/115000757404-datagrip-mac-kerberos-kerberos-authentication-with-postgresql

-Djava.security.krb5.realm=realm -Djava.security.krb5.kdc=kdc

,但不能理解如何获取境界kdc的正确值

I have Postgres DB that uses kerberos authentication. So I configured my /etc/krb5.conf file, run kinit and now can use it, for example in python code:

import psycopg2

conn = psycopg2.connect(
    host="database.address.com",
    database="tested",
    user="username",
    port=5472
)

# Get version
cursor = conn.cursor()
cursor.execute('SELECT VERSION()')
row = cursor.fetchone()
print(row)

It works perfectly, but sometime it is very useful to have ability to watch data in tables. I want to use DataGrip, but I can't figured out how to connect it to DB.

I found some old question about it: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000757404-DataGrip-Mac-Kerberos-Authentication-with-PostgreSQL

-Djava.security.krb5.realm=realm -Djava.security.krb5.kdc=kdc

but can't understand how to get correct values for realm and kdc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

禾厶谷欠 2025-01-29 13:11:29
  1. 创建使用以下内容的文件jaas.conf:
  pgjdbc {
com.sun.security.auth.module.krb5loginmodule所需
useticketcache = true
debug = true
reenewtgt = true
donotprompt = true;
};
 
  1. 打开数据源属性,转到高级选项卡并将其添加到VM选项字段中:-djava.security.auth.login.config =< path; path_to>/jaas.conf

  2. 如果无济

  3. 如果仍然不起作用,请向您的DBA询问kdcrealm names。

  1. Create file jaas.conf with following content:
pgjdbc {
com.sun.security.auth.module.Krb5LoginModule required
useTicketCache=true
debug=true
renewTGT=true
doNotPrompt=true;
};
  1. Open up data source properties, go to Advanced tab and add this to VM options field: -Djava.security.auth.login.config=<path_to>/jaas.conf

  2. If it does not help and you have working krb5.conf also add this -Djava.security.krb5.conf=/etc/krb5.conf to the VM options

  3. If it still does not work, please ask your DBA for kdc and realm names.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文