Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SUBDIRS = ai archive chat desktopnotifications files filesbackendDefault filesbackendSeafile intranet kendox maps mdm meet passwd smime templatesnippets
SUBDIRS = ai archive chat desktopnotifications files filesbackendDefault filesbackendSeafile google2fa intranet kendox maps mdm meet passwd smime templatesnippets

.PHONY: subdirs $(SUBDIRS)

Expand Down
31 changes: 31 additions & 0 deletions plugins/google2fa/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
include ../shared.mk

MSGFMT ?= msgfmt

JSFILES = js/Google2FAPlugin.js \
js/data/Configuration.js \
js/data/ResponseHandler.js \
js/settings/Category.js \
js/settings/GeneralSettingsWidget.js

COPYFILES = manifest.xml config.php \
$(wildcard resources/css/*.css) \
$(shell find resources/icons/ -type f \( -name '*.png' -o -name '*.gif' -o -name '*.jpg' \) ) \
$(shell find php/ -type f \! -name '.*' -not -path '*/tests/*' -not -path '*/examples/*' -not -path '*/vendor/bin/*' -not -path '*/.github/*' -not -iname '*.py' -not -iname 'naturalselection')

CSSDEPLOY = $(DESTDIR)/resources/css/

COPYFILESDEST = $(addprefix $(DESTDIR)/, $(COPYFILES))

all: $(COPYFILESDEST) $(JSDEPLOY)/google2fa.js $(CSSDEPLOY)/google2fa.css

$(JSDEPLOY)/google2fa.js: $(JSFILES)
mkdir -p $(DESTDIR)/js
cat $(JSFILES) > $(@:.js=-debug.js)
$(JSCOMPILER) $(@:.js=-debug.js) --output $@ \
--source-map "url='$(shell basename $@.map)'" \
$(JSOPTIONS)

$(CSSDEPLOY)/google2fa.css: $(CSSFILES)
mkdir -p $(CSSDEPLOY)
cat $(CSSFILES) > $(CSSDEPLOY)/google2fa.css
26 changes: 26 additions & 0 deletions plugins/google2fa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# grommunio Google 2FA Plugin

This plugin will integrate two-factor authorization with an external OTP provider (Google Authenticator App) in grommunio-web.

# Configuration

The plugin configuration can be found in the **'config.php'** file.

```const PLUGIN_GOOGLE2FA_ENABLE = true;```

* Enable/Disable plugin
* Default for new users, this doesn't mean the activation of two-factor authentication!

```const PLUGIN_GOOGLE2FA_ALWAYS_ENABLED = false;```

* Enable plugin when plugin is loading, the user can't disable the plugin.

```const PLUGIN_GOOGLE2FA_ACTIVATE = false;```

* Activate / deactivate 2FA
* Default for new users.

```const PLUGIN_GOOGLE2FA_ALWAYS_ACTIVATED = false;```

* Activate 2FA when plugin is loading.

27 changes: 27 additions & 0 deletions plugins/google2fa/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

/**
* Configuration for Google2FA plugin
*/

/**
* Enable/Disable plugin
* Default for new users, this doesn't mean the activation of two-factor authentication!
*/
const PLUGIN_GOOGLE2FA_ENABLE = true;

/**
* Enable plugin when plugin is loading, the user can't disable the plugin.
*/
const PLUGIN_GOOGLE2FA_ALWAYS_ENABLED = false;

/**
* Activate/Deactivate 2FA
* Default for new users.
*/
const PLUGIN_GOOGLE2FA_ACTIVATE = false;

/**
* Activate 2FA when plugin is loading.
*/
const PLUGIN_GOOGLE2FA_ALWAYS_ACTIVATED = false;
47 changes: 47 additions & 0 deletions plugins/google2fa/js/Google2FAPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Ext.namespace('Zarafa.plugins.google2fa');

/**
* @class Zarafa.plugins.google2fa.Google2FA
* @extends Zarafa.core.Plugin
*/
Zarafa.plugins.google2fa.Google2FA = Ext.extend(Zarafa.core.Plugin, {

/**
* @constructor
* @param {Object} config Configuration object
*/
constructor: function (config) {
config = config || {};

Zarafa.plugins.google2fa.Google2FA.superclass.constructor.call(this, config);
},

/**
* Init plugin
*/
initPlugin: function () {
Zarafa.plugins.google2fa.Google2FA.superclass.initPlugin.apply(this, arguments);
Zarafa.plugins.google2fa.data.Configuration.init();
this.registerInsertionPoint("context.settings.categories", this.createSettingCategories, this);
},

/**
* Create category in settings
*/
createSettingCategories: function () {
return {
xtype: "Zarafa.plugins.google2fa.category"
};
}
});

Zarafa.onReady(function () {
let allowUserDisable = container.getSettingsModel().get('zarafa/v1/plugins/google2fa/user_disable_allowed');

container.registerPlugin(new Zarafa.core.PluginMetaData({
name: 'google2fa',
displayName: _('Google2FA Plugin'),
allowUserDisable: allowUserDisable,
pluginConstructor: Zarafa.plugins.google2fa.Google2FA
}));
});
24 changes: 24 additions & 0 deletions plugins/google2fa/js/data/Configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Ext.namespace("Zarafa.plugins.google2fa.data");
/**
* @class Zarafa.plugins.google2fa.data.Configuration
* @extends Object
*
* Manage the inital settings if settings is loading
*/
Zarafa.plugins.google2fa.data.Configuration = Ext.extend(Object,
{
activate: undefined,
init: function () {
let a = new Zarafa.plugins.google2fa.data.ResponseHandler({
successCallback: this.gotIsActivated.createDelegate(this)
});
container.getRequest().singleRequest("google2famodule", "isactivated", {}, a);
},
gotIsActivated: function (a) {
this.activate = a.isActivated;
},
isActivated: function (a) {
return this.activate;
}
});
Zarafa.plugins.google2fa.data.Configuration = new Zarafa.plugins.google2fa.data.Configuration();
56 changes: 56 additions & 0 deletions plugins/google2fa/js/data/ResponseHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Ext.namespace("Zarafa.plugins.google2fa.data");

/**
* @class Zarafa.plugins.google2fa.data.ResponseHandler
* @extends Zarafa.core.data.AbstractResponseHandler
*
* Response handler for communication with server
*/
Zarafa.plugins.google2fa.data.ResponseHandler = Ext.extend(Zarafa.core.data.AbstractResponseHandler,
{
/**
* @cfg {Function} successCallback The function which
* will be called after success request.
*/
successCallback: Ext.emptyFn,

/**
* @cfg {Function} failureCallback The function which
* will be called after a failed request.
* This callback is optional and currently unused.
*/
failureCallback: Ext.emptyFn,

doResetconfiguration: function (a) {
this.successCallback(a);
},
doGetsecret: function (a) {
this.successCallback(a);
},
doActivate: function (a) {
this.successCallback(a);
},
doIsactivated: function (a) {
this.successCallback(a);
},
doVerifycode: function (a) {
this.successCallback(a);
},
doError: function (a) {
if (a.error)
Zarafa.common.dialogs.MessageBox.show({
title: "Error",
msg: a.error.info.original_message,
icon: Zarafa.common.dialogs.MessageBox.ERROR,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
else
Zarafa.common.dialogs.MessageBox.show({
title: "Error",
msg: a.info.original_message,
icon: Zarafa.common.dialogs.MessageBox.ERROR,
buttons: Zarafa.common.dialogs.MessageBox.OK
});
}
});
Ext.reg("google2fa.responsehandler", Zarafa.plugins.google2fa.data.ResponseHandler);
28 changes: 28 additions & 0 deletions plugins/google2fa/js/settings/Category.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Ext.namespace("Zarafa.plugins.google2fa.settings");

/**
* @class Zarafa.plugins.google2fa.settings.SettingsGoogle2FACategory
* @extends Zarafa.settings.ui.SettingsCategory
*
* Category view for two-factor authentication in settings
*/
Zarafa.plugins.google2fa.settings.Category = Ext.extend(Zarafa.settings.ui.SettingsCategory, {
/**
* @constructor
* @param {Object} config Configuration object
*/
constructor: function (config) {
config = config || {};
Ext.applyIf(config, {
title: _('Two-factor authentication'),
categoryIndex: 1,
iconCls: "icon_google2fa_category",
items: [{
xtype: "Zarafa.plugins.google2fa.generalsettingswidget"
}, container.populateInsertionPoint("context.settings.category.google2fa", this)]
});
Zarafa.plugins.google2fa.settings.Category.superclass.constructor.call(this, config);
}
});

Ext.reg("Zarafa.plugins.google2fa.category", Zarafa.plugins.google2fa.settings.Category);
Loading