auth0 3.6.1 → 4.0.0
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/.gitignore +4 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +7 -0
- data/.travis.yml +12 -7
- data/CHANGELOG.md +10 -0
- data/Gemfile +4 -2
- data/Guardfile +13 -10
- data/LICENSE +2 -2
- data/README.md +9 -11
- data/Rakefile +33 -7
- data/auth0.gemspec +12 -12
- data/deploy_documentation.sh +29 -0
- data/doc_config/templates/default/fulldoc/html/css/full_list.css +79 -0
- data/doc_config/templates/default/fulldoc/html/css/style.css +546 -0
- data/doc_config/templates/default/layout/html/breadcrumb.erb +11 -0
- data/doc_config/templates/default/layout/html/footer.erb +115 -0
- data/doc_config/templates/default/layout/html/headers.erb +17 -0
- data/doc_config/templates/default/layout/html/layout.erb +27 -0
- data/lib/auth0.rb +5 -5
- data/lib/auth0/api/authentication_endpoints.rb +264 -46
- data/lib/auth0/api/v1.rb +5 -5
- data/lib/auth0/api/v1/clients.rb +7 -7
- data/lib/auth0/api/v1/connections.rb +9 -10
- data/lib/auth0/api/v1/logs.rb +9 -16
- data/lib/auth0/api/v1/rules.rb +5 -5
- data/lib/auth0/api/v1/users.rb +28 -27
- data/lib/auth0/api/v2.rb +17 -9
- data/lib/auth0/api/v2/blacklists.rb +30 -9
- data/lib/auth0/api/v2/clients.rb +60 -19
- data/lib/auth0/api/v2/connections.rb +63 -10
- data/lib/auth0/api/v2/emails.rb +58 -0
- data/lib/auth0/api/v2/jobs.rb +44 -7
- data/lib/auth0/api/v2/rules.rb +104 -0
- data/lib/auth0/api/v2/stats.rb +22 -5
- data/lib/auth0/api/v2/tenants.rb +39 -0
- data/lib/auth0/api/v2/tickets.rb +58 -0
- data/lib/auth0/api/v2/users.rb +128 -39
- data/lib/auth0/client.rb +8 -6
- data/lib/auth0/exception.rb +29 -23
- data/lib/auth0/mixins.rb +12 -10
- data/lib/auth0/mixins/httparty_proxy.rb +13 -10
- data/lib/auth0/mixins/initializer.rb +25 -27
- data/lib/auth0/version.rb +2 -2
- data/spec/integration/lib/auth0/api/v1/api_clients_spec.rb +2 -4
- data/spec/integration/lib/auth0/api/v1/api_users_spec.rb +25 -32
- data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +14 -0
- data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +61 -6
- data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +68 -42
- data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +71 -0
- data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +69 -0
- data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +83 -0
- data/spec/integration/lib/auth0/api/v2/api_stats_spec.rb +16 -0
- data/spec/integration/lib/auth0/api/v2/api_tenants_spec.rb +37 -0
- data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +33 -0
- data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +88 -36
- data/spec/integration/lib/auth0/auth0_client_spec.rb +43 -35
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +253 -47
- data/spec/lib/auth0/api/v1/clients_spec.rb +37 -38
- data/spec/lib/auth0/api/v1/connections_spec.rb +44 -38
- data/spec/lib/auth0/api/v1/logs_spec.rb +24 -24
- data/spec/lib/auth0/api/v1/rules_spec.rb +23 -22
- data/spec/lib/auth0/api/v1/users_spec.rb +153 -130
- data/spec/lib/auth0/api/v2/blacklists_spec.rb +12 -11
- data/spec/lib/auth0/api/v2/clients_spec.rb +38 -33
- data/spec/lib/auth0/api/v2/connections_spec.rb +59 -34
- data/spec/lib/auth0/api/v2/emails_spec.rb +47 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +24 -10
- data/spec/lib/auth0/api/v2/rules_spec.rb +69 -0
- data/spec/lib/auth0/api/v2/stats_spec.rb +11 -11
- data/spec/lib/auth0/api/v2/tenants_spec.rb +25 -0
- data/spec/lib/auth0/api/v2/tickets_spec.rb +31 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +101 -39
- data/spec/lib/auth0/client_spec.rb +46 -58
- data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +98 -69
- data/spec/lib/auth0/mixins/initializer_spec.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- data/spec/spec_helper_full.rb +16 -15
- data/spec/spec_helper_unit.rb +5 -5
- data/spec/support/credentials.rb +9 -3
- data/spec/support/dummy_class.rb +7 -1
- data/spec/support/dummy_class_for_proxy.rb +2 -2
- data/spec/support/import_users.json +13 -0
- data/spec/support/stub_response.rb +1 -2
- metadata +78 -41
data/lib/auth0/api/v1.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
1
|
+
require 'auth0/api/v1/users'
|
|
2
|
+
require 'auth0/api/v1/clients'
|
|
3
|
+
require 'auth0/api/v1/connections'
|
|
4
|
+
require 'auth0/api/v1/rules'
|
|
5
|
+
require 'auth0/api/v1/logs'
|
|
6
6
|
module Auth0
|
|
7
7
|
# Space for all API calls
|
|
8
8
|
module Api
|
data/lib/auth0/api/v1/clients.rb
CHANGED
|
@@ -5,15 +5,15 @@ module Auth0
|
|
|
5
5
|
module Clients
|
|
6
6
|
# {https://auth0.com/docs/api#!#get--api-clients}
|
|
7
7
|
def clients
|
|
8
|
-
path =
|
|
8
|
+
path = '/api/clients'
|
|
9
9
|
get(path)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
alias_method :get_clients, :clients
|
|
13
13
|
|
|
14
14
|
# {https://auth0.com/docs/api#!#post--api-clients}
|
|
15
|
-
def create_client(name, callbacks=
|
|
16
|
-
path =
|
|
15
|
+
def create_client(name, callbacks = '')
|
|
16
|
+
path = '/api/clients'
|
|
17
17
|
request_params = {
|
|
18
18
|
name: name,
|
|
19
19
|
callbacks: callbacks
|
|
@@ -23,8 +23,8 @@ module Auth0
|
|
|
23
23
|
|
|
24
24
|
# @deprecated use {#patch_client}
|
|
25
25
|
# {https://auth0.com/docs/api#!#put--api-clients--client-id-}
|
|
26
|
-
def update_client(name, callbacks=
|
|
27
|
-
warn
|
|
26
|
+
def update_client(name, callbacks = '', client_id = @client_id)
|
|
27
|
+
warn 'This endpoint has been deprecated in favor of PATCH.'
|
|
28
28
|
path = "/api/clients/#{client_id}"
|
|
29
29
|
request_params = {
|
|
30
30
|
name: name,
|
|
@@ -34,7 +34,7 @@ module Auth0
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
# {https://auth0.com/docs/api#!#patch--api-clients--client-id-}
|
|
37
|
-
def patch_client(name, callbacks=
|
|
37
|
+
def patch_client(name, callbacks = '', client_id = @client_id)
|
|
38
38
|
path = "/api/clients/#{client_id}"
|
|
39
39
|
request_params = {
|
|
40
40
|
name: name,
|
|
@@ -5,39 +5,38 @@ module Auth0
|
|
|
5
5
|
module Connections
|
|
6
6
|
# {https://auth0.com/docs/api#!#get--api-connections}
|
|
7
7
|
def connections
|
|
8
|
-
get(
|
|
8
|
+
get('/api/connections')
|
|
9
9
|
end
|
|
10
|
-
|
|
10
|
+
alias_method :get_connections, :connections
|
|
11
11
|
|
|
12
12
|
# {https://auth0.com/docs/api#!#get--api-connections--connection-name-}
|
|
13
13
|
def connection(connection_name)
|
|
14
|
-
path = "/api/connections/#{connection_name
|
|
14
|
+
path = "/api/connections/#{connection_name}"
|
|
15
15
|
get(path)
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
alias_method :get_connection, :connection
|
|
18
18
|
|
|
19
19
|
# {https://auth0.com/docs/api#!#delete--api-connections--connection-name-}
|
|
20
20
|
def delete_connection(connection_name)
|
|
21
|
-
path = "/api/connections/#{connection_name
|
|
21
|
+
path = "/api/connections/#{connection_name}"
|
|
22
22
|
delete(path)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
# {https://auth0.com/docs/api#!#post--api-connections}
|
|
26
|
-
def create_connection(connection_name, strategy, tenant_domain, domain_aliases=nil)
|
|
27
|
-
path =
|
|
26
|
+
def create_connection(connection_name, strategy, tenant_domain, domain_aliases = nil)
|
|
27
|
+
path = '/api/connections'
|
|
28
28
|
request_params = {
|
|
29
29
|
name: connection_name,
|
|
30
30
|
strategy: strategy,
|
|
31
31
|
options: {
|
|
32
32
|
tenant_domain: tenant_domain,
|
|
33
|
-
domain_aliases: domain_aliases
|
|
34
|
-
}
|
|
33
|
+
domain_aliases: domain_aliases }
|
|
35
34
|
}
|
|
36
35
|
post(path, request_params)
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
# {https://auth0.com/docs/api#!#put--api-connections--connection-name-}
|
|
40
|
-
def update_connection(connection_name, tenant_domain, status=true)
|
|
39
|
+
def update_connection(connection_name, tenant_domain, status = true)
|
|
41
40
|
path = "/api/connections/#{connection_name}"
|
|
42
41
|
request_params = {
|
|
43
42
|
status: status,
|
data/lib/auth0/api/v1/logs.rb
CHANGED
|
@@ -3,26 +3,19 @@ module Auth0
|
|
|
3
3
|
module V1
|
|
4
4
|
# {https://auth0.com/docs/api#logs}
|
|
5
5
|
module Logs
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
# {https://auth0.com/docs/api#!#get--api-logs-search--criteria-}
|
|
9
|
-
#
|
|
10
|
-
# {https://auth0.com/docs/api#!#get--api-logs-from--checkpointId--take--count-}
|
|
11
|
-
def logs(options={})
|
|
6
|
+
# https://auth0.com/docs/api/v1#!#logs
|
|
7
|
+
def logs(options = {})
|
|
12
8
|
acceptable_params = %i(take from search_criteria page per_page sort fields exclude_fields)
|
|
13
|
-
options.reject! do |key,value|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
warn "#{key} is not in acceptable params list: #{acceptable_params}"
|
|
18
|
-
true
|
|
19
|
-
end
|
|
9
|
+
options.reject! do |key, value|
|
|
10
|
+
next unless key.nil? || value.nil? || !acceptable_params.include?(key.to_sym)
|
|
11
|
+
warn "#{key} is not in acceptable params list: #{acceptable_params}"
|
|
12
|
+
true
|
|
20
13
|
end
|
|
21
|
-
path= "/api/logs
|
|
14
|
+
path = "/api/logs?#{URI.encode_www_form(options)}"
|
|
22
15
|
get(path)
|
|
23
16
|
end
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
alias_method :search_logs, :logs
|
|
26
19
|
|
|
27
20
|
# {https://auth0.com/docs/api#!#get--api-logs--_id-}
|
|
28
21
|
def log(id)
|
|
@@ -31,7 +24,7 @@ module Auth0
|
|
|
31
24
|
end
|
|
32
25
|
|
|
33
26
|
# {https://auth0.com/docs/api#!#get--api-users--user_id--logs-page--number--per_page--items-}
|
|
34
|
-
def user_logs(user_id, page=0, per_page=50)
|
|
27
|
+
def user_logs(user_id, page = 0, per_page = 50)
|
|
35
28
|
path = "/api/users/#{user_id}/logs?page=#{page}&per_page=#{per_page}"
|
|
36
29
|
get(path)
|
|
37
30
|
end
|
data/lib/auth0/api/v1/rules.rb
CHANGED
|
@@ -5,15 +5,15 @@ module Auth0
|
|
|
5
5
|
module Rules
|
|
6
6
|
# https://auth0.com/docs/api#!#get--api-rules
|
|
7
7
|
def rules
|
|
8
|
-
path =
|
|
8
|
+
path = '/api/rules'
|
|
9
9
|
get(path)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
alias_method :get_rules, :rules
|
|
13
13
|
|
|
14
14
|
# https://auth0.com/docs/api#!#post--api-rules
|
|
15
|
-
def create_rule(name, script, order=nil,status=true)
|
|
16
|
-
path =
|
|
15
|
+
def create_rule(name, script, order = nil, status = true)
|
|
16
|
+
path = '/api/rules'
|
|
17
17
|
request_params = {
|
|
18
18
|
name: name,
|
|
19
19
|
status: status,
|
|
@@ -24,7 +24,7 @@ module Auth0
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
# https://auth0.com/docs/api#!#put--api-rules--rule-name-
|
|
27
|
-
def update_rule(name, script, order=nil,status=true)
|
|
27
|
+
def update_rule(name, script, order = nil, status = true)
|
|
28
28
|
path = "/api/rules/#{name}"
|
|
29
29
|
request_params = {
|
|
30
30
|
status: status,
|
data/lib/auth0/api/v1/users.rb
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
module Auth0
|
|
2
2
|
module Api
|
|
3
|
+
# rubocop:disable Metrics/ModuleLength
|
|
3
4
|
module V1
|
|
4
5
|
# {https://auth0.com/docs/api#users}
|
|
5
6
|
module Users
|
|
6
7
|
# {https://auth0.com/docs/api#!#get--api-users}
|
|
7
8
|
#
|
|
8
9
|
# {https://auth0.com/docs/api#!#get--api-users-search--criteria-}
|
|
9
|
-
def users(search=nil)
|
|
10
|
-
path =
|
|
11
|
-
path += "?search=#{search
|
|
10
|
+
def users(search = nil)
|
|
11
|
+
path = '/api/users'
|
|
12
|
+
path += "?search=#{search}" unless search.to_s.empty?
|
|
12
13
|
get(path)
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
alias_method :users_search, :users
|
|
17
|
+
alias_method :get_users, :users
|
|
17
18
|
|
|
18
19
|
# {https://auth0.com/docs/api#!#get--api-users--user_id-}
|
|
19
20
|
def user(user_id)
|
|
@@ -21,7 +22,7 @@ module Auth0
|
|
|
21
22
|
get(path)
|
|
22
23
|
end
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
alias_method :get_user, :user
|
|
25
26
|
|
|
26
27
|
# {https://auth0.com/docs/api#!#get--api-users--user_id--devices}
|
|
27
28
|
def user_devices(user_id)
|
|
@@ -31,37 +32,37 @@ module Auth0
|
|
|
31
32
|
|
|
32
33
|
# {https://auth0.com/docs/api#!#get--api-connections--connection--users}
|
|
33
34
|
# {https://auth0.com/docs/api#!#get--api-connections--connection--users-search--criteria-}
|
|
34
|
-
def connection_users(connection_name, search=nil)
|
|
35
|
+
def connection_users(connection_name, search = nil)
|
|
35
36
|
path = "/api/connections/#{connection_name}/users"
|
|
36
|
-
path += "?search=#{search
|
|
37
|
+
path += "?search=#{search}" unless search.to_s.empty?
|
|
37
38
|
get(path)
|
|
38
39
|
end
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
alias_method :search_connection_users, :connection_users
|
|
41
42
|
|
|
42
43
|
# {https://auth0.com/docs/api#!#get--api-enterpriseconnections-users-search--criteria-}
|
|
43
|
-
def enterpriseconnections_users(search_criteria=nil, per_page=500)
|
|
44
|
-
path = "/api/enterpriseconnections/users?search=#{search_criteria
|
|
44
|
+
def enterpriseconnections_users(search_criteria = nil, per_page = 500)
|
|
45
|
+
path = "/api/enterpriseconnections/users?search=#{search_criteria}&per_page=#{per_page.to_i}"
|
|
45
46
|
get(path)
|
|
46
47
|
end
|
|
47
48
|
|
|
48
49
|
# {https://auth0.com/docs/api#!#get--api-socialconnections-users-search--criteria-}
|
|
49
|
-
def socialconnections_users(search_criteria=nil, per_page=500)
|
|
50
|
-
path =
|
|
50
|
+
def socialconnections_users(search_criteria = nil, per_page = 500)
|
|
51
|
+
path = "/api/socialconnections/users?search=#{search_criteria}&per_page=#{per_page.to_i}"
|
|
51
52
|
get(path)
|
|
52
53
|
end
|
|
53
54
|
|
|
54
55
|
# {https://auth0.com/docs/api#!#get--api-clients--client-id--users}
|
|
55
|
-
def client_users(client_id
|
|
56
|
+
def client_users(client_id = @client_id)
|
|
56
57
|
path = "/api/clients/#{client_id}/users"
|
|
57
58
|
get(path)
|
|
58
59
|
end
|
|
59
60
|
|
|
60
61
|
# {https://auth0.com/docs/api#!#post--api-users}
|
|
61
|
-
def create_user(email, password, connection_name, request_params={})
|
|
62
|
+
def create_user(email, password, connection_name, request_params = {})
|
|
62
63
|
options = { email: email, password: password, connection: connection_name }
|
|
63
64
|
request_params.merge!(options)
|
|
64
|
-
path =
|
|
65
|
+
path = '/api/users'
|
|
65
66
|
post(path, request_params)
|
|
66
67
|
end
|
|
67
68
|
|
|
@@ -72,15 +73,15 @@ module Auth0
|
|
|
72
73
|
end
|
|
73
74
|
|
|
74
75
|
# {https://auth0.com/docs/api#!#post--api-users--user_id--change_password_ticket}
|
|
75
|
-
def change_password_ticket(user_id, new_password, result_url=nil)
|
|
76
|
-
request_params = {
|
|
76
|
+
def change_password_ticket(user_id, new_password, result_url = nil)
|
|
77
|
+
request_params = { 'newPassword' => new_password, 'resultUrl' => result_url }
|
|
77
78
|
path = "/api/users/#{user_id}/change_password_ticket"
|
|
78
79
|
post(path, request_params)
|
|
79
80
|
end
|
|
80
81
|
|
|
81
82
|
# {https://auth0.com/docs/api#!#post--api-users--user_id--verification_ticket}
|
|
82
|
-
def verification_ticket(user_id, result_url=nil)
|
|
83
|
-
request_params = {
|
|
83
|
+
def verification_ticket(user_id, result_url = nil)
|
|
84
|
+
request_params = { 'resultUrl' => result_url }
|
|
84
85
|
path = "/api/users/#{user_id}/verification_ticket"
|
|
85
86
|
post(path, request_params)
|
|
86
87
|
end
|
|
@@ -93,7 +94,7 @@ module Auth0
|
|
|
93
94
|
end
|
|
94
95
|
|
|
95
96
|
# {https://auth0.com/docs/api#!#put--api-users--user_id--email}
|
|
96
|
-
def update_user_email(user_id, email, verify=true)
|
|
97
|
+
def update_user_email(user_id, email, verify = true)
|
|
97
98
|
path = "/api/users/#{user_id}/email"
|
|
98
99
|
request_params = { email: email, verify: verify }
|
|
99
100
|
put(path, request_params)
|
|
@@ -101,20 +102,20 @@ module Auth0
|
|
|
101
102
|
|
|
102
103
|
# {https://auth0.com/docs/api#!#put--api-users--user_id--metadata}
|
|
103
104
|
# This will overwrite user's metadata, be really carefull, preffer using patch instead
|
|
104
|
-
def update_user_metadata(user_id, metadata={})
|
|
105
|
+
def update_user_metadata(user_id, metadata = {})
|
|
105
106
|
path = "/api/users/#{user_id}/metadata"
|
|
106
107
|
put(path, metadata)
|
|
107
108
|
end
|
|
108
109
|
|
|
109
110
|
# {https://auth0.com/docs/api#!#put--api-users--user_id--password}
|
|
110
|
-
def update_user_password(user_id, password, verify=true)
|
|
111
|
+
def update_user_password(user_id, password, verify = true)
|
|
111
112
|
path = "/api/users/#{user_id}/password"
|
|
112
113
|
request_params = { password: password, verify: verify }
|
|
113
114
|
put(path, request_params)
|
|
114
115
|
end
|
|
115
116
|
|
|
116
117
|
# {https://auth0.com/docs/api#!#put--api-users--email--password}
|
|
117
|
-
def update_user_password_using_email(email, password, connection_name, verify=true)
|
|
118
|
+
def update_user_password_using_email(email, password, connection_name, verify = true)
|
|
118
119
|
request_params = {
|
|
119
120
|
email: email,
|
|
120
121
|
password: password,
|
|
@@ -126,7 +127,7 @@ module Auth0
|
|
|
126
127
|
end
|
|
127
128
|
|
|
128
129
|
# {https://auth0.com/docs/api#!#patch--api-users--user_id--metadata}
|
|
129
|
-
def patch_user_metadata(user_id, metadata={})
|
|
130
|
+
def patch_user_metadata(user_id, metadata = {})
|
|
130
131
|
path = "/api/users/#{user_id}/metadata"
|
|
131
132
|
patch(path, metadata)
|
|
132
133
|
end
|
|
@@ -135,13 +136,13 @@ module Auth0
|
|
|
135
136
|
#
|
|
136
137
|
# This will remove all your users
|
|
137
138
|
def delete_users
|
|
138
|
-
path =
|
|
139
|
+
path = '/api/users/'
|
|
139
140
|
delete(path)
|
|
140
141
|
end
|
|
141
142
|
|
|
142
143
|
# {https://auth0.com/docs/api#!#delete--api-users--user_id-}
|
|
143
144
|
def delete_user(user_id)
|
|
144
|
-
|
|
145
|
+
fail Auth0::MissingUserId, 'if you want to remove all users use delete_users method' if user_id.to_s.empty?
|
|
145
146
|
path = "/api/users/#{user_id}"
|
|
146
147
|
delete(path)
|
|
147
148
|
end
|
data/lib/auth0/api/v2.rb
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
1
|
+
require 'auth0/api/v2/blacklists'
|
|
2
|
+
require 'auth0/api/v2/clients'
|
|
3
|
+
require 'auth0/api/v2/connections'
|
|
4
|
+
require 'auth0/api/v2/emails'
|
|
5
|
+
require 'auth0/api/v2/jobs'
|
|
6
|
+
require 'auth0/api/v2/rules'
|
|
7
|
+
require 'auth0/api/v2/stats'
|
|
8
|
+
require 'auth0/api/v2/users'
|
|
9
|
+
require 'auth0/api/v2/tenants'
|
|
10
|
+
require 'auth0/api/v2/tickets'
|
|
7
11
|
|
|
8
12
|
module Auth0
|
|
9
13
|
module Api
|
|
10
14
|
# https://auth0.com/docs/apiv2
|
|
11
15
|
module V2
|
|
12
|
-
include Auth0::Api::V2::Clients
|
|
13
|
-
include Auth0::Api::V2::Users
|
|
14
16
|
include Auth0::Api::V2::Blacklists
|
|
17
|
+
include Auth0::Api::V2::Clients
|
|
18
|
+
include Auth0::Api::V2::Connections
|
|
19
|
+
include Auth0::Api::V2::Emails
|
|
15
20
|
include Auth0::Api::V2::Jobs
|
|
21
|
+
include Auth0::Api::V2::Rules
|
|
16
22
|
include Auth0::Api::V2::Stats
|
|
17
|
-
include Auth0::Api::V2::
|
|
23
|
+
include Auth0::Api::V2::Users
|
|
24
|
+
include Auth0::Api::V2::Tenants
|
|
25
|
+
include Auth0::Api::V2::Tickets
|
|
18
26
|
end
|
|
19
27
|
end
|
|
20
28
|
end
|
|
@@ -1,22 +1,43 @@
|
|
|
1
1
|
module Auth0
|
|
2
2
|
module Api
|
|
3
3
|
module V2
|
|
4
|
-
#
|
|
4
|
+
# Methods to use the blacklist endpoints
|
|
5
5
|
module Blacklists
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
attr_reader :blacklists_path
|
|
7
|
+
|
|
8
|
+
# Retrieves the jti and aud of all tokens in the blacklist.
|
|
9
|
+
# @see https://auth0.com/docs/api/v2#!/Blacklists/get_tokens
|
|
10
|
+
# @param aud [string] The JWT's aud claim. The client_id of the client for which it was issued
|
|
11
|
+
#
|
|
12
|
+
# @return [json] Returns the blacklisted tokens
|
|
13
|
+
#
|
|
14
|
+
def blacklisted_tokens(aud = nil)
|
|
15
|
+
request_params = {
|
|
16
|
+
aud: aud
|
|
17
|
+
}
|
|
18
|
+
get(blacklists_path, request_params)
|
|
10
19
|
end
|
|
11
20
|
|
|
12
|
-
#
|
|
13
|
-
|
|
21
|
+
# Adds the token identified by the jti to a blacklist for the tenant.
|
|
22
|
+
# @see https://auth0.com/docs/api/v2#!/blacklists/post_tokens
|
|
23
|
+
# @param jti [string] The jti of the JWT to blacklist
|
|
24
|
+
# @param aud [string] The JWT's aud claim. The client_id of the client for which it was issued
|
|
25
|
+
# @return [json] Returns the blacklisted token
|
|
26
|
+
#
|
|
27
|
+
def add_token_to_blacklist(jti, aud = nil)
|
|
28
|
+
fail Auth0::MissingParameter, 'Must specify a valid JTI' if jti.to_s.empty?
|
|
14
29
|
request_params = {
|
|
15
30
|
jti: jti,
|
|
16
31
|
aud: aud
|
|
17
32
|
}
|
|
18
|
-
|
|
19
|
-
|
|
33
|
+
post(blacklists_path, request_params)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
# Blacklists API path
|
|
39
|
+
def blacklists_path
|
|
40
|
+
@blacklists_path ||= '/api/v2/blacklists/tokens'
|
|
20
41
|
end
|
|
21
42
|
end
|
|
22
43
|
end
|
data/lib/auth0/api/v2/clients.rb
CHANGED
|
@@ -1,40 +1,81 @@
|
|
|
1
1
|
module Auth0
|
|
2
2
|
module Api
|
|
3
3
|
module V2
|
|
4
|
-
#
|
|
4
|
+
# Methods to use the client endpoints
|
|
5
5
|
module Clients
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
attr_reader :clients_path
|
|
7
|
+
|
|
8
|
+
# Retrieves a list of all client applications. Accepts a list of fields to include or exclude.
|
|
9
|
+
# @see https://auth0.com/docs/api/v2#!/clients/get_clients
|
|
10
|
+
# @param fields [string] A comma separated list of fields to include or exclude from the result.
|
|
11
|
+
# @param include_fields [boolean] if the fields specified are to be included in the result, false otherwise
|
|
12
|
+
#
|
|
13
|
+
# @return [json] Returns the clients applications.
|
|
14
|
+
def clients(fields: nil, include_fields: nil)
|
|
15
|
+
include_fields = true if !fields.nil? && include_fields.nil?
|
|
16
|
+
request_params = {
|
|
17
|
+
fields: fields,
|
|
18
|
+
include_fields: include_fields
|
|
19
|
+
}
|
|
20
|
+
get(clients_path, request_params)
|
|
10
21
|
end
|
|
11
|
-
|
|
22
|
+
alias_method :get_clients, :clients
|
|
12
23
|
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
|
|
24
|
+
# Creates a new client application.
|
|
25
|
+
# @see https://auth0.com/docs/api/v2#!/clients/post_clients
|
|
26
|
+
# @param name [string] The name of the client. Must contain at least one character. Does not allow '<' or '>'
|
|
27
|
+
# @param options [hash] The Hash options used to define the client's properties.
|
|
28
|
+
# @return [json] Returns the created client application.
|
|
29
|
+
def create_client(name, options = {})
|
|
30
|
+
fail Auth0::MissingParameter, 'Must specify a valid client name' if name.to_s.empty?
|
|
31
|
+
request_params = Hash[options.map { |(k, v)| [k.to_sym, v] }]
|
|
16
32
|
request_params[:name] = name
|
|
17
|
-
|
|
18
|
-
post(path, request_params)
|
|
33
|
+
post(clients_path, request_params)
|
|
19
34
|
end
|
|
20
35
|
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
# Retrieves a client by its id.
|
|
37
|
+
# @see https://auth0.com/docs/api/v2#!/Clients/get_clients_by_id
|
|
38
|
+
# @param client_id [string] The id of the client to retrieve
|
|
39
|
+
# @param fields [string] A comma separated list of fields to include or exclude from the result.
|
|
40
|
+
# @param include_fields [boolean] If the fields specified are to be included in the result, false otherwise
|
|
41
|
+
# @return [json] Returns the requested client application.
|
|
42
|
+
def client(client_id, fields: nil, include_fields: nil)
|
|
43
|
+
fail Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty?
|
|
44
|
+
include_fields = true if !fields.nil? && include_fields.nil?
|
|
45
|
+
request_params = {
|
|
46
|
+
fields: fields,
|
|
47
|
+
include_fields: include_fields
|
|
48
|
+
}
|
|
49
|
+
path = "#{clients_path}/#{client_id}"
|
|
50
|
+
get(path, request_params)
|
|
25
51
|
end
|
|
26
52
|
|
|
27
|
-
#
|
|
53
|
+
# Deletes a client and all its related assets (like rules, connections, etc) given its id.
|
|
54
|
+
# @see https://auth0.com/docs/api/v2#!/Clients/delete_clients_by_id
|
|
55
|
+
# @param client_id [string] The id of the client to delete
|
|
28
56
|
def delete_client(client_id)
|
|
29
|
-
|
|
57
|
+
fail Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty?
|
|
58
|
+
path = "#{clients_path}/#{client_id}"
|
|
30
59
|
delete(path)
|
|
31
60
|
end
|
|
32
61
|
|
|
33
|
-
#
|
|
62
|
+
# Updates a client.
|
|
63
|
+
# @see https://auth0.com/docs/api/v2#!/Clients/patch_clients_by_id
|
|
64
|
+
# @param client_id [string] The id of the client to update
|
|
65
|
+
# @param options [hash] The Hash options used to define the client's properties.
|
|
34
66
|
def patch_client(client_id, options)
|
|
35
|
-
|
|
67
|
+
fail Auth0::MissingClientId, 'Must specify a client id' if client_id.to_s.empty?
|
|
68
|
+
fail Auth0::MissingParameter, 'Must specify a valid body' if options.to_s.empty?
|
|
69
|
+
path = "#{clients_path}/#{client_id}"
|
|
36
70
|
patch(path, options)
|
|
37
71
|
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
# Clients API path
|
|
76
|
+
def clients_path
|
|
77
|
+
@clients_path ||= '/api/v2/clients'
|
|
78
|
+
end
|
|
38
79
|
end
|
|
39
80
|
end
|
|
40
81
|
end
|