auth0 3.1.2 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/auth0.gemspec +6 -5
  4. data/lib/auth0/api/authentication_endpoints.rb +19 -2
  5. data/lib/auth0/mixins/initializer.rb +3 -3
  6. data/lib/auth0/version.rb +1 -1
  7. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +20 -2
  8. data/spec/lib/auth0/client_spec.rb +1 -1
  9. data/spec/lib/auth0/mixins/initializer_spec.rb +28 -0
  10. metadata +44 -72
  11. data/doc/Auth0.html +0 -153
  12. data/doc/Auth0/AccessDenied.html +0 -142
  13. data/doc/Auth0/Api.html +0 -128
  14. data/doc/Auth0/Api/AuthenticationEndpoints.html +0 -592
  15. data/doc/Auth0/Api/V1.html +0 -188
  16. data/doc/Auth0/Api/V1/Clients.html +0 -440
  17. data/doc/Auth0/Api/V1/Connections.html +0 -506
  18. data/doc/Auth0/Api/V1/Logs.html +0 -366
  19. data/doc/Auth0/Api/V1/Rules.html +0 -439
  20. data/doc/Auth0/Api/V1/Users.html +0 -1617
  21. data/doc/Auth0/Api/V2.html +0 -193
  22. data/doc/Auth0/Api/V2/Blacklists.html +0 -268
  23. data/doc/Auth0/Api/V2/Clients.html +0 -477
  24. data/doc/Auth0/Api/V2/Jobs.html +0 -277
  25. data/doc/Auth0/Api/V2/Router.html +0 -109
  26. data/doc/Auth0/Api/V2/Stats.html +0 -268
  27. data/doc/Auth0/Api/V2/Users.html +0 -652
  28. data/doc/Auth0/BadRequest.html +0 -142
  29. data/doc/Auth0/Client.html +0 -164
  30. data/doc/Auth0/Exception.html +0 -140
  31. data/doc/Auth0/InvalidParameter.html +0 -142
  32. data/doc/Auth0/Mixins.html +0 -153
  33. data/doc/Auth0/Mixins/HTTPartyProxy.html +0 -121
  34. data/doc/Auth0/Mixins/Initializer.html +0 -312
  35. data/doc/Auth0/NotFound.html +0 -143
  36. data/doc/Auth0/ServerError.html +0 -142
  37. data/doc/Auth0/Unauthorized.html +0 -143
  38. data/doc/Auth0/Unsupported.html +0 -142
  39. data/doc/Auth0/UserIdIsBlank.html +0 -143
  40. data/doc/Auth0Client.html +0 -163
  41. data/doc/_index.html +0 -418
  42. data/doc/class_list.html +0 -58
  43. data/doc/css/common.css +0 -1
  44. data/doc/css/full_list.css +0 -57
  45. data/doc/css/style.css +0 -339
  46. data/doc/file.README.html +0 -103
  47. data/doc/file_list.html +0 -60
  48. data/doc/frames.html +0 -26
  49. data/doc/index.html +0 -103
  50. data/doc/js/app.js +0 -219
  51. data/doc/js/full_list.js +0 -181
  52. data/doc/js/jquery.js +0 -4
  53. data/doc/method_list.html +0 -435
  54. data/doc/top-level-namespace.html +0 -114
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e594e5861171575d73680a0f20920df385d52662
4
- data.tar.gz: 8fbf62cd33e4b2d3f036d9ff2b58deed509c3711
3
+ metadata.gz: c233d8f871a4045c4fcf32245bf4cab7f12ea1ea
4
+ data.tar.gz: 908f8c84e4ad3170363ec86e508323ebb2924d38
5
5
  SHA512:
