Class: NoPassword::OAuth::AppleAuthorizationsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Routable
Defined in:
app/controllers/nopassword/oauth/apple_authorizations_controller.rb

Overview

Constant Summary collapse

AUTHORIZATION_URL =
URI("https://appleid.apple.com/auth/authorize")
TOKEN_URL =
URI("https://appleid.apple.com/auth/token")
KEYS_URL =
URI("https://appleid.apple.com/auth/keys")

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.scopeObject



12
# File 'app/controllers/nopassword/oauth/apple_authorizations_controller.rb', line 12

def self.scope = "name email"

Instance Method Details

#callbackObject



32
33
34
35
36
37
38
# File 'app/controllers/nopassword/oauth/apple_authorizations_controller.rb', line 32

def callback
  # There's no session when the POST happens to this callback (thanks Apple and
  # strict cookies!), so we need to redirect to "show" to get the session back
  # and setup the user for success. Pass state through for CSRF validation.
  id_token = request_access_token.parse.fetch("id_token")
  redirect_to url_for(action: :show, id_token: id_token, state: params[:state])
end

#createObject



52
53
54
# File 'app/controllers/nopassword/oauth/apple_authorizations_controller.rb', line 52

def create
  redirect_to authorization_url.to_s, allow_other_host: true
end

#showObject



40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/nopassword/oauth/apple_authorizations_controller.rb', line 40

def show
   = decode_id_token params.fetch(:id_token)

  if .any?
    Rails.logger.info "Authorization #{self.class} succeeded"
    authorization_succeeded 
  else
    Rails.logger.info "Authorization #{self.class} failed"
    authorization_failed
  end
end