Oracle Apex 自定义身份验证错误 - 'MY_AUTHENTICATION' 不是过程

Oracle Apex Custom Authentication Error - 'MY_AUTHENTICATION' IS NOT A PROCEDURE

请原谅我的天真,但我已经与这个问题进行了几个小时的斗争,但没有任何进展,我不知道自己错过了什么。我对 Oracle 还很陌生,但仍然掌握了很多自定义功能。

我正在尝试编写一个函数(遵循 APEX 界面上的指南)来使用自定义身份验证方案为我的应用程序验证登录凭据。

指南指出:

Specify the name of the function that will verify the user's username and password, after they were entered on a login page. If you enter nothing, you allow any username/password to succeed. The function itself can be defined in the authentication's 'PL/SQL Code' textarea, within a package or as a stored function. This function must return a boolean to the login procedure that calls it. It has 2 input parameters 'p_username' and 'p_password' that can be used to access the values an end user entered on the login page. Examples Enter the following code in the 'PL/SQL Code' textarea

function my_authentication (
    p_username in varchar2,
    p_password in varchar2 )
    return boolean
is
    l_user my_users.user_name%type := upper(p_username);
    l_pwd  my_users.password%type;
    l_id   my_users.id%type;
begin
    select id  , password
      into l_id, l_pwd
      from my_users
     where user_name = l_user;

    return l_pwd = rawtohex(sys.dbms_crypto.hash (
                       sys.utl_raw.cast_to_raw(p_password||l_id||l_user),
                       sys.dbms_crypto.hash_sh512 ));
exception
    when NO_DATA_FOUND then return false;
end;

my_authenticationAuthentication Function

我写的函数并不复杂,因为我目前没有加密 pwd 等来尝试让事情正常工作

function my_authentication (p_username in varchar2,p_password in varchar2 )
    return boolean
is
    valid NUMBER;
    returnvalid BOOLEAN;
begin
    begin
        select 1
        into valid
        from users u
        where u.sys_user.login = lower(p_username) AND u.sys_user.password = p_password;    
    exception
        when NO_DATA_FOUND then valid := 0;
    end;
    returnvalid := valid=1;
    RETURN returnvalid;
end;

澄清用户 table 由 3 个字段组成,存储我要验证的数据的字段是 sys_user(它是一个具有 5 个字段的对象类型:id, fname, lname, login, password).

当我将身份验证函数名称设置为 my_authentication 并尝试登录时,出现以下错误:

ORA-06550: line 1, column 7: PLS-00221: 'MY_AUTHENTICATION' is not a procedure or is undefined 
ORA-06550: line 1, column 7: PL/SQL: Statement ignored

我假设这是我更改的地方

apex_authentication.login(    
    p_username => :P101_USERNAME,
    p_password => :P101_PASSWORD
);

my_authentication(
    p_username => :P101_USERNAME,
    p_password => :P101_PASSWORD
);

在Apex界面的Processing->Process->Login->Source下。我似乎也找不到解决方案的原因是为什么当自定义身份验证方案配置页面明确要求返回布尔值的函数时它请求过程,这是我创建的。我知道它声明登录过程将调用它,但我假设这是启动验证过程的 APEX 接口,它会在其中查找我的方法?

非常感谢任何帮助,我希望我有足够的细节来理解我的问题

非常感谢

您不应该更改页面处理代码,它应该保持为:

apex_authentication.login(    
    p_username => :P101_USERNAME,
    p_password => :P101_PASSWORD
);

这会执行一些逻辑,包括动态运行您在身份验证方案中指定的身份验证功能。