6
- metadata.gz: 7f02c70e0108a902a8d36d1e4f6a1bcee4a170683b8aa4138253fd59c2e47661f15c4bd0914bad6de1696b622da6f0d81a635d761f6ee7f80c7a810e2051289f
7
- data.tar.gz: 501588a2bef940e3b194c77380faead69c5c940e360eb47babade99f6a5701d8cfa2c240d5731e6f664c2764b4282e5db6a3e7f5597bbd97e93a4edaf7e12a14
6
+ metadata.gz: a57726e22e787af7e128c2fb9fe59cb4873d84f9df9f05e1bfa315a3217243c75e743032d738f7a346ebbfe0f8e956f287059d85a57f4a0547979d838ad29f29
7
+ data.tar.gz: 20ca731787c59444212354b3f284400e9045b35aa64c15c2fb5ee4489c60d12fd48ad7cb41ad276f37bace8d2cf0fd869b248c8ecdfa15e4a1f293dc359111da
data/README.md CHANGED
@@ -29,7 +29,8 @@ require "auth0"
29
29
 
30
30
  auth0 = Auth0Client.new(
31
31
  :api_version => 2,
32
- :token => "YOUR JWT HERE"
32
+ :token => "YOUR JWT HERE",
33
+ :namespace => "<YOUR ACCOUNT>.auth0.com"
33
34
  );
34
35
 
35
36
  puts auth0.get_users;
data/auth0.gemspec CHANGED
@@ -22,11 +22,12 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.add_development_dependency 'rake'
24
24
  s.add_development_dependency 'rspec', '~> 3.1.0', '>= 3.1.0'
25
- s.add_development_dependency 'rack-test', '~> 0'
26
- s.add_development_dependency 'simplecov', '~> 0'
25
+ s.add_development_dependency 'rack-test'
26
+ s.add_development_dependency 'simplecov'
27
27
  s.add_development_dependency 'webmock'
28
- s.add_development_dependency 'byebug', '~> 0'
29
- s.add_development_dependency 'faker', '~> 0'
30
- s.add_development_dependency 'yard', '~> 0'
28
+ s.add_development_dependency 'byebug'
29
+ s.add_development_dependency 'faker'
30
+ s.add_development_dependency 'yard'
31
+ s.add_development_dependency 'gem-release'
31
32
  s.license = 'MIT'
32
33
  end
@@ -14,17 +14,34 @@ module Auth0
14
14
  end
15
15
 
16
16
  # {https://auth0.com/docs/auth-api#!#post--delegation}
17
- def delegation(id_token, target, scope = "open_id")
17
+ def delegation(id_token, target, scope = "openid", api_type = "app")
18
18
  request_params = {
19
19
  client_id: @client_id,
20
20
  grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
21
21
  id_token: id_token,
22
22
  target: target,
23
+ api_type: api_type,
23
24
  scope: scope
24
25
  }
25
26
  post("/delegation", request_params)
26
27
  end
27
28
 
29
+ # {https://auth0.com/docs/auth-api#!#post--users--user_id--impersonate}
30
+ def impersonate(user_id, app_client_id, impersonator_id, options)
31
+ request_params = {
32
+ protocol: options.fetch(:protocol, "oauth2"),
33
+ impersonator_id: impersonator_id,
34
+ client_id: app_client_id,
35
+ additionalParameters: {
36
+ response_type: options.fetch(:response_type, "code"),
37
+ state: options.fetch(:state, ""),
38
+ scope: options.fetch(:scope, "openid"),
39
+ callback_url: options.fetch(:callback_url, ""),
40
+ }
41
+ }
42
+ post("/users/#{user_id}/impersonate", request_params)
43
+ end
44
+
28
45
  # {https://auth0.com/docs/auth-api#!#post--oauth-ro}
29
46
  def login(username, password, scope = "openid", id_token=nil, connection_name="Username-Password-Authentication")
30
47
  request_params = {
@@ -33,7 +50,7 @@ module Auth0
33
50
  password: password,
34
51
  scope: scope,
35
52
  connection: connection_name,
36
- grand_type: "password",
53
+ grant_type: "password",
37
54
  id_token: id_token
38
55
  }
