Thi*_*key 7 mysql database-design best-practices row-level-security
我正在尝试在我使用 MySQL 开发的 webapp 上模拟行级安全性。
使用此方法:使用所需的表创建一个数据库,其中将存储与所有用户有关的数据,并为表的列建立适当的索引。
根据用户 ID 为特定用户创建 mysql“视图”。
为了实现行级安全,我还必须为每个用户创建 mysql 帐户,并在视图上设置“授予”权限。
对于 Web 界面,将使用基于 PHP 的 MVC 框架。
但是,根据我的研究:
1] Having separate mysql account per user "make the webapp less secure".
2]Having separate mysql account per user "increases the disk I/O".
问题:
1] How does creating mysql user per webapp user make the webapp less secure?
2] Does the disk I/O increase considerably?
3] Is there a better way to implement row-level-security in MySQL?
4]What are the pros/cons of implementing row-level-security by the above method?
为什么我要查看行级安全性?
I need row level security because there are rows which will be shared between multiple users & have 1 or 2 owners to it. Only these owners can delete/modify them.
我无法添加诸如“行级安全性”“磁盘 io”之类的标签,因为我的声誉点较少。如果其他人可以,请这样做。
SHOW GRANTS;
在应用程序的数据库连接中运行,并公开已连接用户的所有授权。这可能包括查看主机 IP、子网。对特定表、视图和列的授权也变得可见。例子
delimiter $$
CREATE TRIGGER check_row_priv BEFORE UPDATE ON t1
FOR EACH ROW
BEGIN
IF (USER()='user1@localhost') && (OLD.is_editable=0)
THEN
-- Make Trigger Fail Here
END IF;
END; $$
delimiter ;
Run Code Online (Sandbox Code Playgroud)
我写了另一篇文章,展示了如何中止存储过程和触发器。问题中的其他答案可能会让您深入了解中止触发器,或者至少使数据不可变。
归档时间: |
|
查看次数: |
1812 次 |
最近记录: |