Skip to content

Commit

Permalink
[recaptcha] captcha plugin for login screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ar2rsawseen committed Nov 10, 2021
1 parent 5c82ab3 commit 5a41e67
Show file tree
Hide file tree
Showing 26 changed files with 330 additions and 0 deletions.
14 changes: 14 additions & 0 deletions plugins/recaptcha/api/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var pluginObject = {};
// common = require('../../../api/utils/common.js'),
// plugins = require('../../pluginManager.js');

(function(/*plugin*/) {
//write api call
/*
plugins.register("/i", function(ob){
});
*/
}(pluginObject));

module.exports = pluginObject;
58 changes: 58 additions & 0 deletions plugins/recaptcha/frontend/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
var exportedPlugin = {},
countlyConfig = require('../../../frontend/express/config', 'dont-enclose'),
recaptcha = require('express-recaptcha');
var plugins = require("../../pluginManager.js");

plugins.setConfigs("recaptcha", {
enable: true,
site_key: "",
secret_key: ""
});

(function(plugin) {
plugin.init = function(app, countlyDb) {
plugins.loadConfigs(countlyDb, function() {
if (plugins.getConfig("recaptcha").enable && plugins.getConfig("recaptcha").site_key !== "" && plugins.getConfig("recaptcha").secret_key !== "") {
try {
recaptcha.init(plugins.getConfig("recaptcha").site_key, plugins.getConfig("recaptcha").secret_key);
}
catch (ex) {
console.log(ex);
}
}
});
app.post(countlyConfig.path + '/login', function(req, res, next) {
if (req.session.fails && plugins.getConfig("recaptcha").enable && plugins.getConfig("recaptcha").site_key !== "" && plugins.getConfig("recaptcha").secret_key !== "") {
recaptcha.verify(req, function(error) {
if (!error) {
next();
}
else {
res.redirect(countlyConfig.path + '/login?message=recaptcha.incorrect');
}
});
}
else {
next();
}
});
app.get(countlyConfig.path + '/login', function(req, res, next) {
if (req.session.fails && plugins.getConfig("recaptcha").enable && plugins.getConfig("recaptcha").site_key !== "" && plugins.getConfig("recaptcha").secret_key !== "") {
req.template.html += "<link href='./recaptcha/stylesheets/main.css' rel='stylesheet' type='text/css'>";
req.template.js += "addLocalization('recaptcha', countlyGlobal[\"cdn\"]+'recaptcha/localization/');";
req.template.js += "$(document).ready(function() {" +
"$('body').addClass('recaptcha-enabled');" +
"});";
if (plugins.isPluginEnabled("enterpriseinfo")) {
req.template.js += "$(document).ready(function() {" +
"$('body').addClass('enterpriseinfo-enabled');" +
"});";
}
req.template.form += recaptcha.render();
}
next();
});
};
}(exportedPlugin));

