Skip to content

Commit

Permalink
Merge pull request #342 from cedarcode/braulio_fix_acceptable_attesta…
Browse files Browse the repository at this point in the history
…tion_types_inclusion_for_none

Fix: validate acceptable attestation type inclusion when attestation statement is None
  • Loading branch information
grzuy committed Feb 15, 2021
2 parents 844c973 + f9b89f6 commit 3c2d2fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/webauthn/attestation_statement/none.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ module WebAuthn
module AttestationStatement
class None < Base
def valid?(*_args)
if statement == {}
if statement == {} && trustworthy?
[WebAuthn::AttestationStatement::ATTESTATION_TYPE_NONE, nil]
else
false
end
end

private

def attestation_type
WebAuthn::AttestationStatement::ATTESTATION_TYPE_NONE
end
end
end
end
6 changes: 6 additions & 0 deletions spec/webauthn/attestation_statement/none_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,11 @@
expect(WebAuthn::AttestationStatement::None.new([]).valid?(authenticator_data, nil)).to be_falsy
expect(WebAuthn::AttestationStatement::None.new("a" => "b").valid?(authenticator_data, nil)).to be_falsy
end

it "returns false if None is not among the acceptable attestation types" do
WebAuthn.configuration.acceptable_attestation_types = ['AttCA']

expect(WebAuthn::AttestationStatement::None.new({}).valid?(authenticator_data, nil)).to be_falsy
end
end
end

0 comments on commit 3c2d2fa

Please sign in to comment.