Oracle Apex Custom Authentication scheme

Default authentication of APEX:

When Create new APEX application you can logon your application with username and password created by APEX_ADMIN

In this post i show you how you can logon your application using your custom authentication function.

Custom Authentication function for APEX:

STEP1:

Create your function to check username and password depends on your local table in our case 
COM_USERS as the following:



FUNCTION authenticate_user(p_username IN VARCHAR2
                      ,p_password IN VARCHAR2)
 RETURN BOOLEAN
 IS
 BEGIN
   RETURN TRUE;
 END authenticate_user;


FUNCTION authenticate_user(p_username IN VARCHAR2
                                        ,p_password IN VARCHAR2) RETURN BOOLEAN IS
   isValid       NUMBER;
   l_return BOOLEAN;
 BEGIN
   BEGIN
     SELECT 1
       INTO isValid
       FROM com_users
      WHERE 1 = 1
        AND upper(user_name) = upper(p_username)
        AND upper(user_password) = upper(p_password );
   EXCEPTION
     WHEN no_data_found
          OR too_many_rows THEN
       isValid:= 0;
     WHEN OTHERS THEN
       isValid:= 0;
   END;
   l_return := isValid = 1;
   RETURN l_return ;
 END;
STEP 2:

Now all you have to do is tell your application that it needs to reference the custom authentication.
To create custom authentication scheme you go to the Shared components –> Authentication Schemes and create your own authentication scheme and its by default set as current authentication scheme as the following: 





Hope this helps. 
Thank you,

No comments

2015@Bahaa Barghouti. Powered by Blogger.