omniauth-apple-sau226 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +4 -1
- data/lib/omniauth/apple/sau226/version.rb +1 -1
- data/lib/omniauth/strategies/apple.rb +54 -24
- data/omniauth-apple-sau226.gemspec +6 -6
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5def05edbb741780cfd044218554788c7055c58354c6af327a7630793a3870bf
|
4
|
+
data.tar.gz: 6316e8050837aabeefcd1449dcbd427ac463b7b39189b9e07a06944218ed23f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39f36c82ffb8c65f8c4b2f2bf991db4957defcb2308beb24e44669283f6e8d9404e88defc31e4556114facd61aafe5eb40f98b9e11754c6787bd962ecf971d95
|
7
|
+
data.tar.gz: 99cf9f9758b942750dfc21695a9efa94c905814c6ad729c1eb9edc15033a61145fff5565a65e7474550744d7b0e61b983f0195d480e524ec1240136073bd8944
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -22,9 +22,12 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
25
|
-
provider :apple, ENV['CLIENT_ID'],
|
25
|
+
provider :apple, ENV['CLIENT_ID'], '',
|
26
26
|
{
|
27
27
|
scope: 'email name',
|
28
|
+
team_id: ENV['TEAM_ID'],
|
29
|
+
key_id: ENV['KEY_ID'],
|
30
|
+
pem: ENV['PRIVATE_KEY']
|
28
31
|
}
|
29
32
|
end
|
30
33
|
```
|
@@ -1,24 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'omniauth-oauth2'
|
2
4
|
|
3
5
|
module OmniAuth
|
4
6
|
module Strategies
|
5
7
|
class Apple < OmniAuth::Strategies::OAuth2
|
6
|
-
|
7
|
-
attr_reader :id_token
|
8
|
-
args %i[client_id team_id key_id pem]
|
9
|
-
|
10
8
|
option :name, 'apple'
|
11
|
-
option :client_options, {
|
12
|
-
site: 'https://appleid.apple.com',
|
13
|
-
authorize_url: '/auth/authorize',
|
14
|
-
token_url: '/auth/token',
|
15
|
-
response_mode: 'form_post',
|
16
|
-
}
|
17
9
|
|
18
|
-
|
10
|
+
option :client_options,
|
11
|
+
site: 'https://appleid.apple.com',
|
12
|
+
authorize_url: '/auth/authorize',
|
13
|
+
token_url: '/auth/token'
|
14
|
+
option :authorize_params,
|
15
|
+
response_mode: 'form_post'
|
16
|
+
|
17
|
+
uid { id_info['sub'] }
|
19
18
|
|
20
19
|
info do
|
21
|
-
{
|
20
|
+
{
|
21
|
+
sub: id_info['sub'],
|
22
|
+
email: email,
|
23
|
+
first_name: first_name,
|
24
|
+
last_name: last_name
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
extra do
|
29
|
+
{
|
30
|
+
raw_info: id_info.merge(user_info)
|
31
|
+
}
|
22
32
|
end
|
23
33
|
|
24
34
|
def client
|
@@ -26,27 +36,47 @@ module OmniAuth
|
|
26
36
|
end
|
27
37
|
|
28
38
|
def callback_url
|
29
|
-
full_host + script_name + callback_path
|
39
|
+
options[:redirect_uri] || (full_host + script_name + callback_path)
|
30
40
|
end
|
31
41
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
42
|
+
private
|
43
|
+
|
44
|
+
def id_info
|
45
|
+
id_token = request.params['id_token'] || access_token.params['id_token']
|
46
|
+
log(:info, "id_token: #{id_token}")
|
47
|
+
@id_info ||= ::JWT.decode(id_token, nil, false)[0] # payload after decoding
|
36
48
|
end
|
37
49
|
|
38
|
-
|
50
|
+
def user_info
|
51
|
+
return {} unless request.params['user'].present?
|
52
|
+
|
53
|
+
log(:info, "user_info: #{request.params['user']}")
|
54
|
+
@user_info ||= JSON.parse(request.params['user'])
|
55
|
+
end
|
56
|
+
|
57
|
+
def email
|
58
|
+
user_info['email'] || id_info['email']
|
59
|
+
end
|
60
|
+
|
61
|
+
def first_name
|
62
|
+
user_info.dig('name', 'firstName')
|
63
|
+
end
|
64
|
+
|
65
|
+
def last_name
|
66
|
+
user_info.dig('name', 'lastName')
|
67
|
+
end
|
39
68
|
|
40
69
|
def client_secret
|
41
|
-
|
70
|
+
payload = {
|
42
71
|
iss: options.team_id,
|
43
72
|
aud: 'https://appleid.apple.com',
|
44
73
|
sub: options.client_id,
|
45
|
-
iat:
|
46
|
-
exp: now + 60
|
47
|
-
|
48
|
-
|
49
|
-
|
74
|
+
iat: Time.now.to_i,
|
75
|
+
exp: Time.now.to_i + 60
|
76
|
+
}
|
77
|
+
headers = { kid: options.key_id }
|
78
|
+
|
79
|
+
::JWT.encode(payload, private_key, 'ES256', headers)
|
50
80
|
end
|
51
81
|
|
52
82
|
def private_key
|
@@ -6,12 +6,12 @@ require "omniauth/apple/sau226/version"
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "omniauth-apple-sau226"
|
8
8
|
spec.version = Omniauth::Apple::Sau226::VERSION
|
9
|
-
spec.authors = ["nhosoya", "sau226"]
|
10
|
-
spec.email = ["hnhnnhnh@gmail.com"]
|
9
|
+
spec.authors = ["nhosoya", "Fabian Jäger", "sau226"]
|
10
|
+
spec.email = ["hnhnnhnh@gmail.com", "fabian@mailbutler.io"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
14
|
-
spec.homepage = "https://github.com/
|
12
|
+
spec.summary = %q{sau226's custom build of omniauth-apple}
|
13
|
+
spec.description = %q{OmniAuth strategy for Sign In with Apple}
|
14
|
+
spec.homepage = "https://github.com/sau226dev/omniauth-apple"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.require_paths = ["lib"]
|
38
38
|
|
39
39
|
spec.add_dependency 'omniauth-oauth2'
|
40
|
-
spec.add_dependency '
|
40
|
+
spec.add_dependency 'jwt'
|
41
41
|
spec.add_development_dependency "bundler", "~> 2.0"
|
42
42
|
spec.add_development_dependency "rake", "~> 10.0"
|
43
43
|
end
|
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-apple-sau226
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nhosoya
|
8
|
+
- Fabian Jäger
|
8
9
|
- sau226
|
9
10
|
autorequire:
|
10
11
|
bindir: exe
|
@@ -26,7 +27,7 @@ dependencies:
|
|
26
27
|
- !ruby/object:Gem::Version
|
27
28
|
version: '0'
|
28
29
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
30
|
+
name: jwt
|
30
31
|
requirement: !ruby/object:Gem::Requirement
|
31
32
|
requirements:
|
32
33
|
- - ">="
|
@@ -67,9 +68,10 @@ dependencies:
|
|
67
68
|
- - "~>"
|
68
69
|
- !ruby/object:Gem::Version
|
69
70
|
version: '10.0'
|
70
|
-
description:
|
71
|
+
description: OmniAuth strategy for Sign In with Apple
|
71
72
|
email:
|
72
73
|
- hnhnnhnh@gmail.com
|
74
|
+
- fabian@mailbutler.io
|
73
75
|
executables: []
|
74
76
|
extensions: []
|
75
77
|
extra_rdoc_files: []
|
@@ -86,7 +88,7 @@ files:
|
|
86
88
|
- lib/omniauth/apple/sau226/version.rb
|
87
89
|
- lib/omniauth/strategies/apple.rb
|
88
90
|
- omniauth-apple-sau226.gemspec
|
89
|
-
homepage: https://github.com/
|
91
|
+
homepage: https://github.com/sau226dev/omniauth-apple
|
90
92
|
licenses:
|
91
93
|
- MIT
|
92
94
|
metadata: {}
|
@@ -108,5 +110,5 @@ requirements: []
|
|
108
110
|
rubygems_version: 3.1.2
|
109
111
|
signing_key:
|
110
112
|
specification_version: 4
|
111
|
-
summary:
|
113
|
+
summary: sau226's custom build of omniauth-apple
|
112
114
|
test_files: []
|