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

Release 0.1.1 #8

Merged
merged 9 commits into from
Jan 14, 2020
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
shell: /bin/bash --login

docker:
- image: circleci/ruby:2.3-jessie
- image: circleci/ruby:2.6-stretch
environment:
BUNDLE_PATH: vendor/bundle
steps:
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.6
2.6.1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Or install it yourself as:

ClaimToken.configure do |config|
config.cipher_type = "aes-256-cbc" # this is the default
config.shared_encryption_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
config.shared_encryption_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" # 32 byte key required
config.digest_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
end

Expand Down
4 changes: 2 additions & 2 deletions claim_token.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require 'claim_token/version'
Gem::Specification.new do |spec|
spec.name = "claim_token"
spec.version = ClaimToken::VERSION
spec.authors = ["Daniel Zollinger"]
spec.email = ["daniel.zollinger@crichq.com"]
spec.authors = ["Daniel Zollinger", "Ben Greville"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Aww this lil library still getting love 😁

spec.email = ["ben.greville@crichq.com"]
spec.description = %q{ClaimToken encrypts and signs tokens to be used in a claim-based authentication system}
spec.summary = %q{Encrypt heem! Sign heem! Claim heem!}
spec.homepage = "http://github.com/NuffieProductions/ClaimToken"
Expand Down
2 changes: 1 addition & 1 deletion lib/claim_token/decryptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def check_signature! token
end

def build_cipher token
cipher = OpenSSL::Cipher::Cipher.new( token.fetch("cipher") )
cipher = OpenSSL::Cipher.new( token.fetch("cipher") )
cipher.decrypt
cipher.key = encryption_key
cipher.iv = decode(token.fetch("iv"))
Expand Down
2 changes: 1 addition & 1 deletion lib/claim_token/encryptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def encrypt message
end

def build_cipher
cipher = OpenSSL::Cipher::Cipher.new(cipher_type)
cipher = OpenSSL::Cipher.new(cipher_type)
cipher.encrypt
cipher.key = encryption_key
cipher.iv = iv = cipher.random_iv
Expand Down
2 changes: 1 addition & 1 deletion lib/claim_token/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ClaimToken
VERSION = "0.1.0"
VERSION = "0.1.1".freeze
Copy link
Member

Choose a reason for hiding this comment

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

Do we actually need to specify freeze now ? I though this was being automatically done by ruby ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to this stack overflow discussion you should do this or add the frozen string literal magic comment until Ruby 3, in which it'd do this by default https://stackoverflow.com/a/37799399

end
6 changes: 3 additions & 3 deletions spec/claim_token_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

let(:encoded_token) {
"eyJ0eXBlIjoiRW5jcnlwdGVkTWVzc2FnZSIsImNpcGhlciI6ImFlcy0yNTYtY2Jj" +
"IiwiZGF0YSI6InVSZnpMUEZFYzh5VDV3Q0ZiTDItSUE9PSIsIml2IjoiQ2tzUFhq" +
"Rlk1b29uMjJhNGsybWpuUT09Iiwic2lnbmF0dXJlIjoiMjc1MTNhY2U1ZTQwN2Y3" +
"NWFhOWJmZjJjMzIzOTc2OWM5YTFiOWQyMCJ9"
"IiwiZGF0YSI6IjZ4eGwxR3pmbzVXRUhnMUluVk5rZFE9PSIsIml2IjoiQ2tzUFhq" +
"Rlk1b29uMjJhNGsybWpuUT09Iiwic2lnbmF0dXJlIjoiNWFmOGIxYTA0Y2Y0MmIw" +
"MDZiZDY3ZjJjZTM2YTFjODcyN2I3MTJhMyJ9"
}

describe ".extract" do
Expand Down
4 changes: 2 additions & 2 deletions spec/decryptor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{
"type" => "EncryptedMessage",
"cipher" => "aes-256-cbc",
"data" => "P_2kgNhGBCu2WaF5lM3foW-tGdaJ3O_5tYSmhqg7rtI=",
"data" => "swfTPYQu9WYYhJAu00WIPrmrnmdcZI9928AHhGMetJg=",
"iv" => "CksPXjFY5oon22a4k2mjnQ==",
"signature" => "25efcdc87bae25dd0844a74db58462640d705f11",
"signature" => "6d5ad5e8132424a0e399294cd4ff6c0d357f5055",
}
}

Expand Down
4 changes: 2 additions & 2 deletions spec/encryptor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
{
"type" => "EncryptedMessage",
"cipher" => "aes-256-cbc",
"data" => "P_2kgNhGBCu2WaF5lM3foW-tGdaJ3O_5tYSmhqg7rtI=",
"data" => "swfTPYQu9WYYhJAu00WIPrmrnmdcZI9928AHhGMetJg=",
"iv" => "CksPXjFY5oon22a4k2mjnQ==",
"signature" => "25efcdc87bae25dd0844a74db58462640d705f11",
"signature" => "6d5ad5e8132424a0e399294cd4ff6c0d357f5055",
}
}

Expand Down
6 changes: 3 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

def stub_random_iv
before do
cipher = OpenSSL::Cipher::Cipher.new(ClaimToken.configuration.cipher_type)
cipher = OpenSSL::Cipher.new(ClaimToken.configuration.cipher_type)
allow(cipher).to receive(:random_iv).and_return("\nK\x0F^1X\xE6\x8A'\xDBf\xB8\x93i\xA3\x9D")
allow(OpenSSL::Cipher::Cipher).to receive(:new).and_return(cipher)
allow(OpenSSL::Cipher).to receive(:new).and_return(cipher)
end
end

def use_test_configuration
before do
ClaimToken.configure do |config|
config.shared_encryption_key = "uFeb25D_z0BAGhgH7WKy8QBSat6kxfDa6PrKw1ox69U="
config.shared_encryption_key = "fba0d989f259ad36ada12c127356d420"
config.digest_secret = "d22b90c9172649eaf49cd185f73bd4a53ec3ff4dc6f7d51f9dbaac62421e6dd297b38efcd431a7f2"
Copy link
Member

Choose a reason for hiding this comment

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

This key is still 64 bits long, no potential issue there ?

end
end
Expand Down