diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-16 21:48:36 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-18 22:12:02 +0530 |
commit | 16c44a5ddd8551224bd94318727a32b52a68425d (patch) | |
tree | 0b8c54141b147872151542c83282abc2acb2f2cb /app/controllers/profiles | |
parent | 1b338d59f641ce629cbecb839b64c9fd65561276 (diff) | |
download | gitlab-ce-16c44a5ddd8551224bd94318727a32b52a68425d.tar.gz |
Allow naming U2F devices.
1. Display a list of U2F devices on the `two_factor_auth` page.
2. Allow deleting individual U2F devices.
3. Allow setting a (optional) name for a device (during registration).
Diffstat (limited to 'app/controllers/profiles')
-rw-r--r-- | app/controllers/profiles/two_factor_auths_controller.rb | 11 | ||||
-rw-r--r-- | app/controllers/profiles/u2f_registrations_controller.rb | 7 |
2 files changed, 15 insertions, 3 deletions
diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb index e37e9e136db..cfa84c3bf4d 100644 --- a/app/controllers/profiles/two_factor_auths_controller.rb +++ b/app/controllers/profiles/two_factor_auths_controller.rb @@ -43,11 +43,11 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController # A U2F (universal 2nd factor) device's information is stored after successful # registration, which is then used while 2FA authentication is taking place. def create_u2f - @u2f_registration = U2fRegistration.register(current_user, u2f_app_id, params[:device_response], session[:challenges]) + @u2f_registration = U2fRegistration.register(current_user, u2f_app_id, u2f_registration_params, session[:challenges]) if @u2f_registration.persisted? session.delete(:challenges) - redirect_to profile_account_path, notice: "Your U2F device was registered!" + redirect_to profile_two_factor_auth_path, notice: "Your U2F device was registered!" else @qr_code = build_qr_code setup_u2f_registration @@ -91,7 +91,8 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController # Actual communication is performed using a Javascript API def setup_u2f_registration @u2f_registration ||= U2fRegistration.new - @registration_key_handles = current_user.u2f_registrations.pluck(:key_handle) + @u2f_registrations = current_user.u2f_registrations + @registration_key_handles = @u2f_registrations.pluck(:key_handle) u2f = U2F::U2F.new(u2f_app_id) registration_requests = u2f.registration_requests @@ -102,4 +103,8 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController register_requests: registration_requests, sign_requests: sign_requests }) end + + def u2f_registration_params + params.require(:u2f_registration).permit(:device_response, :name) + end end diff --git a/app/controllers/profiles/u2f_registrations_controller.rb b/app/controllers/profiles/u2f_registrations_controller.rb new file mode 100644 index 00000000000..c02fe85c3cc --- /dev/null +++ b/app/controllers/profiles/u2f_registrations_controller.rb @@ -0,0 +1,7 @@ +class Profiles::U2fRegistrationsController < Profiles::ApplicationController + def destroy + u2f_registration = current_user.u2f_registrations.find(params[:id]) + u2f_registration.destroy + redirect_to profile_two_factor_auth_path, notice: "Successfully deleted U2F device." + end +end |