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/models/u2f_registration.rb | |
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/models/u2f_registration.rb')
-rw-r--r-- | app/models/u2f_registration.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/app/models/u2f_registration.rb b/app/models/u2f_registration.rb index 00b19686d48..808acec098f 100644 --- a/app/models/u2f_registration.rb +++ b/app/models/u2f_registration.rb @@ -3,18 +3,19 @@ class U2fRegistration < ActiveRecord::Base belongs_to :user - def self.register(user, app_id, json_response, challenges) + def self.register(user, app_id, params, challenges) u2f = U2F::U2F.new(app_id) registration = self.new begin - response = U2F::RegisterResponse.load_from_json(json_response) + response = U2F::RegisterResponse.load_from_json(params[:device_response]) registration_data = u2f.register!(challenges, response) registration.update(certificate: registration_data.certificate, key_handle: registration_data.key_handle, public_key: registration_data.public_key, counter: registration_data.counter, - user: user) + user: user, + name: params[:name]) rescue JSON::ParserError, NoMethodError, ArgumentError registration.errors.add(:base, 'Your U2F device did not send a valid JSON response.') rescue U2F::Error => e |