-
Notifications
You must be signed in to change notification settings - Fork 376
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
added algos/strategy classes + structs for inputs #230
Conversation
lib/jwt/signature.rb
Outdated
|
||
raise JWT::VerificationError, 'Algorithm not supported' if algo.nil? | ||
verified = algo.verify(ToVerify.new(algorithm, key, signing_input, signature)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
lib/jwt/signature.rb
Outdated
end | ||
def verify(algorithm, key, signing_input, signature) | ||
algo = ALGOS.find{|algo| | ||
algo.const_get(:SUPPORTED).include? algorithm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
lib/jwt/signature.rb
Outdated
algo.const_get(:SUPPORTED).include? algorithm | ||
} | ||
raise NotImplementedError, 'Unsupported signing method' if algo.nil? | ||
algo.sign ToSign.new(algorithm, msg, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
lib/jwt/signature.rb
Outdated
algo = ALGOS.find{|algo| | ||
algo.const_get(:SUPPORTED).include? algorithm | ||
} | ||
raise NotImplementedError, 'Unsupported signing method' if algo.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
lib/jwt/signature.rb
Outdated
end | ||
algo = ALGOS.find{|algo| | ||
algo.const_get(:SUPPORTED).include? algorithm | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
lib/jwt/algos/ecdsa.rb
Outdated
module JWT | ||
module Algos | ||
module Ecdsa | ||
extend self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use module_function
instead of extend self
.
lib/jwt/algos/ecdsa.rb
Outdated
SecurityUtils.asn1_to_raw(key.dsa_sign_asn1(digest.digest(msg)), key) | ||
end | ||
|
||
def verify to_verify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use def with parentheses when there are parameters.
lib/jwt/algos/ecdsa.rb
Outdated
'secp521r1' => 'ES512' | ||
}.freeze | ||
|
||
def sign to_sign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use def with parentheses when there are parameters.
lib/jwt/algos/eddsa.rb
Outdated
module JWT | ||
module Algos | ||
module Eddsa | ||
extend self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use module_function
instead of extend self
.
lib/jwt/algos/eddsa.rb
Outdated
key.sign(msg) | ||
end | ||
|
||
def verify to_verify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use def with parentheses when there are parameters.
lib/jwt/algos/eddsa.rb
Outdated
module_function | ||
SUPPORTED = %w(ED25519).freeze | ||
|
||
def sign to_sign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use def with parentheses when there are parameters.
module JWT | ||
module Algos | ||
module Rsa | ||
module_function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep a blank line after module_function
.
module JWT | ||
module Algos | ||
module Hmac | ||
module_function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep a blank line after module_function
.
lib/jwt/signature.rb
Outdated
end | ||
|
||
raise JWT::VerificationError, 'Algorithm not supported' if algo.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JWT::Signature#verify performs a nil-check
lib/jwt/algos/unsupported.rb
Outdated
def verify(*) | ||
raise JWT::VerificationError, 'Algorithm not supported' | ||
end | ||
def sign(*) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use empty lines between method definitions.
lib/jwt/algos/unsupported.rb
Outdated
module Unsupported | ||
module_function | ||
|
||
SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.
lib/jwt/algos/unsupported.rb
Outdated
module Unsupported | ||
module_function | ||
|
||
SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space missing inside }.
lib/jwt/algos/unsupported.rb
Outdated
module Unsupported | ||
module_function | ||
|
||
SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space missing to the left of {.
lib/jwt/algos/unsupported.rb
Outdated
module Unsupported | ||
module_function | ||
|
||
SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space missing to the left of {.
lib/jwt/algos/unsupported.rb
Outdated
module Unsupported | ||
module_function | ||
|
||
SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JWT::Algos::Unsupported has the variable name 'o'
Ebert has finished reviewing this Pull Request and has found:
You can see more details about this review at https://ebertapp.io/github/jwt/ruby-jwt/pulls/230. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. Great refactoring. 🥇
made changes discussed here: #229 , changes don't affect the public api.