Skip to content
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

Validate the JSON data in load #36

Merged
merged 14 commits into from
Dec 14, 2017
4 changes: 4 additions & 0 deletions lib/u2f/register_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def self.load_from_json(json)
raise RegistrationError, code: data['errorCode']
end

if data['clientData'].blank? || data['registrationData'].blank?
raise RegistrationError, code: 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the code in a constant, for clarity

end

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