-
Notifications
You must be signed in to change notification settings - Fork 8
2fa #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
2fa #204
Changes from all commits
e268225
07a8d1c
b4b00ae
fa5d345
e5ffee8
807281f
ea5bf96
3be7021
0f28fea
8868f1e
8077ebd
ddb2bba
8f208bf
9470410
147984e
2c8ad81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| { | ||
| "name": "coderscommunity/forum", | ||
| "require": { | ||
| "sentry/sentry": "^1.0" | ||
| "sentry/sentry": "^1.0", | ||
| "ext-mbstring": "*", | ||
| "ext-intl": "*" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "event15/q2a-googleauthenticator-login", | ||
| "type": "library", | ||
| "license": "GPLv2", | ||
| "authors": [ | ||
| { | ||
| "name": "Marek Woś", | ||
| "email": "mwos@getresponse.com" | ||
| } | ||
| ], | ||
| "minimum-stability": "dev", | ||
| "autoload": { | ||
| "psr-4": { | ||
| "CodersCommunity\\": "src/" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. myślę, że namespace powinien być bardziej konkretny, tzn. zawierać jeszcze chociażby nazwę plugina, ale tu jest cała kwestia uzywania composera, opisałem w komentarzu
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. miałem na caly ten kod zupełnie inny pomysł z początku, ale zostałem uprzedzony i kod z obiektowego stał się q2a'owy. Przy takim stanie rzeczy przyjąłem to co już było i nie starałem się diametralnie wszystkiego zmieniać. Jeśli się uda dodać do composera głównego zależność a jej tu nie budować, to być może to zniknie, z resztą o ile mam dobrą pamięć, to ten namespace jest nieużyty, a na pewno nie tak, jak powinien.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nawet jeśli ten byłby nie użyty to CodersCommunity kojarzy się z nazwą całej organizacji forumowej, więc czemu ma należeć do jednego plugina. Tym bardziej już gdyby coś było w globalnym lepiej byłoby dać chociażby |
||
| } | ||
| }, | ||
| "require": { | ||
| "robthree/twofactorauth": "dev-master" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nie lepiej dla bezpieczeństwa wskazać konkretną wersję o jaką nam chodzi?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "Google Authenticator 2-factor authentication for Q2A", | ||
| "description": "This plugin provides a Google 2FA security for users on forum", | ||
| "version": "1.0", | ||
| "date": "2018-05-30", | ||
| "author": "Marek Woś", | ||
event15 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "author_uri": "http://github.com/event15", | ||
| "license": "GPLv2", | ||
| "update_uri": "Web address for Q2A to check for updates", | ||
| "min_q2a": "1.7", | ||
| "min_php": "5.4", | ||
| "load_order": "Bootstrap moment in which the plugin will be loaded" | ||
| } | ||
event15 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| <?php | ||
|
|
||
| namespace CodersCommunity; | ||
|
|
||
| require_once __DIR__ . '/../../vendor/autoload.php'; | ||
|
|
||
| class q2a_googleauthenticator_admin | ||
| { | ||
| public function init_queries() | ||
| { | ||
| $isActive = qa_opt('googleauthenticator_login'); | ||
| $result = null; | ||
|
|
||
| if (1 === $isActive) { | ||
| return null; | ||
| } | ||
|
|
||
| $queries = []; | ||
|
|
||
| $columns = qa_db_read_all_values(qa_db_query_sub('describe ^users')); | ||
| if (!in_array('2fa_enabled', $columns, true)) { | ||
| $queries[] = 'ALTER TABLE ^users ADD `2fa_enabled` SMALLINT (1) DEFAULT 0'; | ||
| } | ||
|
|
||
| if (!in_array('2fa_change_date', $columns, true)) { | ||
| $queries[] = 'ALTER TABLE ^users ADD `2fa_change_date` VARCHAR (80) DEFAULT 0'; | ||
| } | ||
|
|
||
| if (!in_array('2fa_secret', $columns, true)) { | ||
| $queries[] = | ||
| 'ALTER TABLE ^users ADD `2fa_secret` VARCHAR ( 80 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL'; | ||
| } | ||
|
|
||
| if (!in_array('2fa_recovery_code', $columns, true)) { | ||
| $queries[] = 'ALTER TABLE ^users ADD `2fa_recovery_code` VARCHAR (11) DEFAULT 0'; | ||
| } | ||
|
|
||
| if (!in_array('2fa_login_code', $columns, true)) { | ||
| $queries[] = 'ALTER TABLE ^users ADD `2fa_login_code` VARCHAR (32) DEFAULT 0'; | ||
| } | ||
|
|
||
| if (!in_array('2fa_login_code_created', $columns, true)) { | ||
| $queries[] = 'ALTER TABLE ^users ADD `2fa_login_code_created` TIMESTAMP NULL DEFAULT NULL;'; | ||
| } | ||
|
|
||
| if(count($queries)) { | ||
| $result = $queries; | ||
| } | ||
|
|
||
| // we're already set up | ||
| qa_opt('googleauthenticator_login', 1); | ||
|
|
||
| return $result; | ||
| } | ||
|
|
||
| public function admin_form() | ||
| { | ||
| $saved = false; | ||
|
|
||
| if (qa_clicked('2fa_save_button')) { | ||
| $enabled = qa_post_text('googleauthenticator_enable_plugin'); | ||
| qa_opt('googleauthenticator_login', empty($enabled) ? 0 : 1); | ||
|
|
||
| $saved = true; | ||
| } | ||
|
|
||
| return [ | ||
| 'ok' => $saved ? qa_lang('plugin_2fa/saved_plugin_settings') : null, | ||
| 'fields' => [[ | ||
| 'type' => 'checkbox', | ||
| 'label' => qa_opt('googleauthenticator_login') ? | ||
| qa_lang('plugin_2fa/enabled_plugin') : | ||
| qa_lang('plugin_2fa/disabled_plugin'), | ||
| 'value' => qa_opt('googleauthenticator_login') ? true : false, | ||
| 'tags' => 'NAME="googleauthenticator_enable_plugin"' | ||
| ] | ||
| ], | ||
| 'buttons' => [[ | ||
| 'label' => qa_lang('plugin_2fa/save_settings'), | ||
| 'tags' => 'NAME="2fa_save_button"' | ||
| ] | ||
| ] | ||
| ]; | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.