Introduction
Deleting Access Control roles in Oracle APEX is an important task when roles become obsolete or need to be removed to streamline application security. Access Control roles, managed under Shared Components, define user permissions for role-based access control, and removing unused or outdated roles helps maintain a clean and secure application. However, deleting roles requires careful consideration to avoid disrupting existing authorization schemes or user access. This blog post will guide you through the process of deleting Access Control roles in Oracle APEX, provide detailed steps, share best practices, and include a link to the official Oracle APEX documentation for further guidance.
Steps to Delete Access Control Roles in Oracle APEX
Understanding Access Control Roles
Access Control roles in Oracle APEX, defined in Shared Components > Application Access Control, represent permission levels (e.g., Administrator, Editor, Viewer) used in authorization schemes to control access to application components. Deleting a role removes it from the Application Access Control list and requires updating any associated user mappings and authorization schemes to prevent access issues.Checking Role Usage
Before deleting a role, verify where it is used to avoid unintended consequences:- Navigate to Shared Components > Application Access Control in your Oracle APEX application.
- Review the list of roles (e.g., "ADMINISTRATOR," "EDITOR") and note the role targeted for deletion.
- Check for dependencies by examining associated authorization schemes:
- Go to Shared Components > Authorization Schemes.
- Look for schemes referencing the role in their logic, such as:
SELECT 1 FROM apex_access_control WHERE username = :APP_USER AND access_level = 'ADMINISTRATOR';
- Use the Used In column in the Authorization Schemes list to identify pages, regions, or buttons linked to these schemes.
- Query the
APEX_ACCESS_CONTROL
table to identify users assigned to the role:SELECT username FROM apex_access_control WHERE access_level = 'ADMINISTRATOR';
Removing User-Role Mappings
Before deleting the role, update or remove user assignments:- Access the
APEX_ACCESS_CONTROL
table (or equivalent custom table) used for role mappings. - Delete or reassign users mapped to the role. Example:
Or reassign to a different role:DELETE FROM apex_access_control WHERE access_level = 'ADMINISTRATOR';
UPDATE apex_access_control SET access_level = 'EDITOR' WHERE access_level = 'ADMINISTRATOR';
- If using a form to manage roles, update assignments via the interface and ensure the form is secured with an authorization scheme.
- Access the
Updating or Removing Authorization Schemes
Modify or delete authorization schemes that reference the role:- Go to Shared Components > Authorization Schemes.
- For each scheme using the role, either:
- Edit the scheme to reference a different role (e.g., change
access_level = 'ADMINISTRATOR'
toaccess_level = 'MANAGER'
). - Delete the scheme if it’s no longer needed, but first ensure it’s not applied to any components (check Used In).
- Edit the scheme to reference a different role (e.g., change
- If deleting the scheme, update affected components:
- In Page Designer, go to the Security tab of pages, regions, or buttons and set the Authorization Scheme to "No Authorization Required" or a different scheme.
Deleting the Access Control Role
Once dependencies are resolved:- Navigate to Shared Components > Application Access Control.
- Locate the role (e.g., "ADMINISTRATOR") in the list.
- Click the role name and select Delete, or use the checkbox next to the role and click Delete Selected.
- Confirm the deletion. The role is now removed from the Application Access Control list.
Resetting Authorization State
After deleting the role, reset the authorization state to ensure updated access controls take effect:- Call
APEX_AUTHORIZATION.RESET_CACHE
in a PL/SQL process or dynamic action:BEGIN APEX_AUTHORIZATION.RESET_CACHE; END;
- Alternatively, if significant changes are made, invalidate the session:
BEGIN APEX_SESSION.DELETE_SESSION(p_session_id => :APP_SESSION); APEX_UTIL.REDIRECT_URL(p_url => 'f?p=' || :APP_ID || ':LOGIN:' || :APP_SESSION); END;
- Call
Testing the Deletion
- Test by logging in as users previously assigned the deleted role to confirm they no longer have access to restricted components.
- Verify that other roles and schemes function as expected.
- Use APEX Debug Mode or query the APEX_ACTIVITY_LOG view to troubleshoot any issues with access control.
- Ensure error messages (e.g., "Access Denied") display clearly for unauthorized users.
You can remove an access control role from your application by following these steps.
Steps to Delete a Role
Navigate to the Shared Components page:
Go to the Workspace home page.
Click the App Builder icon.
Select the application where the role is defined.
On the Application home page, click Shared Components.
Access the Application Access Control page:
Under Security, select Application Access Control.
Select the role to delete:
Locate the role you want to remove.
Click on the role name to open the Role dialog.
Delete the role:
Click Delete to remove the role permanently.
Once deleted, the role will no longer be available for authorization checks or assignments within the application.
Best Practices for Deleting Access Control Roles in Oracle APEX
- Verify Dependencies: Always check where a role is used (in authorization schemes and components) before deletion to avoid breaking access controls.
- Backup Configurations: Export the Application Access Control configuration via Shared Components > Export before deleting roles to allow recovery if needed.
- Reassign Users: Update user-role mappings to appropriate roles before deletion to maintain access for affected users.
- Secure Role Management: Restrict role deletion to authorized users (e.g., administrators) using authorization schemes.
- Test in Development: Perform deletions in a development environment first to ensure no unintended consequences.
- Document Changes: Maintain records of deleted roles, affected schemes, and user reassignments for future reference.
- Monitor Access: Enable Application Activity Logging in Shared Components > Security Attributes to track access attempts and audit changes post-deletion.
- Reset Cache Promptly: Use
APEX_AUTHORIZATION.RESET_CACHE
after role deletion to ensure immediate application of changes.
Oracle APEX Documentation
For detailed guidance on managing Application Access Control roles in Oracle APEX, refer to the official documentation:
Oracle APEX Application Access Control Documentation
Conclusion
Deleting Access Control roles in Oracle APEX is a straightforward process when done carefully, ensuring that obsolete roles are removed without disrupting application security. By verifying dependencies, updating user mappings, and resetting authorization states, you can maintain a clean and secure access control framework. Following best practices and consulting the Oracle APEX documentation will help you manage roles effectively and keep your application secure and efficient.