-
Notifications
You must be signed in to change notification settings - Fork 738
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #4595 - 2FA: Authenticator App
Co-authored-by: Dominik Klein <dk@zammad.com> Co-authored-by: Dusan Vuckovic <dv@zammad.com> Co-authored-by: Florian Liebe <fl@zammad.com> Co-authored-by: Mantas Masalskis <mm@zammad.com> Co-authored-by: Martin Gruner <mg@zammad.com> Co-authored-by: Rolf Schmidt <rolf.schmidt@zammad.com> Co-authored-by: Tobias Schäfer <ts@zammad.com> Co-authored-by: Vladimir Sheremet <vs@zammad.com>
- Loading branch information
1 parent
bec0ce8
commit 54f0620
Showing
148 changed files
with
5,716 additions
and
607 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ paths = [ | |
'''^tmp/''', | ||
] | ||
regexTarget = "line" | ||
regexes = [] | ||
regexes = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/assets/javascripts/app/controllers/_application_controller/after_auth_modal.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class App.ControllerAfterAuthModal extends App.ControllerModal | ||
includeForm: false | ||
data: {} | ||
logoutOnCancel: true | ||
backdrop: 'static' | ||
keyboard: false | ||
buttonClose: false | ||
buttonSubmit: false | ||
buttonCancel: __('Cancel') | ||
|
||
onCancel: (e) -> | ||
if @logoutOnCancel | ||
App.Auth.logout() | ||
|
||
fetchAfterAuth: -> | ||
@ajax( | ||
id: 'after_auth' | ||
type: 'GET' | ||
url: "#{@apiPath}/users/after_auth" | ||
success: (after_auth) -> | ||
App.Config.set('after_auth', after_auth) | ||
|
||
return if _.isEmpty(after_auth) | ||
|
||
new App['AfterAuth' + after_auth.type]( | ||
data: after_auth.data | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/assets/javascripts/app/controllers/_plugin/after_auth.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class AfterAuth extends App.Controller | ||
constructor: -> | ||
super | ||
|
||
return if !@authenticateCheck() | ||
|
||
after_auth = App.Config.get('after_auth') | ||
return if _.isEmpty(after_auth) | ||
|
||
new App['AfterAuth' + after_auth.type]( | ||
data: after_auth.data | ||
) | ||
|
||
App.Config.set('after_auth', AfterAuth, 'Plugins') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
app/assets/javascripts/app/controllers/after_auth/two_factor_configuration.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
class App.AfterAuthTwoFactorConfiguration extends App.ControllerAfterAuthModal | ||
head: __('Set up two-factor authentication') | ||
buttonCancel: __('Cancel & Sign out') | ||
buttonSubmit: false | ||
|
||
events: | ||
'click .js-configuration-method': 'selectConfigurationMethod' | ||
|
||
constructor: (params) -> | ||
|
||
# Remove the fade transition if requested. | ||
if params.noFadeTransition | ||
params.className = 'modal' | ||
|
||
super(params) | ||
|
||
content: -> | ||
content = $(App.view('after_auth/two_factor_configuration')()) | ||
|
||
@fetchAvailableMethods() | ||
|
||
content | ||
|
||
fetchAvailableMethods: -> | ||
# If user clicks cancel & sign out, modal may try to re-render during logout | ||
# Since current user is no longer avaialble, it would throw a javascript error | ||
return if !App.User.current() | ||
|
||
@ajax( | ||
id: 'two_factor_enabled_methods' | ||
type: 'GET' | ||
url: "#{@apiPath}/users/#{App.User.current().id}/two_factor_enabled_methods" | ||
success: @renderAvailableMethods | ||
) | ||
|
||
renderAvailableMethods: (data, status, xhr) => | ||
methodButtons = $(App.view('after_auth/two_factor_configuration/method_buttons')( | ||
enabledMethods: @transformTwoFactorMethods(data) | ||
)) | ||
|
||
@$('.two-factor-auth-method-buttons').html(methodButtons) | ||
|
||
transformTwoFactorMethods: (data) -> | ||
return [] if _.isEmpty(data) | ||
|
||
iteratee = (memo, item) -> | ||
method = App.TwoFactorMethods.methodByKey(item.method) | ||
|
||
return memo if !method | ||
|
||
memo.push(_.extend( | ||
{}, | ||
method, | ||
disabled: item.configured | ||
)) | ||
|
||
memo | ||
|
||
_.reduce(data, iteratee, []) | ||
|
||
closeWithoutFade: => | ||
@el.removeClass('fade') | ||
@close() | ||
|
||
selectConfigurationMethod: (e) => | ||
e.preventDefault() | ||
|
||
@closeWithoutFade() | ||
|
||
configurationMethod = $(e.currentTarget).data('method') | ||
|
||
return if _.isEmpty(configurationMethod) | ||
|
||
new App['TwoFactorConfigurationMethod' + configurationMethod]( | ||
mode: 'after_auth' | ||
successCallback: @fetchAfterAuth | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.