diff options
| author | David Sommerseth <dazo@users.sourceforge.net> | 2012-01-05 19:49:17 +0100 |
|---|---|---|
| committer | David Sommerseth <dazo@users.sourceforge.net> | 2013-06-13 01:01:55 +0200 |
| commit | f3c6505df85d22706e8a8a849ead71bb10246cbe (patch) | |
| tree | e41b47becd2ccb76cdcb7beadd9a2a23f582757a /database/postgresql | |
| parent | 9e34f375787fb267e3c6e735590abf25efb3d63b (diff) | |
| download | eurephia-f3c6505df85d22706e8a8a849ead71bb10246cbe.tar.gz eurephia-f3c6505df85d22706e8a8a849ead71bb10246cbe.tar.xz eurephia-f3c6505df85d22706e8a8a849ead71bb10246cbe.zip | |
Add an SQL VIEW for updating users.last_accessed more safely
It's not ideal to let the eurephia-auth user have write access to the
users table. This view will allow the eurephia-auth user only to touch
users.last_accessed; and this value will be enforced to be CURRENT_TIMESTAMP.
Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'database/postgresql')
| -rw-r--r-- | database/postgresql/sql-schema.sql | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/database/postgresql/sql-schema.sql b/database/postgresql/sql-schema.sql index 907d1d5..11b5c7d 100644 --- a/database/postgresql/sql-schema.sql +++ b/database/postgresql/sql-schema.sql @@ -43,6 +43,17 @@ CREATE TABLE users ( ); CREATE UNIQUE INDEX openvpn_users_uname ON openvpn_users(username); +-- View users_last_access: A view which allows the eurephia-auth user to update +-- the last_access column in users table +-- +-- The "touch" rule will enforce CURRENT_TIMESTAMP, not trusting the value provided +-- by the user updating this view. +-- +CREATE VIEW users_last_access AS SELECT uid, last_accessed FROM users; +CREATE RULE users_last_access_touch + AS ON UPDATE TO users_last_access + DO INSTEAD UPDATE users SET last_accessed = CURRENT_TIMESTAMP WHERE uid = NEW.uid; + -- Table usercerts: keeps the links of user accounts and certificates and -- which firewall access profile each access is granted CREATE TABLE usercerts ( |
