当前位置: 首页 > news >正文

人民日报网站谁做的无线网络优化工程师

人民日报网站谁做的,无线网络优化工程师,惠东东莞网站建设,如何让做网站使用session_exec 、file_fdw以及自定义函数实现该功能。 缺陷:实测发现锁用户后,进去解锁特定用户。只能允许一次登陆,应该再次登陆的时候,触发函数,把之前的日志里的错误登陆的信息也计算到登录次数里了。而且foreig…

使用session_exec 、file_fdw以及自定义函数实现该功能。

缺陷:实测发现锁用户后,进去解锁特定用户。只能允许一次登陆,应该再次登陆的时候,触发函数,把之前的日志里的错误登陆的信息也计算到登录次数里了。而且foreign table不能在数据库里清理。需要删除对应的pg_log,才能使foreign table信息清理掉,来重制该用户的密码错误记录。

https://github.com/okbob/session_exec

unzip session_exec-master.zip
cd session_exec-master/
make pg_config=$PGHOME/bin/pg_config
make pg_config=$PGHOME/bin/pg_config install

更改配置文件

logging_collector = on 
log_destination = 'csvlog' 
session_preload_libraries='session_exec'
session_exec.login_name='login'

     更改完之后需要重启数据库

pg_ctl restart

安装file_fdw扩展

cd contrib/file_fdw/
# 安装命令
make && make install

创建外部表postgres_log

create extension file_fdw;CREATE SERVER pglog FOREIGN DATA WRAPPER file_fdw;CREATE FOREIGN TABLE public.postgres_log(
log_time timestamp(3) with time zone,user_name text,database_name text,process_id integer,connection_from text,session_id text,session_line_num bigint,command_tag text,session_start_time timestamp with time zone,virtual_transaction_id text,transaction_id bigint,error_severity text,sql_state_code text,message text,detail text,hint text,internal_query text,internal_query_pos integer,context text,query text,query_pos integer,location text,application_name text
) SERVER pglog
OPTIONS ( program 'find /home/pg13/data/log/ -type f -name "*.csv" -mtime -1 -exec cat {} \;', format 'csv' );grant SELECT on postgres_log to PUBLIC;

如下设置的是5 5次登录失败就锁定用户

create or replace function public.login() returns void as $$
declare
res record;
failed_login_times int = 5;
failed_login int = 0;
begin
--获取数据库中所有可连接数据库的用户
for res in select rolname from pg_catalog.pg_roles where rolcanlogin= 't' and rolname !='postgres'
loopraise notice 'user: %!',res.rolname;--获取当前用户最近连续登录失败次数select count(*)from (select log_time,user_name,error_severity,message,detail from public.postgres_log where command_tag = 'authentication' and user_name = res.rolname and (detail is null or detail not like 'Role % does not exist.%') order by log_time desc limit failed_login_times) AWHERE A.error_severity='FATAL'into  failed_login ;raise notice 'failed_login_times: %! failed_login: %!',failed_login_times,failed_login;--用户最近密码输入错误次数达到5次或以上if failed_login >= failed_login_times then--锁定用户EXECUTE format('alter user %I nologin',res.rolname);raise notice 'Account % is locked!',res.rolname;end if;
end loop;
end;
$$ language plpgsql strict security definer set search_path to 'public';

用户是否被锁/是否允许登陆,可以查看pg_roles系统视图里的rolcanlogin字段。

验证密码失败:

使用如下语句,可以查询登陆失败的记录。

select log_time,user_name,error_severity,message,detail from public.postgres_log where command_tag = 'authentication'  order by log_time desc limit 10 offset 0;

解锁用户命令如下:

alter user test_user login;

解锁同时需要删除pg_log下csv文件里的对应有改用户登陆失败的日志记录,重制密码登录错误的记录,否则可能会重复计算之前的错误登陆记录。

http://www.khdw.cn/news/54258.html

相关文章:

  • 图片外链生成工具seo培训一对一
  • wordpress前台显示作者角色广州宣布5条优化措施
  • 宁波网站优化服务app推广平台有哪些
  • 个人主页自助建站上海关键词排名推广
  • 网站开发应用免费手机网站建站系统
  • 网站轮播图网站流量统计软件
  • 武汉做个网站多少钱朋友圈广告投放价格表
  • 单词量测试网站开发苏州seo公司
  • 用手机网站做app公司网站建设全包
  • 龙华网站(建设龙华信科)软文营销经典案例优秀软文
  • 做电影网站有什么好处小企业广告投放平台
  • 货架 网站建设 牛商网网络营销课程作业
  • wordpress博客主题自媒体淄博seo怎么选择
  • 做电梯销售从哪些网站获取信息seo关键字排名优化
  • 哪个网站做视频收益高武汉seo网络营销推广
  • 方城网站设计百度代发排名
  • 杰奇小说网站建设seo关键词排名优化评价
  • 石家庄做网站电话免费做网站怎么做网站吗
  • 枣强网址建站电话投放小网站
  • 做网站的最终目的历下区百度seo
  • 如何做视频网站推广员什么软件可以弄排名
  • 备案查询站长之家网站排名推广软件
  • 自己制作手机游戏app百度官方优化指南
  • 佛山市品牌网站建设哪家好武汉电脑培训学校有哪些
  • 企业网站模板下载psd格式百度seo怎么优化
  • 龙岗网站价格今天最新的新闻头条新闻
  • 做网站1天转多钱产品线上推广方案
  • 目前做哪个网站能致富保定seo网络推广
  • 南京做网站的公司电商网站设计
  • 建设银行360网站登录不了制作网页完整步骤