sync_attr_with_auth0 0.2.0 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3b29ebf79d97e921bb5e8cb4f8faed85f37d626e6637a3ade34a4e551d7e005a
|
4
|
+
data.tar.gz: b1f528e810d6c6eb2eee5f2381f1ba1d337f1c83ced7c4ed63d795eb7fa8e804
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86e479e00c7f1e86cb2b02b8e1a3fc7b922e04d05cf750b1e233f39462cf2ae98e2d8810e6d706fc872bbd9a6704eb23ae3963b3eb4f42c581bb2d06f03d7c75
|
7
|
+
data.tar.gz: 1152e5d70a71e5e5cd4b208a6bafa39e788e6c4f03661aacd41d5497648008dcee15114bdf01f362f63a9be4472d73109be0f083f5bd40dd95bcd7ac0b354f5c
|
@@ -13,6 +13,7 @@ module SyncAttrWithAuth0
|
|
13
13
|
|
14
14
|
module ClassMethods
|
15
15
|
|
16
|
+
# TODO: We should accept two arrays of fields: user_metadata (for user-managed settings) and app_metadata (for app-managed settings)
|
16
17
|
def sync_attr_with_auth0(*fields)
|
17
18
|
options = fields.extract_options!
|
18
19
|
|
@@ -159,12 +160,8 @@ module SyncAttrWithAuth0
|
|
159
160
|
|
160
161
|
|
161
162
|
def auth0_app_metadata
|
162
|
-
|
163
|
-
|
164
|
-
'nickname' => auth0_user_name,
|
165
|
-
'given_name' => auth0_user_given_name,
|
166
|
-
'family_name' => auth0_user_family_name
|
167
|
-
}
|
163
|
+
# TODO: Source this from a separate attribute list.
|
164
|
+
return {}
|
168
165
|
end # auth0_app_metadata
|
169
166
|
|
170
167
|
|
@@ -94,7 +94,7 @@ module SyncAttrWithAuth0
|
|
94
94
|
def create_in_auth0
|
95
95
|
params = auth0_create_params
|
96
96
|
|
97
|
-
response = SyncAttrWithAuth0::Auth0.create_user(
|
97
|
+
response = SyncAttrWithAuth0::Auth0.create_user(params, config: auth0_sync_configuration)
|
98
98
|
|
99
99
|
# Update the record with the uid and picture after_commit
|
100
100
|
@auth0_uid = response['user_id']
|
@@ -105,10 +105,8 @@ module SyncAttrWithAuth0
|
|
105
105
|
def update_in_auth0(user_uid)
|
106
106
|
return unless user_uid
|
107
107
|
|
108
|
-
params = auth0_update_params
|
109
|
-
|
110
108
|
begin
|
111
|
-
response = SyncAttrWithAuth0::Auth0.patch_user(user_uid,
|
109
|
+
response = SyncAttrWithAuth0::Auth0.patch_user(user_uid, auth0_update_params(user_uid), config: auth0_sync_configuration)
|
112
110
|
|
113
111
|
# Update the record with the uid after_commit (in case it doesn't match what's on file).
|
114
112
|
@auth0_uid = user_uid
|
@@ -125,7 +123,7 @@ module SyncAttrWithAuth0
|
|
125
123
|
else
|
126
124
|
# The uid was incorrect, so re-attempt with the new uid
|
127
125
|
# and update the one on file.
|
128
|
-
response = SyncAttrWithAuth0::Auth0.patch_user(found_user['user_id'],
|
126
|
+
response = SyncAttrWithAuth0::Auth0.patch_user(found_user['user_id'], auth0_update_params(found_user['user_id']), config: auth0_sync_configuration)
|
129
127
|
|
130
128
|
# Update the record with the uid after_commit
|
131
129
|
@auth0_uid = found_user['user_id']
|
@@ -159,6 +157,10 @@ module SyncAttrWithAuth0
|
|
159
157
|
'password' => password,
|
160
158
|
'connection' => auth0_sync_configuration.connection_name,
|
161
159
|
'email_verified' => email_verified,
|
160
|
+
'name' => auth0_user_name,
|
161
|
+
'nickname' => auth0_user_name,
|
162
|
+
'given_name' => auth0_user_given_name,
|
163
|
+
'family_name' => auth0_user_family_name,
|
162
164
|
'user_metadata' => user_metadata,
|
163
165
|
'app_metadata' => app_metadata
|
164
166
|
}
|
@@ -167,15 +169,24 @@ module SyncAttrWithAuth0
|
|
167
169
|
end # auth0_create_params
|
168
170
|
|
169
171
|
|
170
|
-
def auth0_update_params
|
172
|
+
def auth0_update_params(user_uid)
|
171
173
|
user_metadata = auth0_user_metadata
|
172
174
|
app_metadata = auth0_app_metadata
|
175
|
+
is_auth0_connection_strategy = user_uid.start_with?("auth0|")
|
173
176
|
|
174
177
|
params = {
|
175
178
|
'app_metadata' => app_metadata,
|
176
179
|
'user_metadata' => user_metadata
|
177
180
|
}
|
178
181
|
|
182
|
+
if is_auth0_connection_strategy
|
183
|
+
# We can update the name attributes on Auth0 connection strategy only.
|
184
|
+
params['name'] = auth0_user_name
|
185
|
+
params['nickname'] = auth0_user_name
|
186
|
+
params['given_name'] = auth0_user_given_name
|
187
|
+
params['family_name'] = auth0_user_family_name
|
188
|
+
end
|
189
|
+
|
179
190
|
if auth0_user_saved_change_to_password?
|
180
191
|
# The password needs to be updated.
|
181
192
|
params['password'] = auth0_user_password
|
@@ -14,10 +14,10 @@ module SyncAttrWithAuth0
|
|
14
14
|
}
|
15
15
|
},
|
16
16
|
'iat' => Time.now.to_i,
|
17
|
-
'jti' => UUIDTools::UUID.
|
17
|
+
'jti' => UUIDTools::UUID.random_create.to_s
|
18
18
|
}
|
19
19
|
|
20
|
-
jwt = JWT.encode(payload, JWT.
|
20
|
+
jwt = JWT.encode(payload, JWT::Base64.url_decode(global_client_secret), 'HS256', { typ: 'JWT' })
|
21
21
|
|
22
22
|
return jwt
|
23
23
|
end # ::create_auth0_jwt
|
@@ -86,10 +86,9 @@ module SyncAttrWithAuth0
|
|
86
86
|
end # ::find_users_by_email
|
87
87
|
|
88
88
|
|
89
|
-
def self.create_user(
|
89
|
+
def self.create_user(params, config: SyncAttrWithAuth0.configuration)
|
90
90
|
auth0 = SyncAttrWithAuth0::Auth0.create_auth0_client(config: config)
|
91
|
-
|
92
|
-
return auth0.create_user(name, params)
|
91
|
+
return auth0.create_user(params.delete('connection'), params)
|
93
92
|
end # ::create_user
|
94
93
|
|
95
94
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sync_attr_with_auth0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick McGraw
|
8
8
|
- Mike Oliver
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2016-07-26 00:00:00.000000000 Z
|
@@ -87,28 +87,28 @@ dependencies:
|
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: 5.0.0
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
97
|
+
version: 5.0.0
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: jwt
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - "
|
102
|
+
- - ">="
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
104
|
+
version: 2.2.0
|
105
105
|
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- - "
|
109
|
+
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
111
|
+
version: 2.2.0
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: rails
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ homepage: http://rubygems.org/gems/sync_attr_with_auth0
|
|
154
154
|
licenses:
|
155
155
|
- MIT
|
156
156
|
metadata: {}
|
157
|
-
post_install_message:
|
157
|
+
post_install_message:
|
158
158
|
rdoc_options: []
|
159
159
|
require_paths:
|
160
160
|
- lib
|
@@ -169,9 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
|
-
|
173
|
-
|
174
|
-
signing_key:
|
172
|
+
rubygems_version: 3.0.6
|
173
|
+
signing_key:
|
175
174
|
specification_version: 4
|
176
175
|
summary: Synchronize attributes on a local ActiveRecord user model with the user metadata
|
177
176
|
store on Auth0
|