[精讚] [會員登入]
455

新增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

你可能感興趣的文章

縣市IDP更換SSL憑證及修改servername+wildfly等設定 縣市IDP更換SSL

縣市端新增syncdata spi功能 為了讓部裡主機可以透過OAUTH2流程,呼叫縣市同步SYNCDATA 的API

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

系統不正常關機導致mongodb啟動失敗 重新安裝mongodb使用mongorestore

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

縣市端新增師生關係API程式 在縣市端建立可由教育部主機撈取縣市資料庫師生關係的API 程式

我有話要說

>>

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

訪客留言

[無留言]

隨機好文

在新版谷歌協作平台嵌入edimax或lass空氣盒子讀取數值並視覺化 embeeded javascript to read and visualized lass json value on new google site

在windows環境下強制刪除無法以檔案總管刪除的檔案或目錄 how to remove directories or files that cannot be deleted by default file manager

被蘋果帳號釣魚網站詐騙的心得 請小心小額電信代收費詐騙

zfs on ubuntu 20.04 how to destroy zfs pool while error message said pool is busy

更新java版本後一定要做的事情 how to deal with PKIX path building failed issue after upgrade java sdk version in IDE