Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
masayukioguni committed Dec 20, 2023
1 parent b42831b commit c653a63
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/omniauth/strategies/apple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,26 @@ def callback_url

private

# https://github.com/nhosoya/omniauth-apple/issues/103
# https://github.com/nhosoya/omniauth-apple/pull/106#issuecomment-1559825025
def new_nonce
session['omniauth.nonce'] = SecureRandom.urlsafe_base64(16)
Rails.logger.info("#{self.class.name}\##{__method__} new_nonce")
nonce = SecureRandom.urlsafe_base64(16)
session["omniauth.nonce"] = nonce
cookies.encrypted[:apple_auth_params] =
{ same_site: :none, expires: 1.hour.from_now, secure: true, value: nonce }
nonce
end

def stored_nonce
session.delete('omniauth.nonce')
Rails.logger.info("#{self.class.name}\##{__method__} stored_nonce")
nonce = session.delete("omniauth.nonce") || cookies.encrypted[:apple_auth_params]
cookies.delete :apple_auth_params
nonce
end

def cookies
request.env["action_dispatch.cookies"]
end

def id_info
Expand Down

0 comments on commit c653a63

Please sign in to comment.