Database Access Control
Control database access with DDS Data Grants, active Data Roles, and server-verified end-user context attributes.
DDS Overview
DDS uses Oracle DeepSec to enforce authorization on the database schema. Authorization depends on the application user, target project schema, active Data Roles, applicable Data Grants, and end-user context attributes.
A Data Grant specifies the operations, columns, and rows a Data Role can access. Each project schema has default <SCHEMA>$NOAUTH_ROLE and <SCHEMA>$AUTHENTICATED_ROLE roles. Use the project schema’s exact case in the role name.
For all relational Data Grant scenarios from the DeepSec source, see Data Grant Examples.
Authenticated and Unauthenticated Access
Data Grants can test ORA_END_USER_CONTEXT.BAASSYS.EU_CONTEXT.auth.is_authenticated. This attribute contains the string true or false.
Controlling Access to Tables and Views
Use a Data Grant to authorize an operation on a database table or view. This example permits authenticated users to select from the ARTICLES table:
In the Console, open Database > SQL Editor, enter the Data Grant statement, and click Run Script. These examples use project schema TESTUSER and an existing ARTICLES table with ID, EXCERPT, PUBLISHED_BY, and PUBLISHED_DATE columns. Replace TESTUSER in the role name with your project schema.
CREATE OR REPLACE DATA GRANT "restricted reads for myrecords" AS SELECT
ON ARTICLES
WHERE ORA_END_USER_CONTEXT.BAASSYS.EU_CONTEXT.auth.is_authenticated = 'true'
TO "TESTUSER$AUTHENTICATED_ROLE";
Row, Column, and Operation-Level Access
A Data Grant can restrict rows with a WHERE predicate, restrict columns in its operation clause, and specify allowed operations.
The following Data Grant permits an authenticated user to update only articles that the user published:
CREATE OR REPLACE DATA GRANT "restricted updates for authors" AS UPDATE
ON ARTICLES
WHERE PUBLISHED_BY = ORA_END_USER_CONTEXT.BAASSYS.EU_CONTEXT.auth.user_id
TO "TESTUSER$AUTHENTICATED_ROLE";
For column-level access, use operation clauses such as SELECT(ID, EXCERPT, PUBLISHED_BY) and UPDATE(PUBLISHED_DATE).
Using the End User Security Context
Reference server-verified context attributes in a Data Grant with the following form:
ORA_END_USER_CONTEXT.BAASSYS.EU_CONTEXT.<attribute-chain>
Available attributes include:
- Authentication attributes such as
auth.is_authenticated,auth.sub,auth.user_id,auth.user_displayname,auth.idp_name,auth.email_verified, andauth.scope. - Project attributes such as
project.id,project.auth_type,project.auth_id,project.objs_type,project.objs_id, andproject.project_owner. - Request attributes
request.serviceandrequest.operation.
For each request, the service creates or refreshes the End User Security Context from verified identity, project, operation, and Data Role values.
Default-Deny Behavior
A matching Data Grant permits the requested operation. Otherwise, DDS denies the operation. Row and column restrictions can omit rows, mask values with null, or leave an update with zero affected rows. Check returned data and affected-row counts as well as authorization errors.