Adding Security to your Database Application Using Oracle Application Express 5.1


Options



Before You Begin

Purpose

This tutorial shows you how to add security to your application using Oracle Application Express.

Time to Complete

Approximately 40 minutes.

Background

In this tutorial, you first create Application Express users. Then you create an Access Control page in the application and restrict only these users to be able to access certain components in the application.

What Do You Need?

  • Installed Sample Database Application Packaged App

Creating Users

This section of the tutorial is applicable only for applications that use Oracle Application Express Authentication.

If your application is configured to use Oracle Application Express Authentication, you may use the functions already available in Oracle Application Express to create new users. Application Express allows you to create new users in bulk.

In this section, you create new users and in the next section you restrict access to certain areas of the application to certain users.

  1. In the Application Express login page, enter the following login credentials and click Sign In:

    • Workspace: obe

    • Username: obe

    • Password: oracle

    Login page
    Description of this image
  2. From the Oracle Application Express home page, click the down arrow next to Administration, and select Manage Users and Groups.

    Administration menu
    Description of this image
  3. Click Create User >.

  4. Enter the following information:

    Note: Make sure that there are no trailing spaces in the username and password.

    • Username: Brad.Knight

    • Email Address: brad.knight@oracle.com

    • Default Schema: <your_schema_name>

    • User is a workspace administrator: No

    • User is a developer: No

    • Password: <choose_a_password>

    • Confirm Password: <repeat_your_password>

    Note that while creating users, you have a choice to provide access to Team Development Module. By default, developers get access to Application Builder, SQL Workshop, Websheet Development, and Team Development Module.

    Note: In this OBE, you accept the default Yes for Require Change of Password on First Use. Therefore, when you log in as this user later, you will be redirected to a screen where you specify a new password. You can then re-login using the new password.

    Click Create and Create Another.

    Create User page
    Description of this image
  5. Enter the following information and click Create and Create Another.

    • Username: Susie.Parker

    • Email Address: susie.parker@oracle.com

    • Default Schema: <your_schema_name>

    • User is a workspace administrator: No

    • User is a developer: No

    • Password: <choose_a_password>

    • Confirm Password: <repeat_your_password>

    Note: In this OBE, you accept the default Yes for Require Change of Password on First Use. Therefore, when you log in as this user later, you will be redirected to a screen where you specify a new password. You can then re-login using the new password.

  6. Enter the following information and click Create User.

    • Username: John.Bell

    • Email Address: john.bell@oracle.com

    • Default Schema: <your_schema_name>

    • User is a workspace administrator: No

    • User is a developer: No

    • Password: <choose_a_password>

    • Confirm Password: <repeat_your_password>

    Note: In this OBE, you accept the default Yes for Require Change of Password on First Use. Therefore, when you log in as this user later, you will be redirected to a screen where you specify a new password. You can then re-login using the new password.

  7. Notice that three new users are created.

    Users page displaying three new users
    Description of this image
  8. You now set up administrator access to the application. Click the App Builder tab.

Restricting Access

Now that you have users defined, you can restrict access to certain portions of the application. In this section, you allow only certain users to edit tasks.

Add an Access Control Page

You create an Access Control page to secure the application so that only privileged users can perform certain operations. In this page, you define which user can access which part of the application.

  1. In the App Builder home page, click Sample Database Application.

    App Builder page - Sample Database Application
    Description of this image
  2. Click Create Page >.

  3. Select Access Control as page type.

    Create a Page modal window
    Description of this image
  4. Accept the default values and click Next >.

    Create Access Control wizard - Step 1
    Description of this image
  5. For Navigation Preference, accept the default value of Do not associate this page with a navigation menu entry and click Next >.

  6. In the Confirmation step, click Create.

    Create Access Control - Confirmation page
    Description of this image
  7. The page loads in Page Designer view. Click the Save and Run Page button.

    Save and Run page button
    Description of this image
  8. Enter your login credentials and click Sign In.

    Sample Database Application login page
    Description of this image
  9. You see the Access Control Administration page that you added to the application. The page is divided into two regions, and the default setting for Application Mode is Full access to all, access control list not used. In this case, you want to restrict certain users from certain parts of the application.

    Select "Restricted access. Only users defined in the access control list are allowed." and click Set Application Mode.

    Access Control Administration page - Application Administration region
    Description of this image
  10. The Application mode has been set. In the next section, you identify your privileged users. Click Add User.

    Access Control List
    Description of this image

Identify Privileged Users

Earlier, you created 3 users - Brad.Knight, John.Bell, and Susie.Parker. In this section, you identify Brad.Knight to be allowed to edit information in the application, but he cannot change any user's access. John.Bell can only view the information in the application, but cannot make any changes. And finally, Susie.Parker is the administrator of the application so she can change anything in addition to changing the user privileges.

  1. Enter john.bell for Username and select View for Privilege. Then, click Add User again.

  2. Enter brad.knight for Username and select Edit for Privilege. Then, click Add User.

  3. Enter susie.parker for Username and select Administrator for Privilege. Then, click Apply Changes.

    Access Control List with three users
    Description of this image
  4. Next, you define which areas of the application are restricted. Click the Application<n> link from the developer tool bar.

    Developer Toolbar
    Description of this image

