oracle - 如何在一定次数的无效登录尝试后锁定帐户
问题描述
我的 oracle apex 应用程序中有一个身份验证方案。我还将最终用户的用户名和密码存储在数据库中。因此,当用户登录时,他们使用他们制作的用户名和密码(我不为用户创建任何帐户)。我想设置它,以便帐户在进行太多无效登录尝试时被锁定(我应该能够解锁)。
形成我研究的唯一我能找到的东西与管理快递有关,但我仍然不知道这有什么帮助,我也无法在我的 oracle 应用程序中找到这个页面。我也不想要任何复杂的东西,也许是在顶点而不是代码上的东西(因为我不太擅长理解函数/布尔值等)。
解决方案
对于 Application Express 帐户身份验证,它适用于使用 Application Express 最终用户帐户管理界面创建的最终用户帐户。
登录到Internal
工作区并转到Manage Instance > Security > Authentication Control
,转到Development Environment Settings
并设置Require User Account Expiration and Locking
为是。
对于自定义身份验证,我希望您可以在日志表中记录无效用户尝试,并根据连续无效登录尝试的计数来限制/锁定用户。
下面的示例代码基于提供的链接
创建一个 USER_LOG 表来记录无效尝试,如下所示
create table USER_LOG (username varchar2(4000),
login_failed_count number, updated_on date);
更改现有table1
并为用户锁定添加一个标志(Y - 是用户锁定,N - 否用户未锁定),如下所示。
Alter table table1 add is_locked varchar2(1) default 'N';
完成上述更改后,您可以尝试使用链接中提供的以下更新过程。
create or replace function Table1Authenticate( p_username varchar2, p_password varchar2 ) return boolean is
i integer;
l_rcnt number;
l_failed_cnt number;
l_max_failed_cnt number :=4;
l_lock_flag varchar2(1);
begin
select count(1) into l_rcnt
from table1 t1
where t1.username = p_username
and t1.password = p_password;
if (l_rcnt > 0) then
select is_locked into l_lock_flag from table1 where username = p_username
and password = p_password;
if (l_lock_flag ='N') then
delete from USER_LOG where username=p_username;
return true;
elsif (l_lock_flag ='Y') then
apex_util.set_custom_auth_status (p_status => 'Account Locked, Exceeded Maximum Attempts..!');
return false;
end if;
else
merge into USER_LOG u
using dual l
on (u.username=p_username)
when matched then
update set login_failed_count=login_failed_count+1,updated_on=sysdate
when not matched then
insert (username,login_failed_count,updated_on) values
(p_username,1,sysdate);
select login_failed_count into l_failed_cnt
from user_log where username =p_username;
if (l_failed_cnt > l_max_failed_cnt) then
update table1 set is_locked='Y' where username=p_username;
end if;
return( false );
end if;
exception when others then
return( false );
end;
要解锁用户,请将is_locked
in更新table1
为。使用前请多场景验证。希望这对您有所帮助。Y
N
推荐阅读
- python - 如何绘制数据,带有 suplots 的预测栏?
- javascript - 为 Vuetify 数据表行添加自定义编号
- ubuntu - 无法解析 kubernetes.default 或服务
- airflow - Airflow 中 XCOM 的最大内存大小
- scala - 从 sbt 插件记录
- r - 将 ggplot2 绘图粘贴到 Word 时可以删除空格吗?
- git - 如何绕过:远程:GitLab:作者
是不是团队成员? - python - 如何在 Plotly 地理图中使用箭头?
- c++ - 构造函数字符串参数未设置窗口标题
- c++ - 存在冲突版本的 openssl 时的 gcc 构建行为