我们有几个专用于 Oracle DB 11gR2 中的模块(财务、股票、crm 等)的模式。我们希望为开发人员建立这样的架构:
- Developers will not have schema owner users' password.
- Developers will have time-limited access to DB objects, according to their level, in 2 ways:
- Top-level senior developers will have unlimited priviliges on a spesific schema when they were authorized for a limited period.
- Junior developers will have limited priviliges on a spesific schema when they were authorized for a limited period.
简而言之,我们想在 Oracle DB 中组织我们的开发方式。我们如何构建该结构? 如果我不够清楚,我可以为您的问题提供详细信息。
谢谢,
编辑:我有一种直觉,情况不是很清楚。让我举一个简单的场景:
假设我有一个名为“DUMMY”的模式(具有对象的用户),它有一个名为“DummyTbl”的表和一个名为“DummyFunc”的函数。显然,用户“DUMMY”可以无限制地管理所有这些对象,因为她是所有者。但是,我不希望开发人员使用通用用户“DUMMY”,我希望他们使用自己的用户名登录数据库。
因为,当我给他们用户'DUMMY's password 时,我无法区分开发人员的权限级别。所有的开发人员都可以无限制地行动。相反,我希望名为“DummySenior”的高级开发人员能够创建、更改、执行对象,并对“DummyTbl”执行 CRUD 操作。
但是,我希望名为“DummyJunior”的初级开发人员只引用对象而不对表执行 CRUD 操作。实现这一点最明显的方法是陪伴角色。但是,我们在配置所需角色时遇到了几个问题(即,'DummySenior' 的 afaik 能够在 'DUMMY' 模式下创建表,他必须具有 '创建任何表' 权限。
但是,当“DummySenior”拥有该权限时,他也可以在“DUMMY2”模式下创建表。这是一个明显的安全漏洞。)
最佳答案
对于高级开发人员,您可以创建一个定义者权限过程,该过程只需运行传入的任何命令。假设 DUMMY 具有相关的 CREATE TABLE/VIEW/...
权限,这有效地为高级开发人员提供了所有 SELECT ANY
权限,但仅限于该模式。
create or replace procedure dummy.execute_any(p_code in clob) authid definer is
begin
execute immediate p_code;
end;
/
--For a procedure this powerful, grant it directly to a user.
--That keeps the privilege "obvious", it won't get buried in layers of roles.
grant execute on dummy to senior_developer;
对于初级开发者,创建角色并动态授予其相关的SELECT
权限。您可能希望安排此过程或临时运行它。
--Create and populate role with some lesser object privileges on a schema.
create role junior_developer_role;
begin
--Repeat this structure for other objects, like sequences.
for tables in
(
select owner, table_name
from dba_tables
where owner = 'DUMMY'
) loop
execute immediate 'grant select on '||tables.owner||'.'||tables.table_name||
' to junior_developer_role';
end loop;
end;
/
关于oracle - Oracle数据库的开发架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29347824/