39
56
  post("/oauth/ro", request_params)
@@ -11,13 +11,13 @@ module Auth0
11
11
  options = Hash[config.map{|(k,v)| [k.to_sym,v]}]
12
12
  self.class.base_uri "https://#{options[:namespace]}"
13
13
  self.class.headers "Content-Type" => 'application/json'
14
+ self.extend Auth0::Api::AuthenticationEndpoints
15
+ @client_id = options[:client_id]
14
16
  if options[:protocols].to_s.include?("v2") or options[:api_version] === 2
15
17
  self.extend Auth0::Api::V2
16
- @token = options[:access_token] or options[:token]
18
+ @token = (options[:access_token] or options[:token])
17
19
  else
18
20
  self.extend Auth0::Api::V1
19
- self.extend Auth0::Api::AuthenticationEndpoints
20
- @client_id = options[:client_id]
21
21
  @client_secret = options[:client_secret]
22
22
  @token = obtain_access_token
23
23
  end
data/lib/auth0/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Auth0
2
2
  # current version of gem
3
- VERSION = "3.1.2"
3
+ VERSION = "3.2.0"
4
4
  end
@@ -19,15 +19,33 @@ describe Auth0::Api::AuthenticationEndpoints do
19
19
  context ".delegation" do
20
20
  it {expect(@instance).to respond_to(:delegation)}
21
21
  it "is expected to make post request to '/delegation'" do
22
- expect(@instance).to receive(:post).with("/delegation",{:client_id=>nil, :grant_type=>"urn:ietf:params:oauth:grant-type:jwt-bearer", :id_token=>"token", :target=>"target", :scope=>""})
22
+ expect(@instance).to receive(:post).with("/delegation",{:client_id=>nil, :grant_type=>"urn:ietf:params:oauth:grant-type:jwt-bearer", :id_token=>"token", :target=>"target", :scope=>"", api_type: "app"})
23
23
  @instance.delegation("token", "target", "")
24
24
  end
25
+ it "is expected to make post request to '/delegation' with specified api_type" do
26
+ expect(@instance).to receive(:post).with("/delegation",{:client_id=>nil, :grant_type=>"urn:ietf:params:oauth:grant-type:jwt-bearer",
27
+ :id_token=>"", :target=>"", :scope=>"",
28
+ api_type: "salesforce_api"})
29
+ @instance.delegation("", "", "", "salesforce_api")
30
+ end
31
+ end
32
+
33
+ context ".impersonate" do
34
+ let(:user_id) {"some_user_id"}
35
+ let(:app_client_id) {"some_app_client_id"}
36
+ let(:impersonator_id) {"some_impersonator_id"}
37
+
38
+ it {expect(@instance).to respond_to(:impersonate)}
39
+ it "is expected to make post request to '/users/{user_id}/impersonate'" do
40
+ expect(@instance).to receive(:post).with("/users/#{user_id}/impersonate",{:protocol=>"oauth2", :impersonator_id=>impersonator_id, :client_id=>app_client_id, :additionalParameters=>{:response_type=>"code", :state=>"", :scope=>"openid", :callback_url=>""}})
41
+ @instance.impersonate(user_id, app_client_id, impersonator_id, {})
42
+ end
25
43
  end
26
44
 
27
45
  context ".login" do
28
46
  it {expect(@instance).to respond_to(:signup)}
29
47
  it "is expected to make post to /oauth/ro" do
30
- expect(@instance).to receive(:post).with("/oauth/ro", {client_id: nil, username:"test@test.com", password: "password", connection: "Username-Password-Authentication", scope: "openid", grand_type: "password", id_token: nil})
48
+ expect(@instance).to receive(:post).with("/oauth/ro", {client_id: nil, username:"test@test.com", password: "password", connection: "Username-Password-Authentication", scope: "openid", grant_type: "password", id_token: nil})
31
49
  @instance.login("test@test.com", "password")
