omniauth-apple 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of omniauth-apple might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +26 -0
- data/CHANGELOG.md +35 -0
- data/README.md +3 -1
- data/Rakefile +4 -0
- data/lib/omniauth/apple/version.rb +2 -2
- data/lib/omniauth/strategies/apple.rb +66 -21
- data/omniauth-apple.gemspec +5 -2
- metadata +52 -9
- data/.rakeTasks +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41d5662d5a5e982f5c81c143ea79beb20fcfaab848ec2c6bcfacb5b9495d3046
|
4
|
+
data.tar.gz: 6b7c3a2463cbc7587a782689cb515a5dbf046290033ec48ba06fc50025a98847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d14394af75cb4d4b0dc144a2b6bdae4937da6e82244e41c0ba8ee2aa2b11a1643de51e3021bde630f9d0a21a6ae452ffbe8ca229637f882ffd958cf771196b7e
|
7
|
+
data.tar.gz: 64774e5e62eb203c01e3a080f76e02463e64526722e6d036155d4b89ecf2ba2e80453320c5f128cf16192f263ce840e98121f0bd581c13d5ecf707968cb491b0
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: RSpec
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
ruby: ['2.5', '2.6', '2.7']
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
19
|
+
uses: actions/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
- name: Build and test with Rake on Ruby ${{ matrix.ruby }}
|
23
|
+
run: |
|
24
|
+
gem install bundler
|
25
|
+
bundle install --jobs 4 --retry 3
|
26
|
+
bundle exec rake spec
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
## [Unreleased]
|
2
|
+
|
3
|
+
## [1.0.0] - 2020-06-26
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- [#26](https://github.com/nhosoya/omniauth-apple/pull/26) Support ID Token verification
|
8
|
+
- [#40](https://github.com/nhosoya/omniauth-apple/pull/40) Add rspec test cases
|
9
|
+
- [#42](https://github.com/nhosoya/omniauth-apple/pull/42) [#43](https://github.com/nhosoya/omniauth-apple/pull/43) Setup CI
|
10
|
+
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
|
14
|
+
- [#31](https://github.com/nhosoya/omniauth-apple/pull/31) Stop relying on ActiveSupport
|
15
|
+
- [#37](https://github.com/nhosoya/omniauth-apple/pull/37) Fix nonce validation
|
16
|
+
- [#41](https://github.com/nhosoya/omniauth-apple/pull/41) Fix where the RoR extension is used
|
17
|
+
- [#46](https://github.com/nhosoya/omniauth-apple/pull/46) Fix naming of Omniauth module to OmniAuth
|
18
|
+
- [#48](https://github.com/nhosoya/omniauth-apple/pull/48) Remove .rakeTasks
|
19
|
+
|
20
|
+
|
21
|
+
### Changed
|
22
|
+
|
23
|
+
- [#27](https://github.com/nhosoya/omniauth-apple/pull/27) Update development dependency
|
24
|
+
- [#28](https://github.com/nhosoya/omniauth-apple/pull/28) Update README.md
|
25
|
+
- [#38](https://github.com/nhosoya/omniauth-apple/pull/38) Refine AuthHash
|
26
|
+
- [#39](https://github.com/nhosoya/omniauth-apple/pull/39) Set the default scope to 'email name'
|
27
|
+
|
28
|
+
## [0.0.3] - 2020-05-15
|
29
|
+
|
30
|
+
## [0.0.2] - 2020-01-16
|
31
|
+
|
32
|
+
## [0.0.1] - 2019-06-07
|
33
|
+
|
34
|
+
[Unreleased]: https://github.com/nhosoya/omniauth-apple/compare/v1.0.0...master
|
35
|
+
[1.0.0]: https://github.com/nhosoya/omniauth-apple/compare/v0.0.3...v1.0.0
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
![build](https://github.com/nhosoya/omniauth-apple/workflows/RSpec/badge.svg?branch=master&event=push)
|
2
|
+
|
1
3
|
# OmniAuth::Apple
|
2
4
|
|
3
5
|
OmniAuth strategy for [Sign In with Apple](https://developer.apple.com/sign-in-with-apple/).
|
@@ -7,7 +9,7 @@ OmniAuth strategy for [Sign In with Apple](https://developer.apple.com/sign-in-w
|
|
7
9
|
Add this line to your application's Gemfile:
|
8
10
|
|
9
11
|
```ruby
|
10
|
-
gem 'omniauth-apple'
|
12
|
+
gem 'omniauth-apple'
|
11
13
|
```
|
12
14
|
|
13
15
|
And then execute:
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'omniauth-oauth2'
|
4
|
+
require 'net/https'
|
4
5
|
|
5
6
|
module OmniAuth
|
6
7
|
module Strategies
|
@@ -12,57 +13,94 @@ module OmniAuth
|
|
12
13
|
authorize_url: '/auth/authorize',
|
13
14
|
token_url: '/auth/token'
|
14
15
|
option :authorize_params,
|
15
|
-
response_mode: 'form_post'
|
16
|
+
response_mode: 'form_post',
|
17
|
+
scope: 'email name'
|
16
18
|
option :authorized_client_ids, []
|
17
|
-
|
19
|
+
|
18
20
|
uid { id_info['sub'] }
|
19
21
|
|
20
22
|
info do
|
21
|
-
|
23
|
+
prune!(
|
22
24
|
sub: id_info['sub'],
|
23
25
|
email: email,
|
24
26
|
first_name: first_name,
|
25
|
-
last_name: last_name
|
26
|
-
|
27
|
+
last_name: last_name,
|
28
|
+
name: (first_name || last_name) ? [first_name, last_name].join(' ') : email,
|
29
|
+
)
|
27
30
|
end
|
28
31
|
|
29
32
|
extra do
|
30
|
-
|
31
|
-
|
32
|
-
}
|
33
|
+
id_token = request.params['id_token'] || access_token&.params&.dig('id_token')
|
34
|
+
prune!(raw_info: {id_info: id_info, user_info: user_info, id_token: id_token})
|
33
35
|
end
|
34
36
|
|
35
37
|
def client
|
36
38
|
::OAuth2::Client.new(client_id, client_secret, deep_symbolize(options.client_options))
|
37
39
|
end
|
38
40
|
|
41
|
+
def authorize_params
|
42
|
+
super.merge(nonce: new_nonce)
|
43
|
+
end
|
44
|
+
|
39
45
|
def callback_url
|
40
46
|
options[:redirect_uri] || (full_host + script_name + callback_path)
|
41
47
|
end
|
42
48
|
|
43
49
|
private
|
44
50
|
|
51
|
+
def new_nonce
|
52
|
+
session['omniauth.nonce'] = SecureRandom.urlsafe_base64(16)
|
53
|
+
end
|
54
|
+
|
55
|
+
def stored_nonce
|
56
|
+
session.delete('omniauth.nonce')
|
57
|
+
end
|
58
|
+
|
45
59
|
def id_info
|
46
|
-
if request.params&.key?('id_token') || access_token&.params&.key?('id_token')
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
60
|
+
@id_info ||= if request.params&.key?('id_token') || access_token&.params&.key?('id_token')
|
61
|
+
id_token = request.params['id_token'] || access_token.params['id_token']
|
62
|
+
jwt_options = {
|
63
|
+
verify_iss: true,
|
64
|
+
iss: 'https://appleid.apple.com',
|
65
|
+
verify_iat: true,
|
66
|
+
verify_aud: true,
|
67
|
+
aud: [options.client_id].concat(options.authorized_client_ids),
|
68
|
+
algorithms: ['RS256'],
|
69
|
+
jwks: fetch_jwks
|
70
|
+
}
|
71
|
+
payload, _header = ::JWT.decode(id_token, nil, true, jwt_options)
|
72
|
+
verify_nonce!(payload)
|
73
|
+
payload
|
74
|
+
end
|
51
75
|
end
|
52
76
|
|
53
|
-
def
|
54
|
-
|
55
|
-
|
56
|
-
|
77
|
+
def fetch_jwks
|
78
|
+
uri = URI.parse('https://appleid.apple.com/auth/keys')
|
79
|
+
response = Net::HTTP.get_response(uri)
|
80
|
+
JSON.parse(response.body, symbolize_names: true)
|
81
|
+
end
|
82
|
+
|
83
|
+
def verify_nonce!(payload)
|
84
|
+
return unless payload['nonce_supported']
|
85
|
+
|
86
|
+
return if payload['nonce'] && payload['nonce'] == stored_nonce
|
87
|
+
|
88
|
+
fail!(:nonce_mismatch, CallbackError.new(:nonce_mismatch, 'nonce mismatch'))
|
89
|
+
end
|
57
90
|
|
58
|
-
|
91
|
+
def client_id
|
92
|
+
@client_id ||= if id_info.nil?
|
93
|
+
options.client_id
|
94
|
+
else
|
95
|
+
id_info['aud'] if options.authorized_client_ids.include? id_info['aud']
|
96
|
+
end
|
59
97
|
end
|
60
98
|
|
61
99
|
def user_info
|
62
|
-
|
100
|
+
user = request.params['user']
|
101
|
+
return {} if user.nil?
|
63
102
|
|
64
|
-
|
65
|
-
@user_info ||= JSON.parse(request.params['user'])
|
103
|
+
@user_info ||= JSON.parse(user)
|
66
104
|
end
|
67
105
|
|
68
106
|
def email
|
@@ -77,6 +115,13 @@ module OmniAuth
|
|
77
115
|
user_info.dig('name', 'lastName')
|
78
116
|
end
|
79
117
|
|
118
|
+
def prune!(hash)
|
119
|
+
hash.delete_if do |_, v|
|
120
|
+
prune!(v) if v.is_a?(Hash)
|
121
|
+
v.nil? || (v.respond_to?(:empty?) && v.empty?)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
80
125
|
def client_secret
|
81
126
|
payload = {
|
82
127
|
iss: options.team_id,
|
data/omniauth-apple.gemspec
CHANGED
@@ -5,7 +5,7 @@ require "omniauth/apple/version"
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "omniauth-apple"
|
8
|
-
spec.version =
|
8
|
+
spec.version = OmniAuth::Apple::VERSION
|
9
9
|
spec.authors = ["nhosoya", "Fabian Jäger"]
|
10
10
|
spec.email = ["hnhnnhnh@gmail.com", "fabian@mailbutler.io"]
|
11
11
|
|
@@ -39,5 +39,8 @@ Gem::Specification.new do |spec|
|
|
39
39
|
spec.add_dependency 'omniauth-oauth2'
|
40
40
|
spec.add_dependency 'jwt'
|
41
41
|
spec.add_development_dependency "bundler", "~> 2.0"
|
42
|
-
spec.add_development_dependency "rake", "~>
|
42
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
43
|
+
spec.add_development_dependency "rspec", "~> 3.9"
|
44
|
+
spec.add_development_dependency "webmock", "~> 3.8"
|
45
|
+
spec.add_development_dependency 'simplecov', "~> 0.18"
|
43
46
|
end
|
metadata
CHANGED
@@ -1,15 +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: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nhosoya
|
8
8
|
- Fabian Jäger
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth-oauth2
|
@@ -59,14 +59,56 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '
|
62
|
+
version: '13.0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '
|
69
|
+
version: '13.0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.9'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.9'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: webmock
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.8'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.8'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: simplecov
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.18'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.18'
|
70
112
|
description: OmniAuth strategy for Sign In with Apple
|
71
113
|
email:
|
72
114
|
- hnhnnhnh@gmail.com
|
@@ -75,8 +117,9 @@ executables: []
|
|
75
117
|
extensions: []
|
76
118
|
extra_rdoc_files: []
|
77
119
|
files:
|
120
|
+
- ".github/workflows/rspec.yml"
|
78
121
|
- ".gitignore"
|
79
|
-
-
|
122
|
+
- CHANGELOG.md
|
80
123
|
- Gemfile
|
81
124
|
- LICENSE
|
82
125
|
- README.md
|
@@ -92,7 +135,7 @@ homepage: https://github.com/nhosoya/omniauth-apple
|
|
92
135
|
licenses:
|
93
136
|
- MIT
|
94
137
|
metadata: {}
|
95
|
-
post_install_message:
|
138
|
+
post_install_message:
|
96
139
|
rdoc_options: []
|
97
140
|
require_paths:
|
98
141
|
- lib
|
@@ -107,8 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
150
|
- !ruby/object:Gem::Version
|
108
151
|
version: '0'
|
109
152
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
111
|
-
signing_key:
|
153
|
+
rubygems_version: 3.1.2
|
154
|
+
signing_key:
|
112
155
|
specification_version: 4
|
113
156
|
summary: OmniAuth strategy for Sign In with Apple
|
114
157
|
test_files: []
|
data/.rakeTasks
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
-
You are allowed to:
|
4
|
-
1. Remove rake task
|
5
|
-
2. Add existing rake tasks
|
6
|
-
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
-
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|