Skip to content
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

fix nonce validation #37

Merged
merged 1 commit into from
Jun 18, 2020
Merged

fix nonce validation #37

merged 1 commit into from
Jun 18, 2020

Conversation

btalbot
Copy link
Contributor

@btalbot btalbot commented Jun 18, 2020

The payload argument passed to #verify_nonce! comes directly from JWT.decode which responds with a hash using string keys and not symbols. Other uses of id_info all correctly use string keys.

Without this change, the #verify_nonce! method always handles the payload as if 'nonce_supported' is falsy.

The `payload` argument passed to #verify_nonce! comes directly from JWT.decode which responds with a hash using string keys and not symbols.  Other uses of `id_info` all correctly use string keys.

Without this change, the #verify_nonce! method always handles the payload as if 'nonce_supported' is falsy.
@nhosoya nhosoya merged commit 88a39c8 into nhosoya:master Jun 18, 2020
@@ -76,13 +76,13 @@ def id_info
def fetch_jwks
uri = URI.parse('https://appleid.apple.com/auth/keys')
response = Net::HTTP.get_response(uri)
{ keys: JSON.parse(response.body)['keys'].map { |key| deep_symbolize(key) } }
JSON.parse(response.body, symbolize_names: true)
Copy link
Owner

Choose a reason for hiding this comment

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

It's simple and very good implementation.

@btalbot btalbot deleted the fix-verify-nonce branch June 19, 2020 02:59

return if payload[:nonce].present? && payload[:nonce] != stored_nonce
Copy link

Choose a reason for hiding this comment

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

@nhosoya @btalbot

before

payload[:nonce] != stored_nonce

after

payload['nonce'] == stored_nonce

expect payload nonce and stored_nonce match?
Is that the right change?

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.

3 participants