standard_id 0.2.2 → 0.2.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/app/controllers/standard_id/api/oauth/callback/providers_controller.rb +3 -2
- data/lib/generators/standard_id/install/templates/standard_id.rb +1 -0
- data/lib/standard_id/config/schema.rb +1 -0
- data/lib/standard_id/oauth/social_flow.rb +20 -3
- data/lib/standard_id/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: b187dd81d274ace6321becb8a2be32bf28968ab27d845d698294ff2ec448ad53
|
|
4
|
+
data.tar.gz: 3deb68b18b7d5ad8a4075c303ebe03cf93fc0fd0a74b1ef399736688e62f35ab
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e64c713cd3861aba0ceb1f946d881effc025439807eb30e7ea373052c9890e077a654257e940e6379c7ae743a90fa8736ece2139bb92dd2b9a284b943c48ed2
|
|
7
|
+
data.tar.gz: c61fd9e8033cbbd91903e31933b3d1f0c77b34298a672e77b77af0478b3a64eec011674a1c21b3db5111f60277baf3a71357cd021c45eb2e1dba7222fe828e62
|
|
@@ -16,7 +16,8 @@ module StandardId
|
|
|
16
16
|
params,
|
|
17
17
|
request,
|
|
18
18
|
account:,
|
|
19
|
-
connection: provider.provider_name
|
|
19
|
+
connection: provider.provider_name,
|
|
20
|
+
scopes: params[:scope] || params[:scopes]
|
|
20
21
|
)
|
|
21
22
|
|
|
22
23
|
token_response = flow.execute
|
|
@@ -24,7 +25,7 @@ module StandardId
|
|
|
24
25
|
provider: provider.provider_name,
|
|
25
26
|
social_info:,
|
|
26
27
|
provider_tokens:,
|
|
27
|
-
account
|
|
28
|
+
account:,
|
|
28
29
|
)
|
|
29
30
|
render json: token_response, status: :ok
|
|
30
31
|
end
|
|
@@ -60,6 +60,7 @@ StandardId.configure do |c|
|
|
|
60
60
|
# c.social.apple_key_id = ENV["APPLE_KEY_ID"]
|
|
61
61
|
# c.social.apple_team_id = ENV["APPLE_TEAM_ID"]
|
|
62
62
|
# c.social.allowed_redirect_url_prefixes = ["sidekicklabs://"]
|
|
63
|
+
# c.social.available_scopes = ["profile", "email", "offline_access"]
|
|
63
64
|
# c.social.social_account_attributes = ->(social_info:, provider:) {
|
|
64
65
|
# {
|
|
65
66
|
# email: social_info[:email],
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
module StandardId
|
|
2
2
|
module Oauth
|
|
3
3
|
class SocialFlow < TokenGrantFlow
|
|
4
|
-
attr_reader :account, :connection, :
|
|
4
|
+
attr_reader :account, :connection, :scopes
|
|
5
5
|
|
|
6
|
-
def initialize(params, request, account:, connection:)
|
|
6
|
+
def initialize(params, request, account:, connection:, scopes:)
|
|
7
7
|
super(params, request)
|
|
8
8
|
@account = account
|
|
9
9
|
@connection = connection
|
|
10
|
+
@scopes = validate_and_normalize_scopes(scopes)
|
|
10
11
|
end
|
|
11
12
|
|
|
12
13
|
def authenticate!
|
|
@@ -24,7 +25,7 @@ module StandardId
|
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
def token_scope
|
|
27
|
-
|
|
28
|
+
scopes
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
def grant_type
|
|
@@ -51,6 +52,22 @@ module StandardId
|
|
|
51
52
|
base_payload = super(expires_in)
|
|
52
53
|
base_payload.merge(provider: @connection).compact
|
|
53
54
|
end
|
|
55
|
+
|
|
56
|
+
def validate_and_normalize_scopes(scopes)
|
|
57
|
+
return nil if scopes.blank?
|
|
58
|
+
|
|
59
|
+
available_scopes = StandardId.config.social.available_scopes
|
|
60
|
+
return scopes if available_scopes.blank?
|
|
61
|
+
|
|
62
|
+
requested_scopes = scopes.to_s.split(/\s+/).reject(&:blank?).uniq
|
|
63
|
+
invalid_scopes = requested_scopes - available_scopes.map(&:to_s)
|
|
64
|
+
|
|
65
|
+
if invalid_scopes.any?
|
|
66
|
+
raise StandardId::InvalidScopeError, "Invalid scope(s): #{invalid_scopes.join(', ')}. Available scopes: #{available_scopes.join(', ')}"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
requested_scopes.join(" ")
|
|
70
|
+
end
|
|
54
71
|
end
|
|
55
72
|
end
|
|
56
73
|
end
|
data/lib/standard_id/version.rb
CHANGED