Skip to content

added algos/strategy classes + structs for inputs#230

Merged
excpt merged 10 commits intojwt:masterfrom
ab320012:master
Sep 9, 2017
Merged

added algos/strategy classes + structs for inputs#230
excpt merged 10 commits intojwt:masterfrom
ab320012:master

Conversation

@ab320012
Copy link
Copy Markdown
Contributor

@ab320012 ab320012 commented Sep 7, 2017

made changes discussed here: #229 , changes don't affect the public api.

Comment thread lib/jwt/signature.rb Outdated
}

raise JWT::VerificationError, 'Algorithm not supported' if algo.nil?
verified = algo.verify(ToVerify.new(algorithm, key, signing_input, signature))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

Comment thread lib/jwt/signature.rb Outdated
end
def verify(algorithm, key, signing_input, signature)
algo = ALGOS.find{|algo|
algo.const_get(:SUPPORTED).include? algorithm
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

Comment thread 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

Comment thread lib/jwt/signature.rb Outdated
algo = ALGOS.find{|algo|
algo.const_get(:SUPPORTED).include? algorithm
}
raise NotImplementedError, 'Unsupported signing method' if algo.nil?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

Comment thread lib/jwt/signature.rb Outdated
end
algo = ALGOS.find{|algo|
algo.const_get(:SUPPORTED).include? algorithm
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

Comment thread lib/jwt/algos/ecdsa.rb Outdated
module JWT
module Algos
module Ecdsa
extend self
Copy link
Copy Markdown

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.

Comment thread lib/jwt/algos/ecdsa.rb Outdated
SecurityUtils.asn1_to_raw(key.dsa_sign_asn1(digest.digest(msg)), key)
end

def verify to_verify
Copy link
Copy Markdown

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.

Comment thread lib/jwt/algos/ecdsa.rb Outdated
'secp521r1' => 'ES512'
}.freeze

def sign to_sign
Copy link
Copy Markdown

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.

Comment thread lib/jwt/algos/eddsa.rb Outdated
module JWT
module Algos
module Eddsa
extend self
Copy link
Copy Markdown

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.

Comment thread lib/jwt/algos/eddsa.rb Outdated
key.sign(msg)
end

def verify to_verify
Copy link
Copy Markdown

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.

Comment thread lib/jwt/algos/eddsa.rb Outdated
module_function
SUPPORTED = %w(ED25519).freeze

def sign to_sign
Copy link
Copy Markdown

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.

Comment thread lib/jwt/algos/rsa.rb
module JWT
module Algos
module Rsa
module_function
Copy link
Copy Markdown

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.

Comment thread lib/jwt/algos/hmac.rb
module JWT
module Algos
module Hmac
module_function
Copy link
Copy Markdown

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.

Comment thread lib/jwt/signature.rb Outdated
alg.const_get(:SUPPORTED).include? algorithm
end

raise JWT::VerificationError, 'Algorithm not supported' if algo.nil?
Copy link
Copy Markdown

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

Read more about it here.

def verify(*)
raise JWT::VerificationError, 'Algorithm not supported'
end
def sign(*)
Copy link
Copy Markdown

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.

Comment thread lib/jwt/algos/unsupported.rb Outdated
module Unsupported
module_function

SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trailing whitespace detected.

Comment thread lib/jwt/algos/unsupported.rb Outdated
module Unsupported
module_function

SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Space missing inside }.

Comment thread lib/jwt/algos/unsupported.rb Outdated
module Unsupported
module_function

SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }}
Copy link
Copy Markdown

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 {.

Comment thread lib/jwt/algos/unsupported.rb Outdated
module Unsupported
module_function

SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }}
Copy link
Copy Markdown

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 {.

Comment thread lib/jwt/algos/unsupported.rb Outdated
module Unsupported
module_function

SUPPORTED = Object.new.tap{ |o| o.define_singleton_method(:include?){ |*| true }}
Copy link
Copy Markdown

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'

Read more about it here.

@sourcelevel-bot
Copy link
Copy Markdown

Ebert has finished reviewing this Pull Request and has found:

  • 14 fixed issues! 🎉

You can see more details about this review at https://ebertapp.io/github/jwt/ruby-jwt/pulls/230.

Copy link
Copy Markdown
Member

@excpt excpt left a 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. 🥇

@excpt excpt merged commit 51a162f into jwt:master Sep 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants