9.1 Configure the Database for IAM Integration
Complete the required configuration in your database to integrate with an IAM system (for example, Microsoft Entra ID or OCI IAM) and implement Oracle Deep Data Security (Deep Sec). Your specific configuration steps vary depending on whether your IAM-managed users connect through an application or directly through a SQL client.
9.1.1 Set Up IAM Integration for Application-Mediated Connections
If your IAM-managed users connect to the database through an application, complete the following configuration steps in your database to enable end-user security context establishment.
Note:
- On Oracle AI
Database, run the SQL and PL/SQL statements in this section as a named user with
the DBA role. Run the statements that create the OCI IAM credential object
as
SYS. - On Oracle Autonomous AI Database, run the statements as the
ADMINuser.
- Enable transport layer security (TLS).Transmission of the end-user security context payload requires a TLS-secured connection between the Oracle client driver and the database server. If TLS is not already configured, see Configuring Transport Layer Security Encryption in Oracle AI Database Security Guide.
- Set up the connection pool user account.Create a connection pool user account and grant it both the
CREATE SESSIONandCREATE END USER SECURITY CONTEXTprivileges. Without the latter privilege, the database server rejects any attempt to attach an end-user security context payload to the session.You can provision the connection pool user account in either of the following two ways.- IAM-authenticated connection pool user accountCreate the connection pool user account by identifying it with the application's IAM client ID. This user authenticates to the database using the database-access token. This authentication method for the connection pool user account is supported only for Microsoft Entra ID.
CREATE USER hr_app_user IDENTIFIED GLOBALLY AS 'AZURE_CLIENT_ID=${HRAPP_CLIENT_ID}'; GRANT CREATE SESSION TO hr_app_user; GRANT CREATE END USER SECURITY CONTEXT TO hr_app_user; - Password-authenticated connection pool user accountAlternatively, create a standard database user account with a password. This user authenticates to the database using the password.
CREATE USER hr_app_user IDENTIFIED BY <password>; GRANT CREATE SESSION TO hr_app_user; GRANT CREATE END USER SECURITY CONTEXT TO hr_app_user;
- IAM-authenticated connection pool user account
- Configure the identity provider.Set the database identity provider parameters to match your database's IAM registration. This allows the database server to validate the audience (
aud) claim in the application’s database-access token.On Oracle AI Database, connect to your target pluggable database (PDB) before applying configuration changes. (On Oracle Autonomous AI Database, this step is not required; you connect directly to the PDB as theADMINuser.)ALTER SESSION SET CONTAINER = <your-target-PDB>;Configuration details vary by IAM system and token version in use. Complete the steps applicable to your environment.Note:
On Oracle Autonomous AI Database, if external authentication has already been enabled, theDBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATIONcall fails withORA-20004. Addforce => TRUEto the call to override the existing configuration. Only one external authentication method can be active at a time, so using force to switch IAM types (for example, from Entra ID to OCI IAM) deactivates the previously configured one.- Microsoft Entra ID v1 Tokens
For Entra ID v1 tokens, the database verifies that the database-access token’s
audclaim matches theapplication_id_urifield in the database’sidentity_provider_config.- On Oracle AI
Database, run the following
statements:
ALTER SYSTEM SET IDENTITY_PROVIDER_TYPE = AZURE_AD SCOPE=BOTH; ALTER SYSTEM SET IDENTITY_PROVIDER_CONFIG = '{ "application_id_uri": "<DB_APP_ID_URI>", "tenant_id": "<TENANT_ID>", "app_id": "<DB_APP_ID>" }' SCOPE=BOTH; - On Oracle Autonomous AI Database, run the following statement. If external authentication has
already been enabled, add
force => TRUEto the call by uncommenting the line:Note:
If Entra ID is already configured with the required parameter values, callingDBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATIONagain is not necessary. Useforceonly when you need to explicitly change the Entra ID values. Force-enabling overwrites the existing configuration and may break existing Entra ID-authenticated database users.
Replace the placeholders with values from your Entra ID instance. See Configure Microsoft Entra ID for Application-Mediated Access.BEGIN DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION( type => 'AZURE_AD', -- force => TRUE, params => JSON_OBJECT( 'tenant_id' VALUE '<TENANT_ID>', 'application_id' VALUE '<DB_APP_ID>', 'application_id_uri' VALUE '<DB_APP_ID_URI>' ) ); END; /
Parameter Description application_id_uriThe application ID URI of the database resource registered in Entra ID. tenant_idThe directory (tenant) ID of your Entra ID environment. app_idThe application (client) ID of the database resource. - On Oracle AI
Database, run the following
statements:
- Microsoft Entra ID v2 Tokens
For Entra ID v2 tokens, the database verifies that the database-access token’s
audclaim matches theapp_idfield in the database’sidentity_provider_config. The identity provider configuration follows the same format as v1 tokens. - Oracle Cloud Infrastructure Identity and Access Management (OCI
IAM)
For OCI IAM environments, use the
IDENTITY_PROVIDER_OAUTH_CONFIGparameter to set up the identity provider. Additionally, you must create a credential object.- On Oracle AI
Database, run the following
statements:
ALTER SYSTEM SET IDENTITY_PROVIDER_TYPE = OCI_IAM SCOPE=BOTH; ALTER SYSTEM SET IDENTITY_PROVIDER_OAUTH_CONFIG = '{ "app_id": "<application_id>", "domain_url": "<domain_url>" }' SCOPE=BOTH; - On Oracle Autonomous AI Database, run the following statement. If external authentication has
already been enabled for OCI IAM, add
force => TRUEto provide the additional parameters required for configuration. Force-enabling does not break the existing OCI IAM global user authentication:BEGIN DBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATION( type => 'OCI_IAM', -- force => TRUE, params => JSON_OBJECT( 'app_id' VALUE '<application_id>', 'domain_url' VALUE '<domain_url>' ) ); END; /Replace the placeholders with values from your OCI IAM instance. See Configure OCI IAM for Application-Mediated Access.
Parameter Description app_idThe application ID of the database application registered in OCI IAM. domain_urlThe OCI IAM domain URL. Used to retrieve the public signing key for OAuth 2.0 token validation. Note:
On Oracle Autonomous AI Database, theDBMS_CLOUD_ADMIN.ENABLE_EXTERNAL_AUTHENTICATIONcall forOCI_IAMautomatically populates bothIDENTITY_PROVIDER_CONFIG(with the OCI realm, region, and endpoint values) andIDENTITY_PROVIDER_OAUTH_CONFIG(with theapp_idanddomain_urlparameters you pass). You do not have to set these parameters separately. - Create the credential object.
To obtain an access token for the public signing-key endpoint, the database requires the client ID and client secret of the database's application registration in OCI IAM.
Create a credential object to store these values securely in the database. Obtain the client ID and client secret from the OAuth Configuration section of your database application in the OCI IAM console, and execute the following block.
On Oracle AI Database, run the following block asSYS:BEGIN DBMS_CREDENTIAL.CREATE_CREDENTIAL( credential_name => 'OCI_IAM_DOMAIN_DB_CRED$', username => '<CLIENT_ID>', password => '<CLIENT_SECRET>' ); END; /On Oracle Autonomous AI Database, run the following block asADMIN:BEGIN DBMS_CLOUD.CREATE_CREDENTIAL( credential_name => 'OCI_IAM_DOMAIN_DB_CRED$', username => '<CLIENT_ID>', password => '<CLIENT_SECRET>' ); END; /
- On Oracle AI
Database, run the following
statements:
To verify the identity provider settings, run the following command from your SQL*Plus prompt:SHOW PARAMETER identity; - Microsoft Entra ID v1 Tokens
- Create data roles.Define the data roles that you want to enable in your end-user security contexts. Because you are using IAM-managed users, you must create data roles mapped to the application roles in IAM. For the complete syntax and options, see Configure Data Roles.
- Perform optional additional configuration.The following tasks are not mandatory to establish a basic end-user security context, but may be required depending on your application’s authorization model.
- Create end-user context definitions.If your application logic or data grants rely on custom end-user context attributes, create the corresponding
END USER CONTEXTschema objects before deployment. See Configure End-User Contexts and Attributes. - Create the application identity.Set up a database identity for your application that matches its IAM client ID. This identity authorizes the application to activate specific data roles within an end-user security context. See Configure Application Identities.
- Grant additional data roles to the application identity.Explicitly grant any additional or common data roles that your application is allowed to activate. If you skip this step, the database silently ignores the application’s requests for ungranted roles. See Grant and Revoke Data Roles.
- Create end-user context definitions.
9.1.2 Set Up IAM Integration for Direct Logon
If your IAM-managed users (such as data analysts or developers) connect directly to the database using a SQL client and their own IAM access tokens, the database-side setup is more concise. Complete the following tasks.
- Enable transport layer security (TLS).Transmission of the end-user security context payload requires a TLS-secured connection between the client and the database server. If TLS is not already configured, see Configuring Transport Layer Security Encryption in Oracle AI Database Security Guide.
- Configure the identity provider.Set the database identity provider parameters to match your database's IAM application registration. This enables the database server to validate the audience (
aud) claim in the end-user token.Follow the procedure described in Set Up IAM Integration for Application-Mediated Connections. - Create data roles.Define the data roles that you want to enable in your end-user security contexts. Because you are using IAM-managed users, you must create data roles mapped to the application roles in IAM.
For the complete syntax and options, see Configure Data Roles.CREATE DATA ROLE employee_role MAPPED TO 'AZURE_ROLE=EMPLOYEE'; - Create and grant a generic database role.Create a generic database role and grant it the
CREATE SESSIONprivilege. Then grant this generic role to your data role used for direct logon. See Grant Database Role to Data Role.-- Create a standard database role for connection privileges CREATE ROLE db_role; GRANT CREATE SESSION TO db_role; -- Grant the connection privileges to the data roles GRANT db_role TO employee_role;