[精讚] [會員登入]
666

新增IDP程式使用google防機器人的驗證功能

身份認證程式新增google防機器人v2

分享此文連結 //n.sfs.tw/12733

分享連結 新增IDP程式使用google防機器人的驗證功能@外行中的外行
(文章歡迎轉載,務必尊重版權註明連結來源)
2019-05-23 11:19:59 最後編修
2018-09-20 11:56:41 By jung
 

一、申請呼叫google recaptcha api

https://www.google.com/recaptcha/intro/v3beta.html

google帳號登入後

選擇使用reCAPTCHA V2

 

將產生的key & secrets記錄下來

 

二、修改程式

先切到縣市IDP程式分支,右鍵選擇Git->Branch/Tag->Merge Revision

在Revision: 按下"Select"再選擇Remote要merge的分支

下方選擇"Always create commit這樣會產生一次commit紀錄方便理解

 

合併完成後,在LoginPage.java拿掉第74行註解

98行的註解拿掉

 

修改resource package下面的recaptcha.properties內容

將site.key & secret.key改成在google api申請到的值

以上

 

 

三、將mongo中記錄redirect uri的欄位從字串改為可儲存字串陣列值

進入mongo的xxstore資料庫

1. create snapshot & change field type form string to array

db.cncspstore.find().snapshot().forEach(function(e){db.cncspstore.update({_id:e._id},{$push:{
redirecturis:e.redirecturi}});});

2.remove original document field

db.cncspstore.update({},{$unset:{redirecturi:""}},false,true)

3.rename snapshot field

db.cncspstore.update({},{$rename:{'redirecturis':'redirecturi'}},false,true)

備註:

手動刪掉欄位中一筆資料值...

db.cncspstore.update({"clientid" : "要對應修改的clientid值"},{$set:{"redirecturi" : ["要修改的正確uri位址"]}})

 

在mongo中手動加入欄位資料

db.systemstore.update({"_id":ObjectId("5ae0b3c4f0382232e0xxxxd7")},{$push:{"manager":"neaoOOXX"}})

在mongo中刪除某個欄位內的某個數值

db.systemstore.update({"_id":ObjectId("5ae0bxxxf0382232e0e65dd7")},{$pull:{"manager":"neaxxx"}})

 

備份mongo

mongodump --db xxstore --out /root/mongobk/xxxx

還原mongo:必須指定備份路徑到bson檔位置,加上drop參數,先把collections都刪掉才能正確還原

mongorestore -d xxxstore --drop /home/ub/Documents/xxxx/xxxxstore/

在mongo裡有個表是用來放authcode雖然有時效,但mongo不會主動清除裡面的過期紀錄,可能導致系統效能問題

這時可用手動的方式檢查並刪除

db.authcodestore.count()

>42352

裡面存了4萬多筆紀錄沒有作用

可再用下列指令刪除

db.authcodestore.remove({})

重新檢查一次紀錄變成-1了

 

END

你可能感興趣的文章

solution for selinux issue while installing zabbix agent on centos7 install zabbix agent as service will raise selinux issue on some centos 7.3.1611

更新程式環境到wildfly18+openjdk11-phase2: update IDEA to jdk11 更新IDEA 編譯環境

在apache http server停用TLS 1.0/1.1 and SSL 2.0/3.0 How to disable outdated versions of SSL/TLS on Apache

[java]縣市IDP建置 使用NetBeans建置IDP程式

更新程式取消google recaptcha改用輸入驗證碼 update cnclibs to 0.0.8.6

新增縣市端回傳使用者資料功能 新增縣市端回傳使用者資料功能

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

設定win10開機自動執行openvpn連接vpn server how to make win10 connecting to a vpn server automactically after booting up

在virtualbox如何壓縮vdi檔 using commands to reduce virtualbox's vdi file space

使用virtualbox每次都忘記的事情 share folder from win host to linux guest vm

如何用git log功能產生有固定格式的commit紀錄 how to create a git commit history log file with custom format

testing gitlab and jenkins CI/CD on docker-1 在docker架設gitlab, jenkins 測試CI/CD pipeline第一章