18.5 End-User Security Context Issues
Troubleshoot issues with establishing end-user security contexts.
18.5.1 End-User Security Context Not Attached to Session
If the database session does not reflect the end user's identity, the end-user security context may not have been established.
Issue description
{}) instead of the expected end-user
identity (the upn claim for Entra ID tokens, or the
sub claim for OCI IAM
tokens):SELECT ORA_END_USER_CONTEXT.username FROM dual;Probable cause
A valid end-user security context has not been established. The session operates under standard database privileges and bypasses Oracle Deep Data Security (Deep Sec) enforcement.
Resolution procedure
- Review the database and application configuration. See Configure the Database and Application.
- If the issue persists, enable diagnostic tracing and examine the trace output. See Enable Diagnostic Tracing.
18.5.2 Invalid Database-Access Token
If the database rejects a database-access token during security context payload attachment, the token's audience claim may not match the database's identity provider configuration.
Issue description
Invalid database-access token in the end-user security context: Failed to verify claims
Probable cause
The audience claim in the database-access token does not match the corresponding field in the database’s identity provider configuration.
Resolution procedure
- Decode the database-access token (for example,
using a JSON Web Token (JWT) decoder) and inspect the
audience (
aud) claim. - For Entra ID
v1tokens, verify that the token’saudclaim matches theapplication_id_urifield in the database’sIDENTITY_PROVIDER_CONFIG. Forv2tokens, verify that it matches theapp_idfield. - For OCI IAM identity domain tokens:
- Confirm that a credential named
OCI_IAM_DOMAIN_DB_CRED$has been created using theDBMS_CREDENTIAL.CREATE_CREDENTIALprocedure. - Confirm that the
app_idfield inIDENTITY_PROVIDER_OAUTH_CONFIGmatches the token’sresource_app_idclaim. - Confirm that the
domain_urlinIDENTITY_PROVIDER_OAUTH_CONFIGmatches the token’stenant_issclaim.
- Confirm that a credential named
- Correct any mismatched configuration values in the
database’s identity provider settings, and retry the
setEndUserSecurityContextcall from the application.
18.5.3 Data Role in the Database Is Not Mapped to IAM Application Role
If an IAM application role present in the access token does not activate the expected data role in an end-user security context, the role mapping in the database may be missing or incorrectly formatted.
Issue description
The IAM access token contains a valid application role, but
after the application calls
setEndUserSecurityContext, the
corresponding data role does not appear in the
V$END_USER_DATA_ROLE view. Consequently,
the end user does not have the expected data access privileges.
Probable cause
Note:
The database does not raise an error when a role mapping is missing. Instead, it silently ignores the unmapped role and logs a warning in the database trace file (if tracing is enabled).Resolution procedure
- Decode the access token to identify the exact application roles present in the token's claims.
- Query the
DBA_DATA_ROLESview for the data role that was expected to be enabled, and check itsMAPPED_TOvalue. - Depending on your token provider, ensure the
MAPPED_TOstring matches the correct format.- For Microsoft Entra ID tokens, the
mapping must use one of the following formats:
'AZURE_APP=<access_token_aud_claim>:AZURE_ROLE=<azure_role>'or
Context: The database first checks for the'AZURE_ROLE=<azure_role>'AZURE_APPprefix. If it is not present, it defaults to checkingAZURE_ROLE. The optionalAZURE_APPprefix uses the token's audience claim to distinguish between identically named application roles defined in different application registrations. - For Oracle Cloud Infrastructure
(OCI) IAM tokens, the mapping must use the
following format:
Context: In an OCI IAM identity domain use case, an application identifier prefix is not needed because the group is shared across applications within the same domain, and the database can only configure a single domain.'IAM_OAUTH_GROUP=<oci_iam_group_name>'
- For Microsoft Entra ID tokens, the
mapping must use one of the following formats:
- Alter the data role definition to correct any
missing or mismatched
MAPPED_TOvalues. - Establish a new session (or detach and re-attach the
end-user security context) and query
V$END_USER_DATA_ROLEto verify that the data role is now active.
18.5.4 Data Role Granted to an Application Is Not Enabled
If a data role granted to an application does not take effect after the end-user security context is established, the application identity mapping or the default enablement setting on the role grant may be incorrect.
Issue description
A data role granted to an application does not appear in the
V$END_USER_DATA_ROLE view after the
end-user security context is established. End users connecting
through the application do not inherit the data role's
privileges.
Probable causes
- The application name in the database is mapped to an incorrect IAM client ID.
- The data role granted to the application is not configured to be enabled by default.
Resolution procedure
- Decode the database-access token to locate the
application identity claim. The specific claim depends on
your token type:
- Entra ID
v1tokens: Look for theapp_idclaim. - Entra ID
v2tokens: Look for theazpclaim. - OCI IAM client credentials tokens:
Look for the
client_idclaim.
- Entra ID
- Query the
DBA_APPLICATION_IDENTITIESview to inspect theMAPPED_TOcolumn for the row corresponding to your application. - Validate and correct the mapping format based on
your token provider.
- For Entra ID tokens
(
v1andv2), verify the mapping matches the following format, where<ENTRA_ID_APP_ID>is the value of theapp_idorazpclaim:'AZURE_CLIENT_ID=<ENTRA_ID_APP_ID>' Example: 'AZURE_CLIENT_ID=2edc9c9f-8e1e-4ade-8a4a-cc286ed1b899' - For OCI IAM tokens, verify the
mapping matches the following format, where
<OCI_IAM_CLIENT_ID>is the value of theclient_idclaim:'IAM_OAUTH_CLIENT_ID=<OCI_IAM_CLIENT_ID>' Example: 'IAM_OAUTH_CLIENT_ID=e83a43ac80d94637bb1958b06929ac32'
- For Entra ID tokens
(
- Alter the application identity definition to correct
any misconfigurations in the
MAPPED_TOvalue. - Verify the data role grant configuration. Ensure the
data role granted to the application is enabled by default.
If it is not enabled by default, you must either alter the
role grant to enable it or explicitly pass it in the
EndUserSecurityContextpayload's optional data roles list. - Establish a new session (or detach and re-attach the
end-user security context) and query
V$END_USER_DATA_ROLEto verify the data role is now enabled.
18.5.5 ORA-00406 Error When Querying End-User Context
If querying ORA_END_USER_CONTEXT raises a
COMPATIBLE parameter error, the database instance may be running at a
compatibility level that does not support this feature.
Issue description
SQL> SELECT ORA_END_USER_CONTEXT.username FROM dual;
ERROR at line 1:
ORA-00406: COMPATIBLE parameter needs to be 20.0 or greaterProbable cause
The database instance's COMPATIBLE initialization
parameter is set to a value lower than 20.0.
Resolution procedure
- Check the current value of the
COMPATIBLEinitialization parameter:SHOW PARAMETER compatible; - If the value is below 20.0, update the initialization parameter to 20.0 or higher. Consult the Oracle AI Database Upgrade Guide for the procedure to modify this parameter.