Class: NoPassword::OAuth::AppleAuthorizationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- NoPassword::OAuth::AppleAuthorizationsController
- Includes:
- Routable
- Defined in:
- app/controllers/nopassword/oauth/apple_authorizations_controller.rb
Overview
Implements OAuth flow as described at https://developer.apple.com/documentation/sign_in_with_apple/request_an_authorization_to_the_sign_in_with_apple_server Additional API documentation at:
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
.scope ⇒ Object
12 |
# File 'app/controllers/nopassword/oauth/apple_authorizations_controller.rb', line 12 def self.scope = "name email" |
Instance Method Details
#callback ⇒ Object
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 |
#create ⇒ Object
52 53 54 |
# File 'app/controllers/nopassword/oauth/apple_authorizations_controller.rb', line 52 def create redirect_to .to_s, allow_other_host: true end |
#show ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/nopassword/oauth/apple_authorizations_controller.rb', line 40 def show user_info = decode_id_token params.fetch(:id_token) if user_info.any? Rails.logger.info "Authorization #{self.class} succeeded" user_info else Rails.logger.info "Authorization #{self.class} failed" end end |