module.exports = exportedPlugin;
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*global app, $ */
$(document).ready(function() {
//check if configuration view exists
if (app.configurationsView) {
app.configurationsView.registerLabel("recaptcha", "recaptcha.title");
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
recaptcha.title = Recaptcha
recaptcha.description = Display recaptcha on incorrect login
recaptcha.site_key = Site Key
recaptcha.secret_key = Secret Key
recaptcha.enable = Enable Recaptcha
configs.help.recaptcha-enable = Enable or Disable Recaptcha
configs.help.recaptcha-site_key = Get site key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Get secret key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Please verify you are not a robot.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Display recaptcha on incorrect login
recaptcha.site_key = Site Key
recaptcha.secret_key = Secret Key
recaptcha.enable = Enable Recaptcha
configs.help.recaptcha-enable = Enable or Disable Recaptcha
configs.help.recaptcha-site_key = Get site key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Get secret key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Please verify you are not a robot.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = ReCAPTCHA
recaptcha.description = reCAPTCHA bei falscher Anmeldung anzeigen
recaptcha.site_key = Seitenschlüssel
recaptcha.secret_key = Geheimschlüssel
recaptcha.enable = ReCAPTCHA aktivieren
configs.help.recaptcha-enable = ReCAHPTCHA aktivieren oder deaktivieren
configs.help.recaptcha-site_key = Rufen Sie den Seitenschlüssel ab von: <a href='https://www.google.com/recaptcha/admin' target='_blank'> ReCAPTCHA </a> ab
configs.help.recaptcha-secret_key = Rufen Sie den Geheimschlüssel ab von: <a href='https://www.google.com/recaptcha/admin' target='_blank'>ReCAPTCHA</a>
recaptcha.incorrect = Bitte beweisen Sie, dass Sie kein Roboter sind.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Δοκιμασία reCaptcha
recaptcha.description = Εφαρμογή της δοκιμασίας ReCaptcha στην περίπτωση αποτυχημένης ταυτοποίησης
recaptcha.site_key = Κλειδί Τοποθεσίας
recaptcha.secret_key = Κρυφό Κλειδί
recaptcha.enable = Ενεργοποίηση δοκιμασίας reCaptcha
configs.help.recaptcha-enable = Ενεργοποίηση ή Απενεργοποίηση reCaptcha
configs.help.recaptcha-site_key = Λήψη του κλειδιού της τοποθεσίας από <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Λήψη του κρυφού κλειδιού από <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Παρακαλώ επαληθεύστε ότι δεν είσαστε ρομπότ
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Display recaptcha on incorrect login
recaptcha.site_key = Site Key
recaptcha.secret_key = Secret Key
recaptcha.enable = Enable Recaptcha
configs.help.recaptcha-enable = Enable or Disable Recaptcha
configs.help.recaptcha-site_key = Get site key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Get secret key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Please verify you are not a robot.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Display recaptcha on incorrect login
recaptcha.site_key = Site Key
recaptcha.secret_key = Secret Key
recaptcha.enable = Enable Recaptcha
configs.help.recaptcha-enable = Enable or Disable Recaptcha
configs.help.recaptcha-site_key = Get site key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Get secret key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Please verify you are not a robot.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Használjon recaptcha opciót sikertelen belépési kisérlet esetén
recaptcha.site_key = Oldal kulcs
recaptcha.secret_key = Titkos kulcs
recaptcha.enable = Recaptcha engedélyezése
configs.help.recaptcha-enable = Recaptcha engedélyezése vagy tiltása
configs.help.recaptcha-site_key = Oldal kulcs kérés innen <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Get secret key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Kérlek igazold, hogy nem vagy robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = ログインが間違った場合にRecaptchaを表示します
recaptcha.site_key = Site Key
recaptcha.secret_key = Secret Key
recaptcha.enable = Recaptchaを有効にする
configs.help.recaptcha-enable = Recaptchaの有効/無効
configs.help.recaptcha-site_key = Site keyを<a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>から入手してください
configs.help.recaptcha-secret_key = Secret keyを<a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>から入手してください
recaptcha.incorrect = 私はロボットではありません
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = 리캡차
recaptcha.description = 부정확한 로그인에대한 리캡차 표시
recaptcha.site_key = 사이트 키
recaptcha.secret_key = 시크릿 키
recaptcha.enable = 리캡차 가능
configs.help.recaptcha-enable = Recaptcha 사용 또는 사용 안 함
configs.help.recaptcha-site_key = <a href='https://www.google.com/recaptcha/admin' target='_blank'>리캡차</a>에서 사이트 키 얻음.
configs.help.recaptcha-secret_key = <a href='https://www.google.com/recaptcha/admin' target='_blank'>리캡차</a>에서 시크릿 키 얻음.
recaptcha.incorrect = 로봇이 아닌지 확인하십시오.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Display recaptcha on incorrect login
recaptcha.site_key = Lapas atslēga
recaptcha.secret_key = Slepenā atslēga
recaptcha.enable = Enable Recaptcha
configs.help.recaptcha-enable = Enable or Disable Recaptcha
configs.help.recaptcha-site_key = Get site key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Get secret key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Please verify you are not a robot.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Display recaptcha on incorrect login
recaptcha.site_key = Site Key
recaptcha.secret_key = Secret Key
recaptcha.enable = Enable Recaptcha
configs.help.recaptcha-enable = Enable or Disable Recaptcha
configs.help.recaptcha-site_key = Get site key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Get secret key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Please verify you are not a robot.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Отображать recaptcha при неверной попытке входа
recaptcha.site_key = Ключ сайта
recaptcha.secret_key = Секретный ключ
recaptcha.enable = Включить Recaptcha
configs.help.recaptcha-enable = Включить или отключить Recaptcha
configs.help.recaptcha-site_key = Получить ключ сайта из <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Получить секретный ключ из <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Пожалуйста подтвердите, что Вы не робот
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Display recaptcha on incorrect login
recaptcha.site_key = Site Key
recaptcha.secret_key = Secret Key
recaptcha.enable = Enable Recaptcha
configs.help.recaptcha-enable = Enable or Disable Recaptcha
configs.help.recaptcha-site_key = Get site key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Get secret key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Please verify you are not a robot.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Hatalı girişlerde recaptcha görüntüler
recaptcha.site_key = Site Anahtarı
recaptcha.secret_key = Özel Anahtar (Secret Key)
recaptcha.enable = Recaptcha'yı Etkinleştir
configs.help.recaptcha-enable = Recaptcha'yı etkinleştir ya da kapat
configs.help.recaptcha-site_key = Site anahtarını <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a> adresinden alın.
configs.help.recaptcha-secret_key = Gizli anahtarı (secret key) <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a> adresinden alın.
recaptcha.incorrect = Lütfen robot olmadığınızı kanıtlayın.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = Recaptcha
recaptcha.description = Display recaptcha on incorrect login
recaptcha.site_key = Site Key
recaptcha.secret_key = Secret Key
recaptcha.enable = Enable Recaptcha
configs.help.recaptcha-enable = Enable or Disable Recaptcha
configs.help.recaptcha-site_key = Get site key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
configs.help.recaptcha-secret_key = Get secret key from <a href='https://www.google.com/recaptcha/admin' target='_blank'>Recaptcha</a>
recaptcha.incorrect = Please verify you are not a robot.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE AS IT WILL BE OVERRIDEN DURING TRANSLATION SYNC
# IF YOU WOULD LIKE TO HELP COUNTLY TO BE TRANSLATED INTO YOUR LANGUAGE
# PLEASE VISIT https://www.transifex.com/osoner/countly

recaptcha.title = 验证码
recaptcha.description = 当登陆失败时显示验证码
recaptcha.site_key = 网站Key
recaptcha.secret_key = 安全密钥
recaptcha.enable = 启用验证码
configs.help.recaptcha-enable = 启用或关闭验证码
configs.help.recaptcha-site_key = 从网站获取网站密钥<a href='https://www.google.com/recaptcha/admin' target='_blank'>验证码</a>
configs.help.recaptcha-secret_key = 从中获取密钥<a href='https://www.google.com/recaptcha/admin' target='_blank'>验证码</a>
recaptcha.incorrect = 请验证您不是一个机器人。
8 changes: 8 additions & 0 deletions plugins/recaptcha/frontend/public/stylesheets/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.g-recaptcha > div { margin-left: auto; margin-right: auto; }
.recaptcha-enabled input[type=text],
.recaptcha-enabled input[type=password] { width: 282px; margin-right: 2px; }
.recaptcha-enabled #login-button { width: 302px; margin-right: 2px; }
.recaptcha-enabled #login-form { height:346px; margin-top: -173px; }

.enterpriseinfo-enabled.recaptcha-enabled #login-logo { margin-top: 15px; }
.enterpriseinfo-enabled.recaptcha-enabled #login-form { width:950px; margin-left: -475px; height: 380px; margin-top: -190px; }
Empty file added plugins/recaptcha/install.js
Empty file.
13 changes: 13 additions & 0 deletions plugins/recaptcha/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions plugins/recaptcha/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "countly-recaptcha",
"title": "Recaptcha",
"version": "1.0.0",
"description": "Display recaptcha on incorrect login",
"author": "Count.ly",
"homepage": "https://count.ly/plugins/recaptcha",
"repository": {
"type": "git",
"url": "http://github.com/Countly/countly-server.git"
},
"bugs": {
"url": "http://github.com/Countly/countly-server/issues"
},
"keywords": [
"countly",
"analytics",
"captcha",
"plugins",
"recaptcha"
],
"dependencies": {
"express-recaptcha": "2.1.0"
},
"private": true
}
Empty file added plugins/recaptcha/tests.js
Empty file.
Empty file added plugins/recaptcha/uninstall.js
Empty file.

0 comments on commit 5a41e67

Please sign in to comment.