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

style: Prefer immutable objects #10

Merged
merged 2 commits into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ Performance:

Security:
Enabled: true

Style/FrozenStringLiteralComment:
Enabled: true

Style/RedundantFreeze:
Enabled: true
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"

Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "webauthn"
Expand Down
8 changes: 5 additions & 3 deletions lib/webauthn.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "webauthn/validator"
require "webauthn/version"

Expand All @@ -7,9 +9,9 @@

module WebAuthn
ES256_ALGORITHM = { type: "public-key", alg: -7 }.freeze
RP_NAME = "web-server".freeze
USER_ID = "1".freeze
USER_NAME = "web-user".freeze
RP_NAME = "web-server"
USER_ID = "1"
USER_NAME = "web-user"
CREATE_TYPE = "webauthn.create"

def self.credential_creation_options
Expand Down
6 changes: 4 additions & 2 deletions lib/webauthn/validator.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require "cbor"

module WebAuthn
class Validator
AUTHENTICATOR_DATA_MIN_LENGTH = 37.freeze
USER_PRESENT_BIT_POSITION = 0.freeze
AUTHENTICATOR_DATA_MIN_LENGTH = 37
USER_PRESENT_BIT_POSITION = 0

def initialize(attestation_object:, client_data_bin:, original_challenge:)
@attestation_object = attestation_object
Expand Down
2 changes: 2 additions & 0 deletions lib/webauthn/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module WebAuthn
VERSION = "0.0.0"
end
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require "bundler/setup"
require "webauthn"

Expand Down
2 changes: 2 additions & 0 deletions spec/webauthn/validator_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe WebAuthn::Validator do
it "return user-friendly error if no client data received" do
validator = WebAuthn::Validator.new(
Expand Down
2 changes: 2 additions & 0 deletions spec/webauthn_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe WebAuthn do
it "has a version number" do
expect(WebAuthn::VERSION).not_to be nil
Expand Down
2 changes: 2 additions & 0 deletions webauthn.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "webauthn/version"
Expand Down