Apply Authorization Schemes to Application Components

With your authorization scheme created, users with View privilege can review the Orders but cannot change or place orders. Users with Edit privilege can make changes to the Order Information and place new orders, but cannot make changes to the access control list. Users with Administrator privilege, can make any change and addition, including to the access control list.

  1. Click Edit Application Properties.

  2. Click the Security tab.

  3. Under Authorization, change the Authorization Scheme to access control - view and click Apply Changes.

    Security properties of Sample Database Application
    Description of this image
  4. Now that you have given access to the application for view privileged users, you can restrict users to Orders information. Click Page 4 - Orders.

  5. In the Page Rendering section, locate and expand the Orders report Columns node.

    Expanded Orders and Columns node in the Orders page
    Description of this image
  6. Click ORDER_NUMBER.

  7. In the Column section, select access control - edit for the Authorization Scheme and click Save.

    ORDER_NUMBER security attribute
    Description of this image
  8. The Place Order button should only appear when the user has Edit or Administrator privilege. To enable this, you need to set the authorization scheme for the Place Order button.

    In the Page Rendering section, under Region Buttons node, click ENTER_NEW_ORDER.

    Region Buttons of Orders page
    Description of this image
  9. In the Button section, select the access control - edit for Authorization Scheme and click Save.

    ENTER_NEW_ORDER button security attribute
    Description of this image
  10. A user, in spite of not having edit privilege for editing or placing orders (on page 4), may still be able to access the restricted pages 11,12, 14, and 8 (Place Order wizard) by entering the direct URL in the browser.

    To prevent this from happening, you need to restrict pages 11, 12, 14, and 8 to only edit users. Select Page 11 from Page Finder.

    Page Finder modal window
    Description of this image

    Note: In the Sample Database Application, pages 11, 12, 14, and 8 open in a modal window due to which a user will not be able to open the page directly by providing the direct URL to the page. A user can only open pages that open in Normal mode by using the direct URL.

  11. In the Page section under Security, select access control - edit for Authorization Scheme and click Save.

    You may change the page mode (under Appearance) in the Page section to Normal to test that the page is restricted by direct URL for users that are not a part of the access control - edit authorization scheme.

  12. Repeat step 10 and 11 for pages 12, 14, and 8.

  13. Since users with the administrator privilege are only allowed to make changes to the access control list, you need to set the authorization scheme for the page. From the Page Finder, open the Access Control Administration page.

    Page Finder modal window
    Description of this image
  14. In the Page section under Security, select access control - administrator for Authorization Scheme and click Save.

  15. From the Page Finder, open Page 101 Login Page. Run the page by clicking the Save and Run Page button.

  16. If you're already logged in, click the user icon and Sign Out. Enter brad.knight's username and password, and click Sign In.

    Sample Database Application login page
    Description of this image

    Note: If you're signing in as brad for the first time, you will receive a prompt to change your password. Enter you current password, your new password, and click Apply Changes. Then, login as brad.knight using your new password.

  17. Use the left navigation menu and navigate to the Orders page.

  18. Click the Order # of any record to edit the information.

    Orders page with Order # column and Place Order button enabled
    Description of this image

    Notice that Brad can edit the Orders information and can see the Place Order button. Close the Order Details modal window, click the user icon, and Sign Out.

  19. Login as john.bell and navigate to the Orders page.

    Note: If you're signing in as john for the first time, you will receive a prompt to change your password. Enter you current password, your new password, and click Apply Changes. Then, login as john.bell using your new password.

  20. John has only view privileges and therefore cannot edit the Orders information. Also, he does not see the Place Order button.

    Orders page with order# and Place Order button disabled
    Description of this image
  21. Change the page number in your URL to try and access Page 21 Access Control Administration (page number may be different for you).

    Example URL .../f?p=101:4:1998477483740:::::
    Change to .../f?p=101:21:1998477483740:::::

    Press the ENTER key on your keyboard. Notice that you receive a message denying you access to the page because you restricted Page 21 to administrator privilege users only. Click on the Application<n> link in the Developer tool bar.

    No privilege for attempted action warning
    Description of this image
  22. From the Page Finder, open Page 101 Login Page. Run the page by clicking the Save and Run Page button.

  23. Login as susie.parker and navigate to the Orders page.

    Note: If you're signing in as susie for the first time, you will receive a prompt to change your password. Enter you current password, your new password, and click Apply Changes. Then, login as susie.parker using your new password.

  24. Click the Order # to edit the information.

    Orders page with order# and Place Order button enabled
    Description of this image

    Notice that Susie can edit the Orders and can see the Place Order button.

  25. Change the page number in your URL to try and access Page 21 Access Control Administration (page number may be different for you).

    Example URL .../f?p=101:4:1998477483740:::::
    Change to .../f?p=101:21:1998477483740:::::

    Press the ENTER key on your keyboard. Notice that susie has access to the Administration page.

    Access Control Administration page
    Description of this image

Want to Learn More?