standard_id-apple 0.1.0 → 0.1.1
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/README.md +5 -5
- data/lib/standard_id/apple/providers/apple.rb +13 -13
- data/lib/standard_id/apple/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 63120ccfea7a05fb35a42c90548f441a7d719aa3d5a46e0bb9d72ec97e1e5129
|
|
4
|
+
data.tar.gz: '0857aa7e1bbafae5621ce60aa2c3364b01931a836b8e0adc121b50bcfacf42af'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da5566c05904516299901bc7cbafb42e97c59c6bfb516959c8a2e77b55afd34f976e07c503ac94781681b972349c82519f4053d97004c7dea6967738ded0fe4a
|
|
7
|
+
data.tar.gz: 95da64b4f2c8deee61e18867133aa36d7ddea30985c276c266dcba0e8448712de8807c1040f224783621cb7319a998264c982ed0b96cb1e3b52a91447bfd1e0f
|
data/README.md
CHANGED
|
@@ -26,11 +26,11 @@ Configure Apple credentials via the StandardId configuration block:
|
|
|
26
26
|
|
|
27
27
|
```ruby
|
|
28
28
|
StandardId.configure do |config|
|
|
29
|
-
config.
|
|
30
|
-
config.
|
|
31
|
-
config.
|
|
32
|
-
config.
|
|
33
|
-
config.
|
|
29
|
+
config.apple_client_id = ENV["APPLE_CLIENT_ID"]
|
|
30
|
+
config.apple_mobile_client_id = ENV["APPLE_MOBILE_CLIENT_ID"] # optional
|
|
31
|
+
config.apple_team_id = ENV["APPLE_TEAM_ID"]
|
|
32
|
+
config.apple_key_id = ENV["APPLE_KEY_ID"]
|
|
33
|
+
config.apple_private_key = ENV["APPLE_PRIVATE_KEY_PEM"]
|
|
34
34
|
end
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -25,7 +25,7 @@ module StandardId
|
|
|
25
25
|
ensure_basic_credentials!
|
|
26
26
|
|
|
27
27
|
query = {
|
|
28
|
-
client_id: StandardId.config.
|
|
28
|
+
client_id: StandardId.config.apple_client_id,
|
|
29
29
|
redirect_uri: redirect_uri,
|
|
30
30
|
response_type: "code",
|
|
31
31
|
scope: scope,
|
|
@@ -37,7 +37,7 @@ module StandardId
|
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def get_user_info(code: nil, id_token: nil, access_token: nil, redirect_uri: nil, **options)
|
|
40
|
-
client_id = options[:client_id] || StandardId.config.
|
|
40
|
+
client_id = options[:client_id] || StandardId.config.apple_client_id
|
|
41
41
|
|
|
42
42
|
if id_token.present?
|
|
43
43
|
build_response(
|
|
@@ -77,12 +77,12 @@ module StandardId
|
|
|
77
77
|
|
|
78
78
|
def resolve_params(params, context: {})
|
|
79
79
|
flow = context[:flow] || :web
|
|
80
|
-
client_id = flow == :mobile ? StandardId.config.
|
|
80
|
+
client_id = flow == :mobile ? StandardId.config.apple_mobile_client_id : StandardId.config.apple_client_id
|
|
81
81
|
|
|
82
82
|
params.merge(client_id: client_id)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
def exchange_code_for_user_info(code:, redirect_uri:, client_id: StandardId.config.
|
|
85
|
+
def exchange_code_for_user_info(code:, redirect_uri:, client_id: StandardId.config.apple_client_id)
|
|
86
86
|
ensure_full_credentials!(client_id: client_id)
|
|
87
87
|
raise StandardId::InvalidRequestError, "Missing authorization code" if code.blank?
|
|
88
88
|
|
|
@@ -117,7 +117,7 @@ module StandardId
|
|
|
117
117
|
raise StandardId::OAuthError, e.message, cause: e
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
-
def verify_id_token(id_token:, client_id: StandardId.config.
|
|
120
|
+
def verify_id_token(id_token:, client_id: StandardId.config.apple_client_id)
|
|
121
121
|
raise StandardId::InvalidRequestError, "Missing id_token" if id_token.blank?
|
|
122
122
|
raise StandardId::InvalidRequestError, "Apple client_id is not configured" if client_id.blank?
|
|
123
123
|
|
|
@@ -155,7 +155,7 @@ module StandardId
|
|
|
155
155
|
|
|
156
156
|
private
|
|
157
157
|
|
|
158
|
-
def ensure_basic_credentials!(client_id: StandardId.config.
|
|
158
|
+
def ensure_basic_credentials!(client_id: StandardId.config.apple_client_id)
|
|
159
159
|
return if client_id.present?
|
|
160
160
|
|
|
161
161
|
raise StandardId::InvalidRequestError, "Apple OAuth is not configured"
|
|
@@ -165,9 +165,9 @@ module StandardId
|
|
|
165
165
|
ensure_basic_credentials!(client_id: client_id)
|
|
166
166
|
|
|
167
167
|
required = [
|
|
168
|
-
StandardId.config.
|
|
169
|
-
StandardId.config.
|
|
170
|
-
StandardId.config.
|
|
168
|
+
StandardId.config.apple_private_key,
|
|
169
|
+
StandardId.config.apple_key_id,
|
|
170
|
+
StandardId.config.apple_team_id
|
|
171
171
|
]
|
|
172
172
|
|
|
173
173
|
return unless required.any?(&:blank?)
|
|
@@ -175,21 +175,21 @@ module StandardId
|
|
|
175
175
|
raise StandardId::InvalidRequestError, "Apple OAuth credentials are incomplete"
|
|
176
176
|
end
|
|
177
177
|
|
|
178
|
-
def generate_client_secret(client_id: StandardId.config.
|
|
178
|
+
def generate_client_secret(client_id: StandardId.config.apple_client_id)
|
|
179
179
|
header = {
|
|
180
180
|
alg: "ES256",
|
|
181
|
-
kid: StandardId.config.
|
|
181
|
+
kid: StandardId.config.apple_key_id
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
payload = {
|
|
185
|
-
iss: StandardId.config.
|
|
185
|
+
iss: StandardId.config.apple_team_id,
|
|
186
186
|
iat: Time.current.to_i,
|
|
187
187
|
exp: Time.current.to_i + 3600,
|
|
188
188
|
aud: ISSUER,
|
|
189
189
|
sub: client_id
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
private_key = OpenSSL::PKey::EC.new(StandardId.config.
|
|
192
|
+
private_key = OpenSSL::PKey::EC.new(StandardId.config.apple_private_key)
|
|
193
193
|
JWT.encode(payload, private_key, "ES256", header)
|
|
194
194
|
end
|
|
195
195
|
|