Oracle9i Supplied PL/SQL Packages and Types Reference Release 2 (9.2) Part Number A96612-01 |
|
The DBMS_RLS
package contains the fine-grained access control administrative interface. DBMS_RLS
is available with the Enterprise Edition only.
See Also:
Oracle9i Application Developer's Guide - Fundamentals for a detailed example and more usage information on |
This chapter discusses the following topics:
The functionality to support fine-grained access control is based on dynamic predicates, where security rules are not embedded in views, but are acquired at the statement parse time, when the base table or view is referenced in a DML statement.
A dynamic predicate for a table, view, or synonym is generated by a PL/SQL function, which is associated with a security policy through a PL/SQL interface. For example:
DBMS_RLS.ADD_POLICY ( 'hr', 'employees', 'emp_policy', 'hr', 'emp_sec', 'select');
Whenever the EMPLOYEES
table, under the HR schema, is referenced in a query or subquery (SELECT
), the server calls the EMP_SEC
function (under the HR
schema). This returns a predicate specific to the current user for the EMP_POLICY
policy. The policy function may generate the predicates based on the session environment variables available during the function call. These variables usually appear in the form of application contexts.
The server then produces a transient view with the text:
SELECT * FROM hr.employees WHERE P1
Here, P1
(for example, where SAL
> 10000, or even a subquery) is the predicate returned from the EMP_SEC
function. The server treats the EMPLOYEES
table as a view and does the view expansion just like the ordinary view, except that the view text is taken from the transient view instead of the data dictionary.
If the predicate contains subqueries, then the owner (definer) of the policy function is used to resolve objects within the subqueries and checks security for those objects. In other words, users who have access privilege to the policy-protected objects do not need to know anything about the policy. They do not need to be granted object privileges for any underlying security policy. Furthermore, the users do not require EXECUTE
privilege on the policy function, because the server makes the call with the function definer's right.
Note: The transient view can preserve the updatability of the parent object because it is derived from a single table or view with predicate only; that is, no |
DBMS_RLS
also provides the interface to drop, enable, and disable security policies. For example, you can drop or disable the EMP_POLICY
with the following PL/SQL statements:
DBMS_RLS.DROP_POLICY('hr', 'employees', 'emp_policy'); DBMS_RLS.ENABLE_POLICY('hr', 'employees', 'emp_policy', FALSE)
A security check is performed when the transient view is created with a subquery. The schema owning the policy function, which generates the dynamic predicate, is the transient view's definer for security check and object lookup.
The DBMS_RLS
procedures cause current DML transactions, if any, to commit before the operation. However, the procedures do not cause a commit first if they are inside a DDL event trigger. With DDL transactions, the DBMS_RLS
procedures are part of the DDL transaction.
For example, you may create a trigger for CREATE
TABLE
. Inside the trigger, you may add a column through ALTER
TABLE
, and you can add a policy through DBMS_RLS
. All these operations are in the same transaction as CREATE
TABLE
, even though each one is a DDL statement. The CREATE
TABLE
succeeds only if the trigger is completed successfully.
Views of current cursors and corresponding predicates are available from v$vpd_policies
.
A synonym can reference only a view or a table.
|
Copyright © 2000, 2002 Oracle Corporation. All Rights Reserved. |
|