32
50
  end
33
51
  end
@@ -42,6 +42,6 @@ describe Auth0::Client do
42
42
  it {expect(subject).not_to be_a Auth0::Api::V1::Clients}
43
43
  it {expect(subject).not_to be_a Auth0::Api::V1::Rules}
44
44
  it {expect(subject).not_to be_a Auth0::Api::V1::Logs}
45
- it {expect(subject).not_to be_a Auth0::Api::AuthenticationEndpoints}
45
+ it {expect(subject).to be_a Auth0::Api::AuthenticationEndpoints}
46
46
  end
47
47
  end
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+ class MockClass
3
+ attr_reader :token
4
+ include Auth0::Mixins::Initializer
5
+ include HTTParty
6
+ end
7
+
8
+ describe Auth0::Mixins::Initializer do
9
+ let(:params) { { } }
10
+ let(:instance) { DummyClassForProxy.include(described_class).new(params) }
11
+ context 'api v2' do
12
+ before do
13
+ params[:api_version] = 2
14
+ end
15
+
16
+ it 'sets token when access_token is passed' do
17
+ params[:access_token] = '123'
18
+
19
+ expect(instance.instance_variable_get('@token')).to eq('123')
20
+ end
21
+
22
+ it 'sets token when token is passed' do
23
+ params[:token] = '123'
24
+
25
+ expect(instance.instance_variable_get('@token')).to eq('123')
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth0
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Auth0
@@ -11,138 +11,152 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-03-12 00:00:00.000000000 Z
14
+ date: 2015-04-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httparty
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - ~>
20
+ - - "~>"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0.13'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0.13'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rake
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0'
37
37
  type: :development
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: rspec
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ~>
48
+ - - "~>"
49
49
  - !ruby/object:Gem::Version
50
50
  version: 3.1.0
51
- - - '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: 3.1.0
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - ~>
58
+ - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: 3.1.0
61
- - - '>='
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
63
  version: 3.1.0
64
64
  - !ruby/object:Gem::Dependency
65
65
  name: rack-test
66
66
  requirement: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ~>
68
+ - - ">="
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ~>
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: simplecov
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ~>
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  type: :development
86
86
  prerelease: false
87
87
  version_requirements: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - ~>
89
+ - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: webmock
94
94
  requirement: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
101
  version_requirements: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - '>='
103
+ - - ">="
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  - !ruby/object:Gem::Dependency
107
107
  name: byebug
108
108
  requirement: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - ~>
110
+ - - ">="
111
111
  - !ruby/object:Gem::Version
112
112
  version: '0'
113
113
  type: :development
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ~>
117
+ - - ">="
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  - !ruby/object:Gem::Dependency
121
121
  name: faker
122
122
  requirement: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ~>
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  type: :development
128
128
  prerelease: false
129
129
  version_requirements: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ~>
131
+ - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  - !ruby/object:Gem::Dependency
135
135
  name: yard
136
136
  requirement: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ~>
138
+ - - ">="
139
139
  - !ruby/object:Gem::Version
140
140
  version: '0'
141
141
  type: :development
142
142
  prerelease: false
143
143
  version_requirements: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ~>
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ - !ruby/object:Gem::Dependency
149
+ name: gem-release
150
+ requirement: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ type: :development
156
+ prerelease: false
157
+ version_requirements: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
146
160
  - !ruby/object:Gem::Version
147
161
  version: '0'
148
162
  description: Ruby client library for the Auth0 API.
@@ -152,59 +166,15 @@ executables: []
152
166
  extensions: []
153
167
  extra_rdoc_files: []
154
168
  files:
155
- - .bundle/config
156
- - .gitignore
157
- - .rspec
158
- - .travis.yml
169
+ - ".bundle/config"
170
+ - ".gitignore"
171
+ - ".rspec"
172
+ - ".travis.yml"
159
173
  - Gemfile
160
174
  - LICENSE
161
175
  - README.md
