Oracle Apex - Custom Authentication

Card Puncher Data Processing

Implementation

Authentication scheme

function my_authentication (
    p_username in varchar2,
    p_password in varchar2 )
    return boolean
is
    l_pwd    auth.pwd%type;
begin
    select pwd as password
      into l_pwd
      from auth
     where user = p_username;

    return l_pwd = p_password;
    
exception
    when NO_DATA_FOUND then return false;
end;

Automatic Login

f?p=&APP_ALIAS.:LOGIN:::::PX_USER,PX_PWD:nico,welcome1

You can also add the REQUEST parameter of the Apex URL to start a process in the Page processing section.

Page

Without the REQUEST parameter of the Apex URL, you must add this code in the “Before Header” section PL/SQL Process in page rendering

DECLARE 
   l_user VARCHAR2(1000);
   l_ww VARCHAR2(1000);
BEGIN
    
   IF (:PX_USER is not null and :PX_PWD is not null) THEN

   APEX_DEBUG_MESSAGE.LOG_MESSAGE ('Automatic Login: Try to login' || :PX_USER );
     
   l_user := :PX_USER;
   l_ww := :PX_PWD;

   -- Unset the condition variable to not come in a loop if the authentication failed
   :PX_USER := null;
   :PX_PWD := null;


   APEX_CUSTOM_AUTH.LOGIN (
        p_uname       => l_user,
        p_password    => l_ww,
        p_session_id  => V('APP_SESSION'),
        p_app_page    => :APP_ID||':2'); -- Redirect to page 2

       
   END IF;

END;

With the Oracle Apex - Public Navigation (Page and user), even if you are not logged in you get a session id

Support

The page is not redirecting properly

To have proper redirection, the login function must be applied:







Share this page:
Follow us:
Task Runner