Managing Roles

Manage data roles to control access, assign roles to application users, and maintain custom roles for Oracle Backend with Supabase APIs.

Before you begin, sign in to the Console as the project owner and select your project. Use an application user registered with that project to test membership changes.

The examples use BAAS_USER as the project-owner schema. Replace that prefix with your schema name. The screenshots use the TESTUSER schema in a development project.

Understanding Data Roles

Data roles are Oracle DeepSec roles that provide fine-grained access to database tables and views. You can grant them to application identities, application users, and other data roles.

A role assignment identifies who can receive access. Data grants define the permitted database and storage operations. Creating a custom role or assigning it to a user doesn’t itself authorize database or storage operations.

The authentication type determines where you manage the groups that map to data roles:

Default Data Roles

The service creates these data roles when you create a project:

Unauthenticated Access

Grant access for unauthenticated requests to <SCHEMA>$NOAUTH_ROLE.

Authenticated Access

Grant access for authenticated application users to <SCHEMA>$AUTHENTICATED_ROLE.

Schema Scope and Role Names

Data roles are scoped across the database. Prefix each project data role with <SCHEMA>$ to distinguish it from roles used by other projects.

For external IDCS authentication, you can create or delete only groups whose names use the SCHEMA$ prefix. You can assign users to or remove users from only those groups.

Viewing Data Roles

To view the project’s data roles, follow these steps:

  1. In the Console, select Database.
  2. On the Table Editor tab, select Roles.
  3. Review each role’s Members, Default for new user, and Grants values. Use Search roles to find a role.

Description of the illustration data-role-list.png

To inspect a user’s custom role assignments, open Authentication > Users in the Console and review Assigned roles. Default authenticated and unauthenticated roles apply according to request authentication. They aren’t custom user assignments.

Creating a Custom Data Role

To create a custom data role, follow these steps:

  1. In the Console, select Database > Table Editor > Roles.
  2. Select Create role.
  3. In Role name, enter a schema-prefixed name, such as BAAS_USER$AUTHOR_ROLE.
  4. Enter a Description that identifies the role’s purpose.
  5. Leave Assign all new users by default cleared unless every newly registered user requires this role.
  6. Select Create role. Confirm that the role appears in the list with the intended default-assignment setting.

For IDCS-based authentication, the Group Management API creates the corresponding group in the Oracle IAM identity domain. Creating the group doesn’t assign it to existing application users.

If you use the administrator examples in Managing Grants, create BAAS_USER$ADMIN_ROLE separately. Assign it only to the application users who need that access.

Assigning Data Roles to Application Users

To assign a custom data role to a registered application user, follow these steps:

  1. In the Console, open Authentication > Users.
  2. Find the user. In the user’s action menu, select Edit User Role.
  3. In Roles, select the custom roles that the user needs. Keep the assignments that the user still needs.
  4. Select Save. Confirm the assignments in Assigned roles.
  5. Sign in again through your application and test the access granted to those roles.

Description of the illustration assign-user-data-role.png

For IDCS-based authentication, the Group Management API assigns the user to the corresponding group. For external IDCS, the user must also belong to the project’s fusa-<projectID>-usergroup group.

Assigning Data Roles to New Users by Default

To assign a custom role automatically during registration, follow these steps:

  1. In the Console, select Database > Table Editor > Roles.
  2. In the role’s Actions menu, select Edit role.
  3. Select Assign all new users by default.
  4. To save the setting, select Create role.
  5. Register a test user through your application. In the Console, open Authentication > Users and confirm the role in Assigned roles.

This setting applies to newly registered users. It doesn’t assign the role to existing users.

Clearing the setting stops default assignment to future users. It doesn’t remove existing memberships.

For IDCS-based authentication, the group’s assign_by_default property controls default assignment. The service adds default groups to enrolled social-provider profiles and the self-registration profile. It also adds data-role groups to newly enrolled identity-provider profiles.

Data Roles and Authentication Tokens

For IDCS authentication, access tokens include the groups assigned to the user in the group claim. The identity-domain claim configuration uses user.$.groups.display to obtain the assigned group names.

For external IDCS authentication, the service uses the end-user access token directly for service requests. Oracle DeepSec maps the user to data roles and grants.

After changing role assignments, sign in again before testing access so that the application uses a newly issued token. Verify access with application requests. The Console’s schema-owner data view doesn’t test application-user authorization.

Updating Custom Data Roles

To update a custom role, follow these steps:

  1. In the Console, select Database > Table Editor > Roles.
  2. In the role’s Actions menu, select Edit role.
  3. Update Description or Assign all new users by default. The role name is read-only.
  4. To save the changes, select Create role.
  5. Verify the role’s settings in the list.

Description of the illustration edit-data-role.png

For IDCS-based authentication, these changes use the Group Management API and update the custom group’s assign_by_default property.

Removing Data Role Assignments

To change a user’s custom roles in the Console, open Authentication > Users. In the user’s action menu, select Edit User Role. Clear roles that are no longer needed, retain the required roles, and select Save.

The Console’s role editor requires at least one selected role before it enables Save. To remove the user’s final custom role with the fusabase command-line interface (CLI), follow these steps:

  1. Configure and authenticate the CLI for the target project as described in Installing and Configuring Oracle Backend with Supabase APIs.
  2. Save the following content in remove-role.json:

    {
      "username": "author@example.com",
      "groups": ["BAAS_USER$AUTHOR_ROLE"],
      "assign": false
    }

    Replace author@example.com with the application user’s name and BAAS_USER$AUTHOR_ROLE with the assigned role name.

  3. Remove the role assignment:

    fusabase roles unassign --path=remove-role.json
  4. In the Console, open Authentication > Users and verify the user’s Assigned roles.
  5. Sign in again through the application and verify that the removed role no longer authorizes access.

Removing a custom assignment doesn’t remove the default authenticated role. Other active roles and grants can still authorize access.

Dropping a Custom Data Role

Before dropping a custom role, review its members and grants. Update any application access policies that still depend on it.

To drop a custom role, follow these steps:

  1. In the Console, select Database > Table Editor > Roles.
  2. Find the custom role and review its Members and Grants values.
  3. In its Actions menu, select Delete Role.
  4. Review the confirmation, including any grant references, and select Delete.
  5. Confirm that the role no longer appears in the list.
  6. Test the affected application workflows with a newly issued user token.

For IDCS-based authentication, deletion removes the corresponding custom group from the Oracle IAM identity domain. The group name must use the SCHEMA$ prefix.