---
title: "Discussion on \"Custom Authorization using built-in APEX Access Control - A How To\" | Hashnode"
description: "Discussion on \"Custom Authorization using built-in APEX Access Control - A How To\". This article was first published on blogs.oracle.com in September of 2019. Not long after it was published I was made aware of a couple of security flaws. However by that time the underlying blogging platform Oracle was using had been migrated and I ..."
url: "https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Custom Authorization using built-in APEX Access Control - A How To](https://douggault.com/custom-authorization-using-built-in-apex-access-control-a-how-to?utm_source=hashnode&utm_medium=feed)

This article was first published on blogs.oracle.com in September of 2019. Not long after it was published I was made aware of a couple of security flaws. However by that time the underlying blogging platform Oracle was using had been migrated and I ...

Nov 29, 2022 · 19 min read · douggault.com  
Updated Feb 4, 2023  
Read the article

-   [#orclapex](https://hashnode.com/tag/orclapex)
-   [#authentication](https://hashnode.com/tag/authentication)
-   [#authorization](https://hashnode.com/tag/authorization)

## Written by

[Doug Gault](https://hashnode.com/@DougAGault)

@DougAGault · Fort Worth, Texas

  
[View profile](https://hashnode.com/@DougAGault)

Watch Fanatic, Geek, Foodie, Dry Drinker, Traveler, Classic Car Nerd, Techie, Developer, Author, APEX Aficionado.

I'm a developer that has spent most of his professional career in the Oracle world with extremely brief detours into JAVA, JavaScript, C#, shell scripting and Python. Current areas of expertise are Oracle APEX, Data Model Design, PL/SQL, Oracle REST with a little performance tuning thrown in.

## Responses 3

Markdown supported · ⌘↵ to post

[Shyam N](https://hashnode.com/@DevShyam)

[Jun 20, 2023](https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a/comment/64913073aa3e031681681f72)

Very useful information shared and explained in easy way. I am trying to develop multi tenant application and read most of the article present in internet. I do no want to write the code to achieve the same. I want to use Oracle APEX stand role, menu , user to achieve this for data I have tenant\_id but for role, user, List i DO not have. Kindly suggest or publish any article for the same based on Oracle APEX 23.1.

[Doug Gault](https://hashnode.com/@DougAGault)

[Jun 20, 2023](https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a/comment/64913073aa3e031681681f72#reply-6491a5a4c167b41645fd1ee1)

Shyam,

I don't have articles about Authorization and multi-tenant.

However a simple google search on "Multi-tenant Authorization with Oracle APEX" turns up a few hits that might be of interest. Specifically there is a blog post by Jeff Kemp that might help.

Good luck.

[Lionel Lai](https://hashnode.com/@lionel2254)

[Feb 23, 2023](https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a/comment/63f6c0f0437bc8d091bd16eb)

Hi, Finally I found solution to my problem here. Are the demo app still available for access? Password for admin is incorrect. Thanks

[Feb 23, 2023](https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a/comment/63f6c0f0437bc8d091bd16eb#reply-63f7787f207712e9dab0470e)

Hi Lionel,

I fixed the broken password on the app. Should be working now.

As for downloading the app, there is a link in the last paragraph that leads to a place on DropBox where you can download the app script. You don't need to have a DropBox account. If you still have problems downloading, let me know.

[Lionel Lai](https://hashnode.com/@lionel2254)

[Feb 23, 2023](https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a/comment/63f6c0f0437bc8d091bd16eb#reply-63f7f522207712e9dab05622)

Hi [Doug Gault](https://hashnode.com/@DougAGault) , I can open the app now and can donwnload app script without problem. Thank you.

[Doug Gault](https://hashnode.com/@DougAGault)

[Nov 30, 2022](https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a/comment/6387711d7f926e4996319519)

Remember how above I stated that you really shouldn't be using the Authentication Scheme "as is" because it really isn't that secure?

I am admittedly not a security expert, so normally I would engage someone who is to make sure anything that was going into production was air tight. Back at Oracle there was a whole process we had to go through that reviewed all security aspects of our applications before they were put live. And there were accepted patterns for things like Authentication.

The code in this blog post would **_not pass muster!_** And with the help of Christian Neumueller of the APEX Team, here's why.

> **The HASH\_PASSWORD function is vulnerable to a "rainbow table attack."** We hear all the time in the news about stolen user/password tables. If somone were able to get ahold of your USERS table, an attacker can build a table that contains username/likely-password/pre-computed-hash and compare the computed values with the stolen hashes. Once they have a match, they know the actual password. The solution is to salt the hashes and repeatedly apply the hash, e.g. using the PBKDF2 algorithm.

Agreed. although there are many things you should be doing to make sure no one is able to get ahold of the underlying USERS table, if they were to get the data, this is a very valid point.

> **The AUTHENTICATE\_USER function is susceptible to a "Timing attack".** The HASH\_PASSWORD function does not get called when the user does not exist. Therefore, the code path for an invalid username is faster than the one for a valid user. Attackers can use statistical methods to determine whether they guessed a correct username. Your HASH\_PASSWORD is fast, because it is simplistic and therefore inadequate - this algorithm MUST be expensive to make it harder for password crackers. In the real world this is a problem.

Again, agreed. The authentication function does the bare minimum in my example and that's on purpose. I wanted something simple that didn't get in the way of the real meat of this article, which was the Authorization Schemes.

BUT what this does prove is what I stated above ... That the authentication scheme is **very basic\*\*** and is really here for **demo purposes only\*\***. It's not really meant for use in a production system. You'd likely want something far more robust such as a Single Sign On, Social Sign on or SAML based Authentication scheme.

Thank you Christian for your excellent explanations.

[Ibrahim Wael](https://hashnode.com/@IBRA421)

[Feb 4, 2023](https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a/comment/6387711d7f926e4996319519#reply-63de684416b1848f6752a348)

Hi , I have a problem when i create a hash function and gave me error ( Compilation failed,line 6 (16:13:57) PLS-00201: identifier 'P\_USERNAME' must be declaredCompilation failed,line 0 (16:13:57) PL/SQL: Compilation unit analysis terminated ) and i don\`t know why .

[Doug Gault](https://hashnode.com/@DougAGault)

[Feb 4, 2023](https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a/comment/6387711d7f926e4996319519#reply-63deab25870f1899b96ee7ac)

[Ibrahim Wael](https://hashnode.com/@IBRA421)

Thanks for the comment and pointing out the error. Turns out that there was a typo in the function body.

Where I referenced `p_username` it should have been `p_user_name`.

I've fixed it in the main post, but changing that should make things compile for you.

[Ibrahim Wael](https://hashnode.com/@IBRA421)

[Feb 5, 2023](https://hashnode.com/posts/custom-authorization-using-built-in-apex-access-control-a-how-to/638638af3be8a7342291186a/comment/6387711d7f926e4996319519#reply-63dfc20abf2ce4a649f5da42)

[Doug Gault](https://hashnode.com/@DougAGault) Thank you very much for your concern, the issue has already been resolved and thank you for a great blog.
