added algos/strategy classes + structs for inputs#230
Conversation
| } | ||
|
|
||
| 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.
Trailing whitespace detected.
| 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.
Trailing whitespace detected.
| 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.
Trailing whitespace detected.
| 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.
Trailing whitespace detected.
| end | ||
| algo = ALGOS.find{|algo| | ||
| algo.const_get(:SUPPORTED).include? algorithm | ||
| } |
There was a problem hiding this comment.
Trailing whitespace detected.
| module JWT | ||
| module Algos | ||
| module Ecdsa | ||
| extend self |
There was a problem hiding this comment.
Use module_function instead of extend self.
| SecurityUtils.asn1_to_raw(key.dsa_sign_asn1(digest.digest(msg)), key) | ||
| end | ||
|
|
||
| def verify to_verify |
There was a problem hiding this comment.
Use def with parentheses when there are parameters.
| 'secp521r1' => 'ES512' | ||
| }.freeze | ||
|
|
||
| def sign to_sign |
There was a problem hiding this comment.
Use def with parentheses when there are parameters.
| module JWT | ||
| module Algos | ||
| module Eddsa | ||
| extend self |
There was a problem hiding this comment.
Use module_function instead of extend self.
| key.sign(msg) | ||
| end | ||
|
|
||
| def verify to_verify |
There was a problem hiding this comment.
Use def with parentheses when there are parameters.
| module_function | ||
| SUPPORTED = %w(ED25519).freeze | ||
|
|
||
| def sign to_sign |
There was a problem hiding this comment.
Use def with parentheses when there are parameters.
| module JWT | ||
| module Algos | ||
| module Rsa | ||
| module_function |
There was a problem hiding this comment.
Keep a blank line after module_function.
| module JWT | ||
| module Algos | ||
| module Hmac | ||
| module_function |
There was a problem hiding this comment.
Keep a blank line after module_function.
| alg.const_get(:SUPPORTED).include? algorithm | ||
| end | ||
|
|
||
| raise JWT::VerificationError, 'Algorithm not supported' if algo.nil? |
There was a problem hiding this comment.
JWT::Signature#verify performs a nil-check
| def verify(*) | ||
| raise JWT::VerificationError, 'Algorithm not supported' | ||
| end | ||
| def sign(*) |
There was a problem hiding this comment.
Use empty lines between method definitions.
| module Unsupported | ||
| module_function | ||
|
|
||
| SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
There was a problem hiding this comment.
Trailing whitespace detected.
| module Unsupported | ||
| module_function | ||
|
|
||
| SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
| module Unsupported | ||
| module_function | ||
|
|
||
| SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
There was a problem hiding this comment.
Space missing to the left of {.
| module Unsupported | ||
| module_function | ||
|
|
||
| SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
There was a problem hiding this comment.
Space missing to the left of {.
| module Unsupported | ||
| module_function | ||
|
|
||
| SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }} |
There was a problem hiding this comment.
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. |
excpt
left a comment
There was a problem hiding this comment.
Thank you very much. Great refactoring. 🥇
made changes discussed here: #229 , changes don't affect the public api.