且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用物理Postgres的用户登录系统不能与QUOT;逻辑QUOT;用户

更新时间:2022-06-08 09:12:06

要实现自己的目标。

所有的插入,更新和删除,需要留下痕迹,这是
  困难的,如果不是不可能的一个标准用户改变

all inserts, updates and deletes, need to leave a trail that is difficult, if not impossible for a standard user to change.

您可以创建:

1)两个模式:一个是普通表,一个是安全的东西,如登录/密码(哈希)表,用户会话日志,更改日志表等

1) Two schemas: one for common tables, one for security stuff like login/pass(hash) table, user session log, change log table, etc.

2)两个用户:一个普通用户,只能在公共模式(无DDL)使用DML,一是超级

2) Two users: one common user, that can only use dml on common schema (no ddl), one superuser.

3)登录功能,将检查所提供的用户名/密码对登录/密码表,记录成功/失败的尝试到用户会话日志(需要 SECURITY DEFINER 功能)

3) Login function that will check provided user/pass against login/pass table and log successful/failed attempts into user session log (you need SECURITY DEFINER function)

4)将审核触发公共架构表,将检查用户权限并记录任何更改,用户所做的( SECURITY DEFINER 的功能在这里太)。

4) Set of audit triggers on common schema tables that will check the user privileges and log any changes, made by the user (SECURITY DEFINER functions here too).