sync_attr_with_auth0 0.2.8 → 0.2.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdf5a4a8368fa7335d28196d46835cee80aadf6d05f91ac63f9107fcaaa7c5f5
4
- data.tar.gz: e21784a081b09253de3252917f78c3cd0879f023f7344ffa158d45ccd0359cf7
3
+ metadata.gz: a48a0b5291c5f98b38c0594e1b98b5d062a4cc2b093286f9bf412af23f6eaf14
4
+ data.tar.gz: 8b502d146deada30410ddecf3461ef396b8439583c529105d22edfff5c2f0f93
5
5
  SHA512:
6
- metadata.gz: ebea0eec3ca9f5f26b2131ae6653d0f14754d024893492e7ba9ee40c5a06d94b2d59245f841a8f61c52dcd30c089ddea7c5512810e33cfe4111a423c6cb8e5cd
7
- data.tar.gz: e24bbed4725a05b7a506b290da5889edd1ba63e6d3af8086f06c4461e41a8996a391df0800dd323bbfb8392401aa54fb25418b59961648041834017109692ff5
6
+ metadata.gz: a888abb513aef90ff0fc6d2c511744445446e56d8fbbebe70296fbef5d6c26075ad52acb0b46cd7a7ff7d2cc502580f376da00e4c053e5d2f928508d61fc0f46
7
+ data.tar.gz: 481c026fb76261e0520c62d5a8db1a1b63a1fe7e2777daf71e27790ac94035ef7c117741304aec1562f9ecd868f2b17710731f52941c301ff6a3eeef5047b565
@@ -5,52 +5,27 @@ module SyncAttrWithAuth0
5
5
  require "auth0"
6
6
  require "uuidtools"
7
7
 
8
- def self.create_auth0_jwt(global_client_id: ENV['AUTH0_GLOBAL_CLIENT_ID'], global_client_secret: ENV['AUTH0_GLOBAL_CLIENT_SECRET'])
9
- payload = {
10
- 'aud' => global_client_id,
11
- 'scopes' => {
12
- 'users' => {
13
- 'actions' => ['create', 'update', 'read']
14
- }
15
- },
16
- 'iat' => Time.now.to_i,
17
- 'jti' => UUIDTools::UUID.random_create.to_s
18
- }
19
-
20
- jwt = JWT.encode(payload, JWT::Base64.url_decode(global_client_secret), 'RS256', { typ: 'JWT' })
21
-
22
- return jwt
23
- end # ::create_auth0_jwt
24
-
25
-
26
8
  def self.create_auth0_client(
27
9
  api_version: 2,
28
10
  config: SyncAttrWithAuth0.configuration
29
11
  )
30
12
  validate_auth0_config_for_api(api_version, config: config)
31
13
 
32
- case api_version
33
- when 1
34
- auth0 = Auth0Client.new(client_id: config.auth0_client_id, client_secret: config.auth0_client_secret, namespace: config.auth0_namespace)
35
- when 2
36
- jwt = SyncAttrWithAuth0::Auth0.create_auth0_jwt(global_client_id: config.auth0_global_client_id, global_client_secret: config.auth0_global_client_secret)
37
- auth0 = Auth0Client.new(api_version: 2, access_token: jwt, namespace: config.auth0_namespace)
38
- end
14
+ auth0 = Auth0Client.new(
15
+ client_id: config.auth0_client_id,
16
+ client_secret: config.auth0_client_secret,
17
+ domain: config.auth0_namespace
18
+ )
39
19
 
40
20
  return auth0
41
21
  end # ::create_auth0_client
42
22
 
43
23
 
44
- def self.validate_auth0_config_for_api(api_version, config: SyncAttrWithAuth0.configuration)
24
+ def self.validate_auth0_config_for_api(api_version=2, config: SyncAttrWithAuth0.configuration)
45
25
  settings_to_validate = []
46
26
  invalid_settings = []
47
27
 
48
- case api_version
49
- when 1
50
- settings_to_validate = [:auth0_client_id, :auth0_client_secret, :auth0_namespace]
51
- when 2
52
- settings_to_validate = [:auth0_global_client_id, :auth0_global_client_secret, :auth0_namespace]
53
- end
28
+ settings_to_validate = [:auth0_client_id, :auth0_client_secret, :auth0_namespace]
54
29
 
55
30
  settings_to_validate.each do |setting_name|
56
31
  unless config.send(setting_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sync_attr_with_auth0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick McGraw