Skip to content

Commit

Permalink
Raise error on bad response data
Browse files Browse the repository at this point in the history
When trying to sign response make sue the data is correct and raise a known error rather than a method missing error on bad data.
  • Loading branch information
ashleym1972 authored Jun 29, 2017
1 parent cc4c70d commit 02e7162
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/u2f/sign_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ class SignResponse

def self.load_from_json(json)
data = ::JSON.parse(json)
if data['clientData'].blank? || data['keyHandle'].blank? || data['signatureData'].blank?
raise Error, 'Missing required data'
end

instance = new
instance.client_data_json =
::U2F.urlsafe_decode64(data['clientData'])
Expand Down

0 comments on commit 02e7162

Please sign in to comment.