Skip to content

Commit 9617ef8

Browse files
committed
Remove deprecated algorithm functionality
1 parent 9a30b4e commit 9617ef8

File tree

13 files changed

+5
-170
lines changed

13 files changed

+5
-170
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Remove deprecated claim verification methods [#654](https://github.com/jwt/ruby-jwt/pull/654) ([@anakinj](https://github.com/anakinj))
1111
- Remove dependency to rbnacl [#655](https://github.com/jwt/ruby-jwt/pull/655) ([@anakinj](https://github.com/anakinj))
1212
- Support only stricter base64 decoding (RFC 4648) [#658](https://github.com/jwt/ruby-jwt/pull/658) ([@anakinj](https://github.com/anakinj))
13+
- Custom algorithms are required to include `JWT::JWA::SigningAlgorithm` [#660](https://github.com/jwt/ruby-jwt/pull/560) ([@anakinj](https://github.com/anakinj))
1314

1415
Take a look at the [upgrade guide](UPGRADING.md) for more details.
1516

lib/jwt.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
require 'jwt/json'
66
require 'jwt/decode'
77
require 'jwt/configuration'
8-
require 'jwt/deprecations'
98
require 'jwt/encode'
109
require 'jwt/error'
1110
require 'jwt/jwk'
@@ -44,8 +43,6 @@ def encode(payload, key, algorithm = 'HS256', header_fields = {})
4443
# @param options [Hash] additional options for decoding.
4544
# @return [Array<Hash>] the decoded payload and headers.
4645
def decode(jwt, key = nil, verify = true, options = {}, &keyfinder) # rubocop:disable Style/OptionalBooleanParameter
47-
Deprecations.context do
48-
Decode.new(jwt, key, verify, configuration.decode.to_h.merge(options), &keyfinder).decode_segments
49-
end
46+
Decode.new(jwt, key, verify, configuration.decode.to_h.merge(options), &keyfinder).decode_segments
5047
end
5148
end

lib/jwt/configuration/container.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def initialize
3030
def reset!
3131
@decode = DecodeConfiguration.new
3232
@jwk = JwkConfiguration.new
33-
@strict_base64_decoding = false
3433

3534
self.deprecation_warnings = :once
3635
end

lib/jwt/deprecations.rb

Lines changed: 0 additions & 49 deletions
This file was deleted.

lib/jwt/jwa.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
require 'openssl'
44

5-
require_relative 'jwa/compat'
65
require_relative 'jwa/signing_algorithm'
76
require_relative 'jwa/ecdsa'
87
require_relative 'jwa/hmac'
98
require_relative 'jwa/none'
109
require_relative 'jwa/ps'
1110
require_relative 'jwa/rsa'
1211
require_relative 'jwa/unsupported'
13-
require_relative 'jwa/wrapper'
1412

1513
module JWT
1614
# The JWA module contains all supported algorithms.
@@ -20,10 +18,7 @@ class << self
2018
def resolve(algorithm)
2119
return find(algorithm) if algorithm.is_a?(String) || algorithm.is_a?(Symbol)
2220

23-
unless algorithm.is_a?(SigningAlgorithm)
24-
Deprecations.warning('Custom algorithms are required to include JWT::JWA::SigningAlgorithm. Custom algorithms that do not include this module may stop working in the next major version of ruby-jwt.')
25-
return Wrapper.new(algorithm)
26-
end
21+
raise ArgumentError, 'Custom algorithms are required to include JWT::JWA::SigningAlgorithm' unless algorithm.is_a?(SigningAlgorithm)
2722

2823
algorithm
2924
end

lib/jwt/jwa/compat.rb

Lines changed: 0 additions & 32 deletions
This file was deleted.

lib/jwt/jwa/signing_algorithm.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def register_algorithm(algo)
1414

1515
def self.included(klass)
1616
klass.extend(ClassMethods)
17-
klass.include(JWT::JWA::Compat)
1817
end
1918

2019
attr_reader :alg

lib/jwt/jwa/wrapper.rb

Lines changed: 0 additions & 44 deletions
This file was deleted.

spec/jwt/jwa/ecdsa_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,4 @@
3131
end
3232
end
3333
end
34-
35-
context 'backwards compatibility' do
36-
it 'signs and verifies' do
37-
key = OpenSSL::PKey::EC.generate('prime256v1')
38-
signature = described_class.sign('ES256', 'data', key)
39-
expect(described_class.verify('ES256', key, 'data', signature)).to be(true)
40-
end
41-
end
4234
end

spec/jwt/jwa/hmac_spec.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,4 @@
125125
it { is_expected.to be(false) }
126126
end
127127
end
128-
129-
context 'backwards compatibility' do
130-
it 'signs and verifies' do
131-
signature = described_class.sign('HS256', 'data', 'key')
132-
expect(signature).to be_a(String)
133-
expect(described_class.verify('HS256', 'key', 'data', signature)).to be(true)
134-
end
135-
end
136128
end

0 commit comments

Comments
 (0)