omniauth-apple 0.0.1 → 0.0.2
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.
Potentially problematic release.
This version of omniauth-apple might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +3 -2
- data/README.md +5 -2
- data/lib/{omniauth-apple → omniauth/apple}/version.rb +1 -1
- data/lib/omniauth/apple.rb +4 -0
- data/lib/omniauth/strategies/apple.rb +54 -23
- data/lib/omniauth-apple.rb +1 -2
- data/omniauth-apple.gemspec +4 -3
- metadata +21 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c485aae891ca049ae67179446bce1b1ec65386a9b7cbfdd965b7fde65fa688eb
|
4
|
+
data.tar.gz: ebbc624c1ebd90025579dc882c39717f65b7a1cc48cb81ac9e4557c6fd67d30b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77ac0078fd69ce3038de8e8096581364bc71d739cbba2ac2669a8ae64fa0d3612edbba1e066831625dee3f330eea83e18b7eb1e7778d0f5829a9f15459460ffe
|
7
|
+
data.tar.gz: a0f3692d3d130cf18f82941a93ca2bf925c909c58d8bc105791f3b9f2ea22f768ca61c23059d504f7d348751336b383001b51a24f58ddfd707c82fda174e8392
|
data/.gitignore
CHANGED
@@ -42,9 +42,10 @@ build-iPhoneSimulator/
|
|
42
42
|
|
43
43
|
# for a library or gem, you might want to ignore these files since the code is
|
44
44
|
# intended to run in multiple environments; otherwise, check them in:
|
45
|
-
|
46
|
-
|
45
|
+
Gemfile.lock
|
46
|
+
.ruby-version
|
47
47
|
# .ruby-gemset
|
48
48
|
|
49
49
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
50
|
.rvmrc
|
51
|
+
.idea
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ OmniAuth strategy for [Sign In with Apple](https://developer.apple.com/sign-in-w
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem 'omniauth-apple' github: 'nhosoya/omniauth-apple', branch: master
|
10
|
+
gem 'omniauth-apple', github: 'nhosoya/omniauth-apple', branch: 'master'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -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,23 +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
|
-
}
|
16
9
|
|
17
|
-
|
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'] }
|
18
18
|
|
19
19
|
info do
|
20
|
-
{
|
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
|
+
}
|
21
32
|
end
|
22
33
|
|
23
34
|
def client
|
@@ -25,27 +36,47 @@ module OmniAuth
|
|
25
36
|
end
|
26
37
|
|
27
38
|
def callback_url
|
28
|
-
full_host + script_name + callback_path
|
39
|
+
options[:redirect_uri] || (full_host + script_name + callback_path)
|
29
40
|
end
|
30
41
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
35
48
|
end
|
36
49
|
|
37
|
-
|
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
|
38
68
|
|
39
69
|
def client_secret
|
40
|
-
|
70
|
+
payload = {
|
41
71
|
iss: options.team_id,
|
42
72
|
aud: 'https://appleid.apple.com',
|
43
73
|
sub: options.client_id,
|
44
|
-
iat: Time.
|
45
|
-
exp:
|
46
|
-
|
47
|
-
|
48
|
-
|
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)
|
49
80
|
end
|
50
81
|
|
51
82
|
def private_key
|
data/lib/omniauth-apple.rb
CHANGED
data/omniauth-apple.gemspec
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
|
2
2
|
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "omniauth
|
4
|
+
require "omniauth/apple/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "omniauth-apple"
|
8
8
|
spec.version = Omniauth::Apple::VERSION
|
9
|
-
spec.authors = ["nhosoya"]
|
10
|
-
spec.email = ["hnhnnhnh@gmail.com"]
|
9
|
+
spec.authors = ["nhosoya", "Fabian Jäger"]
|
10
|
+
spec.email = ["hnhnnhnh@gmail.com", "fabian@mailbutler.io"]
|
11
11
|
|
12
12
|
spec.summary = %q{OmniAuth strategy for Sign In with Apple}
|
13
13
|
spec.description = %q{OmniAuth strategy for Sign In with Apple}
|
@@ -37,6 +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 'jwt'
|
40
41
|
spec.add_development_dependency "bundler", "~> 2.0"
|
41
42
|
spec.add_development_dependency "rake", "~> 10.0"
|
42
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-apple
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nhosoya
|
8
|
+
- Fabian Jäger
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2020-01-16 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: omniauth-oauth2
|
@@ -24,6 +25,20 @@ dependencies:
|
|
24
25
|
- - ">="
|
25
26
|
- !ruby/object:Gem::Version
|
26
27
|
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: jwt
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
27
42
|
- !ruby/object:Gem::Dependency
|
28
43
|
name: bundler
|
29
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,6 +70,7 @@ dependencies:
|
|
55
70
|
description: OmniAuth strategy for Sign In with Apple
|
56
71
|
email:
|
57
72
|
- hnhnnhnh@gmail.com
|
73
|
+
- fabian@mailbutler.io
|
58
74
|
executables: []
|
59
75
|
extensions: []
|
60
76
|
extra_rdoc_files: []
|
@@ -67,7 +83,8 @@ files:
|
|
67
83
|
- bin/console
|
68
84
|
- bin/setup
|
69
85
|
- lib/omniauth-apple.rb
|
70
|
-
- lib/omniauth
|
86
|
+
- lib/omniauth/apple.rb
|
87
|
+
- lib/omniauth/apple/version.rb
|
71
88
|
- lib/omniauth/strategies/apple.rb
|
72
89
|
- omniauth-apple.gemspec
|
73
90
|
homepage: https://github.com/nhosoya/omniauth-apple
|
@@ -89,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
106
|
- !ruby/object:Gem::Version
|
90
107
|
version: '0'
|
91
108
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
109
|
+
rubygems_version: 3.1.2
|
93
110
|
signing_key:
|
94
111
|
specification_version: 4
|
95
112
|
summary: OmniAuth strategy for Sign In with Apple
|