json_web_token 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/.travis.yml +5 -5
- data/CHANGELOG.md +17 -10
- data/Gemfile +1 -4
- data/LICENSE.md +9 -0
- data/README.md +26 -10
- data/Rakefile +10 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/json_web_token.gemspec +30 -15
- data/lib/json_web_token/version.rb +1 -1
- metadata +109 -31
- data/LICENSE +0 -21
- data/spec/fixtures/rsa/private_key.pem +0 -27
- data/spec/fixtures/rsa/private_key_weak.pem +0 -27
- data/spec/fixtures/rsa/public_key.pem +0 -9
- data/spec/fixtures/rsa/public_key_alt.pem +0 -9
- data/spec/json_web_token/algorithm/ecdsa_spec.rb +0 -56
- data/spec/json_web_token/algorithm/hmac_spec.rb +0 -127
- data/spec/json_web_token/algorithm/rsa_spec.rb +0 -126
- data/spec/json_web_token/format/asn1_spec.rb +0 -105
- data/spec/json_web_token/format/base64_url_spec.rb +0 -84
- data/spec/json_web_token/jwa_spec.rb +0 -71
- data/spec/json_web_token/jws_spec.rb +0 -119
- data/spec/json_web_token/jwt_spec.rb +0 -142
- data/spec/json_web_token/util_spec.rb +0 -24
- data/spec/json_web_token_spec.rb +0 -47
- data/spec/spec_helper.rb +0 -85
- data/spec/support/ecdsa_key.rb +0 -30
- data/spec/support/plausible_jwt.rb +0 -15
data/spec/spec_helper.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
SimpleCov.start
|
3
|
-
|
4
|
-
# Conventionally, all specs live under a `spec` directory, which RSpec adds to
|
5
|
-
# the `$LOAD_PATH`. The generated `.rspec` file contains `--require spec_helper`
|
6
|
-
# which will cause this file to always be loaded, without a need to explicitly
|
7
|
-
# require it in any files.
|
8
|
-
#
|
9
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
10
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
11
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
12
|
-
# individual file that may not need all of that loaded. Instead, consider
|
13
|
-
# making a separate helper file that requires the additional dependencies and
|
14
|
-
# performs the additional setup, and require it from the spec files that
|
15
|
-
# actually need it.
|
16
|
-
#
|
17
|
-
# The `.rspec` file also contains a few flags that are not defaults but that
|
18
|
-
# users commonly want.
|
19
|
-
#
|
20
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
21
|
-
RSpec.configure do |config|
|
22
|
-
config.expect_with :rspec do |expectations|
|
23
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
24
|
-
# and `failure_message` of custom matchers include text for helper methods
|
25
|
-
# defined using `chain`, e.g.:
|
26
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
27
|
-
# # => "be bigger than 2 and smaller than 4"
|
28
|
-
# ...rather than:
|
29
|
-
# # => "be bigger than 2"
|
30
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
31
|
-
end
|
32
|
-
|
33
|
-
config.mock_with :rspec do |mocks|
|
34
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
35
|
-
# a real object. This is generally recommended, and will default to
|
36
|
-
# `true` in RSpec 4.
|
37
|
-
mocks.verify_partial_doubles = true
|
38
|
-
end
|
39
|
-
|
40
|
-
# The settings below are suggested to provide a good initial experience
|
41
|
-
# with RSpec, but feel free to customize to your heart's content.
|
42
|
-
|
43
|
-
# These two settings work together to allow you to limit a spec run to
|
44
|
-
# individual examples or groups you care about by tagging them with `:focus`
|
45
|
-
# metadata. When nothing is tagged with `:focus`, all examples get run.
|
46
|
-
config.filter_run :focus
|
47
|
-
config.run_all_when_everything_filtered = true
|
48
|
-
|
49
|
-
# Allows RSpec to persist some state between runs in order to support the
|
50
|
-
# `--only-failures` and `--next-failure` CLI options. We recommend you
|
51
|
-
# configure your source control system to ignore this file.
|
52
|
-
config.example_status_persistence_file_path = "spec/examples.txt"
|
53
|
-
|
54
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
55
|
-
# recommended. For more details, see:
|
56
|
-
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
57
|
-
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
58
|
-
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
59
|
-
# config.disable_monkey_patching!
|
60
|
-
|
61
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
62
|
-
# file, and it's useful to allow more verbose output when running an
|
63
|
-
# individual spec file.
|
64
|
-
if config.files_to_run.one?
|
65
|
-
# Use the documentation formatter for detailed output, unless a formatter
|
66
|
-
# has already been configured (e.g. via a command-line flag)
|
67
|
-
config.default_formatter = 'doc'
|
68
|
-
end
|
69
|
-
|
70
|
-
# Print the 10 slowest examples and example groups at the end of the spec
|
71
|
-
# run, to help surface which specs are running particularly slowly.
|
72
|
-
# config.profile_examples = 10
|
73
|
-
|
74
|
-
# Run specs in random order to surface order dependencies. If you find an
|
75
|
-
# order dependency and want to debug it, you can fix the order by providing
|
76
|
-
# the seed, which is printed after each run.
|
77
|
-
# --seed 1234
|
78
|
-
config.order = :random
|
79
|
-
|
80
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
81
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
82
|
-
# test failures related to randomization by passing the same `--seed` value
|
83
|
-
# as the one that triggered the failure.
|
84
|
-
Kernel.srand config.seed
|
85
|
-
end
|
data/spec/support/ecdsa_key.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'openssl'
|
2
|
-
|
3
|
-
module EcdsaKey
|
4
|
-
|
5
|
-
BUILT_IN_CURVES = {
|
6
|
-
'256' => 'secp256k1',
|
7
|
-
'384' => 'secp384r1',
|
8
|
-
'512' => 'secp521r1'
|
9
|
-
}
|
10
|
-
|
11
|
-
module_function
|
12
|
-
|
13
|
-
def curve_new(sha_bits)
|
14
|
-
OpenSSL::PKey::EC.new(BUILT_IN_CURVES[sha_bits])
|
15
|
-
end
|
16
|
-
|
17
|
-
def public_key_str(curve, base = 16)
|
18
|
-
curve.generate_key unless curve.private_key
|
19
|
-
curve.public_key.to_bn.to_s(base)
|
20
|
-
end
|
21
|
-
|
22
|
-
def public_key_new(sha_bits, public_key_str, base = 16)
|
23
|
-
curve_name = BUILT_IN_CURVES[sha_bits]
|
24
|
-
fail('Unsupported curve') unless curve_name
|
25
|
-
group = OpenSSL::PKey::EC::Group.new(curve_name)
|
26
|
-
curve = OpenSSL::PKey::EC.new(group)
|
27
|
-
curve.public_key = OpenSSL::PKey::EC::Point.new(group, OpenSSL::BN.new(public_key_str, base))
|
28
|
-
curve
|
29
|
-
end
|
30
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'json_web_token/format/base64_url'
|
2
|
-
|
3
|
-
include JsonWebToken::Format::Base64Url
|
4
|
-
|
5
|
-
def plausible_message_signature?(str, bytesize = 32)
|
6
|
-
parts = str.split('.')
|
7
|
-
return false unless parts.length == 3
|
8
|
-
mac = decode(parts[2])
|
9
|
-
mac.bytesize == bytesize && mac.class == String
|
10
|
-
end
|
11
|
-
|
12
|
-
def plausible_unsecured_message?(str)
|
13
|
-
return false unless str.end_with?('.')
|
14
|
-
str.split('.').length == 2
|
15
|
-
end
|