PostgreSQL 应用程序访问
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
没有万无一失的方法,但最简单的方法是使用您不提供给用户的用户名和密码进行连接。将密码存储在加密的配置文件中。当然,聪明人可以从应用程序中检索加密密钥。
对于一个真正节省的系统,最好在数据库前面放置一个服务来处理所有安全性并提供高级 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.
DBMS 面临着 Catch-22 情况:
DBMS 如何区分两个程序之间的差异?就其而言,它们都是使用正确协议与 DBMS 通信的客户端,并且已将自己标识为数据库的合法用户。
为了使其发挥作用,您必须找到一种不可颠覆的方法来区分这两个应用程序。至少可以说,这并不是一件小事。
存在一些矛盾,但没有一个干净的解决方案。当问题如问题中所示时,这是任何 DBMS 都会面临的一个普遍问题。
The DBMS is being presented with a Catch-22 situation:
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.
好吧,只是不要为您的用户提供 postgresql 数据库帐户,而只为您的应用程序创建一个 postgresql 帐户。
Well, just don't give your users an account on your postgresql database and create only an postgresql account for your application.