162
176
  - Rakefile
163
177
  - auth0.gemspec
164
- - doc/Auth0.html
165
- - doc/Auth0/AccessDenied.html
166
- - doc/Auth0/Api.html
167
- - doc/Auth0/Api/AuthenticationEndpoints.html
168
- - doc/Auth0/Api/V1.html
169
- - doc/Auth0/Api/V1/Clients.html
170
- - doc/Auth0/Api/V1/Connections.html
171
- - doc/Auth0/Api/V1/Logs.html
172
- - doc/Auth0/Api/V1/Rules.html
173
- - doc/Auth0/Api/V1/Users.html
174
- - doc/Auth0/Api/V2.html
175
- - doc/Auth0/Api/V2/Blacklists.html
176
- - doc/Auth0/Api/V2/Clients.html
177
- - doc/Auth0/Api/V2/Jobs.html
178
- - doc/Auth0/Api/V2/Router.html
179
- - doc/Auth0/Api/V2/Stats.html
180
- - doc/Auth0/Api/V2/Users.html
181
- - doc/Auth0/BadRequest.html
182
- - doc/Auth0/Client.html
183
- - doc/Auth0/Exception.html
184
- - doc/Auth0/InvalidParameter.html
185
- - doc/Auth0/Mixins.html
186
- - doc/Auth0/Mixins/HTTPartyProxy.html
187
- - doc/Auth0/Mixins/Initializer.html
188
- - doc/Auth0/NotFound.html
189
- - doc/Auth0/ServerError.html
190
- - doc/Auth0/Unauthorized.html
191
- - doc/Auth0/Unsupported.html
192
- - doc/Auth0/UserIdIsBlank.html
193
- - doc/Auth0Client.html
194
- - doc/_index.html
195
- - doc/class_list.html
196
- - doc/css/common.css
197
- - doc/css/full_list.css
198
- - doc/css/style.css
199
- - doc/file.README.html
200
- - doc/file_list.html
201
- - doc/frames.html
202
- - doc/index.html
203
- - doc/js/app.js
204
- - doc/js/full_list.js
205
- - doc/js/jquery.js
206
- - doc/method_list.html
207
- - doc/top-level-namespace.html
208
178
  - lib/auth0.rb
209
179
  - lib/auth0/api/authentication_endpoints.rb
210
180
  - lib/auth0/api/v1.rb
@@ -239,6 +209,7 @@ files:
239
209
  - spec/lib/auth0/api/v2/users_spec.rb
240
210
  - spec/lib/auth0/client_spec.rb
241
211
  - spec/lib/auth0/mixins/httparty_proxy_spec.rb
212
+ - spec/lib/auth0/mixins/initializer_spec.rb
242
213
  - spec/lib/auth0_client_spec.rb
243
214
  - spec/spec_helper.rb
244
215
  - spec/support/dummy_class.rb
@@ -254,12 +225,12 @@ require_paths:
254
225
  - lib
255
226
  required_ruby_version: !ruby/object:Gem::Requirement
256
227
  requirements:
257
- - - '>='
228
+ - - ">="
258
229
  - !ruby/object:Gem::Version
259
230
  version: '0'
260
231
  required_rubygems_version: !ruby/object:Gem::Requirement
261
232
  requirements:
262
- - - '>='
233
+ - - ">="
263
234
  - !ruby/object:Gem::Version
264
235
  version: '0'
265
236
  requirements: []
@@ -282,6 +253,7 @@ test_files:
282
253
  - spec/lib/auth0/api/v2/users_spec.rb
283
254
  - spec/lib/auth0/client_spec.rb
284
255
  - spec/lib/auth0/mixins/httparty_proxy_spec.rb
256
+ - spec/lib/auth0/mixins/initializer_spec.rb
285
257
  - spec/lib/auth0_client_spec.rb
286
258
  - spec/spec_helper.rb
287
259
  - spec/support/dummy_class.rb