PostgreSQL 应用程序访问

发布于 2024-11-08 19:32:23 字数 254 浏览 0 评论 0原文

我正在使用 JDBC 连接到 PostgreSQL 数据库。我们正在尝试阻止用户本身访问数据库;相反,他们应该被迫使用我们的前端。我们阻止了对任何表的访问,只提供了为用户完成所有工作的过程,但仍然不给他们任何直接访问数据的机会。我们尝试阻止对模式 pg_catalog 的访问,这将用户限制为我们创建的过程,但 JDBC 调用任何过程似乎都需要此访问权限。

无论如何,问题是如何在不访问 pg_catalog 的情况下使用 JDBC,或者如何仅授权应用程序而不是用户建立的连接。

I'm using JDBC to connect to a PostgreSQL database. We are trying to block access to the database for the users themselves; instead they should be forced to use our frontend. We blocked access to any table, and gave only procedures, which do all the work for users, still not giving them any opportunity to access data directly. We tried to block access to schema pg_catalog, which limits users to procedures we created, but it seems that this access is needed for JDBC to call any procedure.

Anyway, the question is either how to use JDBC without access to pg_catalog, or how to authorize only connections made by application, not user.

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

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

发布评论

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

评论(3

窝囊感情。 2024-11-15 19:32:23

没有万无一失的方法,但最简单的方法是使用您不提供给用户的用户名和密码进行连接。将密码存储在加密的配置文件中。当然,聪明人可以从应用程序中检索加密密钥。

对于一个真正节省的系统,最好在数据库前面放置一个服务来处理所有安全性并提供高级 API 来访问数据并让客户端连接到它。

There is no fool proof way but the simplest is to use a username and password for the connection that you do not give to your users. Store the password in an encrypted configuration file. Ofcourse the encryption key can be retrieved from the application by a smart person.

For a really save system it would probably be best to put a service in front of the database that handles all security and provides a high level API to access the data and let the client connect to this.

错々过的事 2024-11-15 19:32:23

DBMS 面临着 Catch-22 情况:

  • 当用户运行特定的 JDBC 程序来访问数据库时,让它做它的事情。
  • 当用户运行任何其他 JDBC 程序来访问数据库时,不要让它做它的事情。

DBMS 如何区分两个程序之间的差异?就其而言,它们都是使用正确协议与 DBMS 通信的客户端,并且已将自己标识为数据库的合法用户。

为了使其发挥作用,您必须找到一种不可颠覆的方法来区分这两个应用程序。至少可以说,这并不是一件小事。

存在一些矛盾,但没有一个干净的解决方案。当问题如问题中所示时,这是任何 DBMS 都会面临的一个普遍问题。

The DBMS is being presented with a Catch-22 situation:

  • When a user runs a specific JDBC program to access the database, let it do its stuff.
  • When a user runs any other JDBC program to access the database, do not let it do its stuff.

How can the DBMS tell the difference between the two programs? As far as it is concerned, they are both clients that are using the correct protocol to communicate with the DBMS, and have identified themselves as a legitimate user of the database.

To make it work, you have to find a non-subvertible way to distinguish between the two applications. That is not trivial - to say the least.

There are kludges, but there isn't a clean solution. It is a generic problem that any DBMS faces when the problem is presented as in the question.

夜清冷一曲。 2024-11-15 19:32:23

好吧,只是不要为您的用户提供 postgresql 数据库帐户,而只为您的应用程序创建一个 postgresql 帐户。

Well, just don't give your users an account on your postgresql database and create only an postgresql account for your application.

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