Search code examples
databaseoracle-apexapex

Oracle Apex authorised users access


I am looking to add an Authorization Option to my db project. I have added a 'manage users' page where you have the ability to add/edit/delete users who have access to view special data, however everyone is able to access this page as it stands.

I have created the USERS table with USER_TYPE as a flag for admin rights.

What I am looking to do is figure out how to recognize which user logs in (how to compare :APP_USER and check if it's DB user, if it is, then show the 'Manage Users' button)


Solution

  • Create an authorization type "Admin" with scheme type "Exists SQL Query" and source

    SELECT 1 
      FROM users 
     WHERE user_name = :APP_USER and 
           user_type = 'ADMIN'
    

    (Change the columns to whatever they're called in your implementation)

    Note that "Evaluation Point: Once per session" is probably fine but it might be annoying when developing because the changes are not re-evaluated. So when developing put it to "Once per page view"