7.2 CALLBACK Procedure

This procedure is the landing resource for external login pages. Call this procedure directly from the browser.

Syntax

APEX_AUTHENTICATION.CALLBACK ( 
    p_session_id      IN NUMBER, 
    p_app_id          IN NUMBER,
    p_page_id         IN NUMBER DEFAULT NULL,			
    p_ajax_identifier IN VARCHAR2, 
    p_x01             IN VARCHAR2 DEFAULT NULL, 
    p_x02             IN VARCHAR2 DEFAULT NULL, 
    p_x03             IN VARCHAR2 DEFAULT NULL, 
    p_x04             IN VARCHAR2 DEFAULT NULL, 
    p_x05             IN VARCHAR2 DEFAULT NULL, 
    p_x06             IN VARCHAR2 DEFAULT NULL, 
    p_x07             IN VARCHAR2 DEFAULT NULL, 
    p_x08             IN VARCHAR2 DEFAULT NULL, 
    p_x09             IN VARCHAR2 DEFAULT NULL, 
    p_x10             IN VARCHAR2 DEFAULT NULL ); 

Parameters

Table 7-1 CALLBACK Procedure Parameters

Parameters Description
p_session_id The Oracle APEX session identifier.
p_app_id The database application identifier.
p_page_id (Optional) Page identifier.
p_ajax_identifier The system generated Ajax identifier. See GET_AJAX_IDENTIFIER Function.
p_x01 through p_x10 (Optional) Parameters that the external login passes to the authentication plugin.

Example 1

In this example, a redirect is performed to an external login page and the callback is passed into APEX, which the external login redirects to after successful authentication.

DECLARE 
    l_callback varchar2(4000) := apex_application.get_callback_url; 
BEGIN 
    sys.owa_util.redirect_url( 
        'https://single-signon.example.com/my_custom_sso.login?p_on_success='|| 
        sys.utl_url.escape ( 
            url => l_callback, 
            escape_reserved_chars => true ); 
    apex_application.stop_apex_engine; 
END;

Example 2

In this example, an external login page saves user data in a shared table and performs a call back with a handle to the data. In APEX, the callback activates the authentication plugin's ajax code. It can take the value of x01 and fetch the actual user data from the shared table.

---- create or replace package body my_custom_sso as 
PROCEDURE LOGIN ( 
    p_on_success in varchar2 ) 
    IS 
    l_login_id varchar2(32); 
BEGIN
    l_login_id := rawtohex(sys.dbms_crypto.random(32)); 
    insert into login_data(id, username) values (l_login_id, 'JOE USER'); 
    sys.owa_util.redirect_url ( 
    p_on_success||'&p_x01='||l_login_id ); 
END; 
---- end my_custom_sso;