auth0 4.16.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +29 -8
- data/.github/CODEOWNERS +1 -1
- data/.github/ISSUE_TEMPLATE/config.yml +8 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +39 -0
- data/.github/ISSUE_TEMPLATE/report_a_bug.md +55 -0
- data/.gitignore +1 -1
- data/.yardoc/checksums +22 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/CHANGELOG.md +84 -0
- data/Gemfile +0 -1
- data/README.md +81 -8
- data/Rakefile +0 -22
- data/auth0.gemspec +4 -3
- data/examples/ruby-api/.gitignore +0 -6
- data/lib/auth0/api/authentication_endpoints.rb +22 -226
- data/lib/auth0/api/v2.rb +8 -4
- data/lib/auth0/api/v2/branding.rb +66 -0
- data/lib/auth0/api/v2/connections.rb +3 -0
- data/lib/auth0/api/v2/jobs.rb +3 -1
- data/lib/auth0/api/v2/organizations.rb +332 -0
- data/lib/auth0/api/v2/tickets.rb +14 -2
- data/lib/auth0/api/v2/users.rb +33 -8
- data/lib/auth0/exception.rb +4 -7
- data/lib/auth0/mixins.rb +0 -1
- data/lib/auth0/mixins/access_token_struct.rb +2 -2
- data/lib/auth0/mixins/api_token_struct.rb +2 -2
- data/lib/auth0/mixins/httpproxy.rb +3 -1
- data/lib/auth0/mixins/initializer.rb +4 -8
- data/lib/auth0/mixins/permission_struct.rb +2 -2
- data/lib/auth0/mixins/validation.rb +15 -1
- data/lib/auth0/version.rb +1 -1
- data/spec/integration/lib/auth0/api/api_authentication_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_roles_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_user_blocks_spec.rb +1 -1
- data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +1 -1
- data/spec/lib/auth0/api/v2/branding_spec.rb +70 -0
- data/spec/lib/auth0/api/v2/connections_spec.rb +4 -0
- data/spec/lib/auth0/api/v2/jobs_spec.rb +11 -0
- data/spec/lib/auth0/api/v2/organizations_spec.rb +588 -0
- data/spec/lib/auth0/api/v2/roles_spec.rb +4 -4
- data/spec/lib/auth0/api/v2/tickets_spec.rb +55 -0
- data/spec/lib/auth0/api/v2/users_spec.rb +57 -11
- data/spec/lib/auth0/client_spec.rb +79 -9
- data/spec/lib/auth0/mixins/httpproxy_spec.rb +2 -2
- data/spec/lib/auth0/mixins/validation_spec.rb +32 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/support/credentials.rb +0 -19
- metadata +49 -44
- data/.github/ISSUE_TEMPLATE.md +0 -39
- data/Gemfile.lock +0 -227
- data/deploy_documentation.sh +0 -29
- data/doc_config/templates/default/fulldoc/html/css/full_list.css +0 -79
- data/doc_config/templates/default/fulldoc/html/css/style.css +0 -546
- data/doc_config/templates/default/layout/html/breadcrumb.erb +0 -11
- data/doc_config/templates/default/layout/html/footer.erb +0 -115
- data/doc_config/templates/default/layout/html/headers.erb +0 -17
- data/doc_config/templates/default/layout/html/layout.erb +0 -27
- data/lib/auth0/api/v1.rb +0 -19
- data/lib/auth0/api/v1/clients.rb +0 -58
- data/lib/auth0/api/v1/connections.rb +0 -68
- data/lib/auth0/api/v1/logs.rb +0 -43
- data/lib/auth0/api/v1/rules.rb +0 -57
- data/lib/auth0/api/v1/users.rb +0 -227
- data/spec/lib/auth0/api/authentication_endpoints_spec.rb +0 -703
@@ -9,6 +9,7 @@ module Auth0
|
|
9
9
|
# being specified. Accepts a list of fields to include or exclude in the resulting list of connection objects.
|
10
10
|
# @see https://auth0.com/docs/api/management/v2#!/Connections/get_connections
|
11
11
|
# @param strategy [string] Strategy to filter connection results.
|
12
|
+
# @param name [string] Name to filter connection results.
|
12
13
|
# @param fields [string] A comma separated list of fields to include or exclude from the result.
|
13
14
|
# @param include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
|
14
15
|
# @param page [int] Page number to get, 0-based.
|
@@ -16,6 +17,7 @@ module Auth0
|
|
16
17
|
# @return [json] Returns the existing connections matching the strategy.
|
17
18
|
def connections(
|
18
19
|
strategy: nil,
|
20
|
+
name: nil,
|
19
21
|
fields: nil,
|
20
22
|
include_fields: nil,
|
21
23
|
page: nil,
|
@@ -24,6 +26,7 @@ module Auth0
|
|
24
26
|
include_fields = true if !fields.nil? && include_fields.nil?
|
25
27
|
request_params = {
|
26
28
|
strategy: strategy,
|
29
|
+
name: name,
|
27
30
|
fields: fields.is_a?(Array) ? fields.join(',') : fields,
|
28
31
|
include_fields: include_fields,
|
29
32
|
page: !page.nil? ? page.to_i : nil,
|
data/lib/auth0/api/v2/jobs.rb
CHANGED
@@ -81,13 +81,15 @@ module Auth0
|
|
81
81
|
# @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
|
82
82
|
# * :user_id [string] user_id of the identity.
|
83
83
|
# * :provider [string] provider of the identity.
|
84
|
+
# @param organization_id [string] organization id
|
84
85
|
#
|
85
86
|
# @return [json] Returns the job status and properties.
|
86
|
-
def send_verification_email(user_id, client_id = nil, identity: nil)
|
87
|
+
def send_verification_email(user_id, client_id = nil, identity: nil, organization_id: nil)
|
87
88
|
raise Auth0::InvalidParameter, 'Must specify a user id' if user_id.to_s.empty?
|
88
89
|
|
89
90
|
request_params = { user_id: user_id }
|
90
91
|
request_params[:client_id] = client_id unless client_id.nil?
|
92
|
+
request_params[:organization_id] = organization_id unless organization_id.nil?
|
91
93
|
|
92
94
|
if identity
|
93
95
|
unless identity.is_a? Hash
|
@@ -0,0 +1,332 @@
|
|
1
|
+
module Auth0
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
# Methods to use the organizations endpoints
|
5
|
+
module Organizations
|
6
|
+
include Auth0::Mixins::Validation
|
7
|
+
|
8
|
+
attr_reader :organizations_path
|
9
|
+
|
10
|
+
# Get all organizations.
|
11
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations
|
12
|
+
# @param options [hash] The Hash options used to define the paging of rersults
|
13
|
+
# * :per_page [integer] The amount of entries per page. Default: 50. Max value: 100.
|
14
|
+
# * :page [integer] The page number. Zero based.
|
15
|
+
# * :include_totals [boolean] True to include query summary in the result, false or nil otherwise.
|
16
|
+
# @return [json] All Organizations
|
17
|
+
def organizations(options = {})
|
18
|
+
request_params = {
|
19
|
+
per_page: options.fetch(:per_page, nil),
|
20
|
+
page: options.fetch(:page, nil),
|
21
|
+
include_totals: options.fetch(:include_totals, nil)
|
22
|
+
}
|
23
|
+
get(organizations_path, request_params)
|
24
|
+
end
|
25
|
+
alias get_organizations organizations
|
26
|
+
|
27
|
+
# Create a new organization.
|
28
|
+
# @see ttps://auth0.com/docs/api/management/v2/#!/Organizations/post_organizations
|
29
|
+
# @param options [hash] See https://auth0.com/docs/api/management/v2/#!/Organizations/post_organizations for available options
|
30
|
+
# @return [json] Returns the created organization.
|
31
|
+
def create_organization(options = {})
|
32
|
+
post(organizations_path, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Get an organization by id. A token with read:organizations scope is required
|
36
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organizations_by_id
|
37
|
+
# @param organization_id [string] The organization_id of the user to retrieve.
|
38
|
+
#
|
39
|
+
# @return [json] Returns the organization with the given organization_id if it exists.
|
40
|
+
def organization(organization_id)
|
41
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
42
|
+
path = "#{organizations_path}/#{organization_id}"
|
43
|
+
get(path)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Get an organization by name. A token with read:organizations scope is required.
|
47
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_name_by_name
|
48
|
+
# @param organization_name [string] The Organization name
|
49
|
+
#
|
50
|
+
# @return [json] Returns the organization with the given organization_name if it exists.
|
51
|
+
def organization_by_name(organization_name)
|
52
|
+
raise Auth0::InvalidParameter, 'Must supply a valid organization_name' if organization_name.to_s.empty?
|
53
|
+
path = "#{organizations_path}/name/#{organization_name}"
|
54
|
+
get(path)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# Deletes a single organization given its id
|
59
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_organizations_by_id
|
60
|
+
# @param organization_id [string] The Organization ID
|
61
|
+
def delete_organization(organization_id)
|
62
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
63
|
+
path = "#{organizations_path}/#{organization_id}"
|
64
|
+
delete(path)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Update an existing organization.
|
68
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/patch_organizations_by_id
|
69
|
+
# @param organization_id [string] The Organization ID
|
70
|
+
# @param body [hash] The optional parameters to update.
|
71
|
+
#
|
72
|
+
# @return [json] Returns the updated user.
|
73
|
+
def patch_organization(organization_id, body)
|
74
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
75
|
+
raise Auth0::InvalidParameter, 'Must supply a valid body' if body.to_s.empty? || body.empty?
|
76
|
+
path = "#{organizations_path}/#{organization_id}"
|
77
|
+
patch(path, body)
|
78
|
+
end
|
79
|
+
alias update_organization patch_organization
|
80
|
+
|
81
|
+
### Organization Enabled Connections
|
82
|
+
|
83
|
+
# Get enabled connections in an Organization
|
84
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections
|
85
|
+
# @param organization_id [string] The Organization ID
|
86
|
+
#
|
87
|
+
# @return [json] Returns the enabled connections for the given organization
|
88
|
+
def get_organizations_enabled_connections(organization_id)
|
89
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
90
|
+
path = "#{organizations_enabled_connections_path(organization_id)}"
|
91
|
+
get(path)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Get enabled connection by id in an Organization
|
95
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_enabled_connections_by_connectionId
|
96
|
+
# @param organization_id [string] The Organization ID
|
97
|
+
# @param connection_id [string] The Connection id
|
98
|
+
#
|
99
|
+
# @return [json] Returns the connection for the given organization
|
100
|
+
def get_organizations_enabled_connection(organization_id, connection_id)
|
101
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
102
|
+
raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
|
103
|
+
path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
|
104
|
+
get(path)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Update an eanbled connection in an Organization
|
108
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/patch_enabled_connections_by_connectionId
|
109
|
+
# @param organization_id [string] The Organization ID
|
110
|
+
# @param connection_id [string] The Connection id
|
111
|
+
# @param assign_membership_on_login [boolean] flag to allow assign membership on login
|
112
|
+
#
|
113
|
+
# @return [json] Returns the connection for the given organization
|
114
|
+
def patch_organizations_enabled_connection(organization_id, connection_id, assign_membership_on_login: nil)
|
115
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
116
|
+
raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
|
117
|
+
raise Auth0::InvalidParameter, 'Must supply a valid assign_membership_on_login value' if assign_membership_on_login.nil?
|
118
|
+
path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
|
119
|
+
|
120
|
+
body = {}
|
121
|
+
body[:assign_membership_on_login] = assign_membership_on_login
|
122
|
+
|
123
|
+
patch(path, body)
|
124
|
+
end
|
125
|
+
alias update_organizations_enabled_connection patch_organizations_enabled_connection
|
126
|
+
|
127
|
+
# Add an enabled connection for an Organization
|
128
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_enabled_connections
|
129
|
+
# @param organization_id [string] The Organization ID
|
130
|
+
# @param assign_membership_on_login [boolean] flag to allow assign membership on login
|
131
|
+
#
|
132
|
+
# @return [json] Returns the connection for the given organization
|
133
|
+
def create_organizations_enabled_connection(organization_id, assign_membership_on_login: false)
|
134
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
135
|
+
path = "#{organizations_enabled_connections_path(organization_id)}"
|
136
|
+
|
137
|
+
body = {}
|
138
|
+
body[:assign_membership_on_login] = assign_membership_on_login
|
139
|
+
|
140
|
+
post(path, body)
|
141
|
+
end
|
142
|
+
alias add_organizations_enabled_connection create_organizations_enabled_connection
|
143
|
+
|
144
|
+
# Remove an enabled connection from an Organization
|
145
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_enabled_connections_by_connectionId
|
146
|
+
# @param organization_id [string] The Organization ID
|
147
|
+
# @param connection_id [string] The Connection id
|
148
|
+
def delete_organizations_enabled_connection(organization_id, connection_id)
|
149
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
150
|
+
raise Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
|
151
|
+
path = "#{organizations_enabled_connections_path(organization_id)}/#{connection_id}"
|
152
|
+
delete(path)
|
153
|
+
end
|
154
|
+
alias remove_organizations_enabled_connection delete_organizations_enabled_connection
|
155
|
+
|
156
|
+
### Organization Invites
|
157
|
+
|
158
|
+
# Get invites in an Organization
|
159
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_invitations
|
160
|
+
# @param organization_id [string] The Organization ID
|
161
|
+
#
|
162
|
+
# @return [json] Returns the invites for the given organization
|
163
|
+
def get_organizations_invites(organization_id)
|
164
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
165
|
+
path = "#{organizations_invitations_path(organization_id)}"
|
166
|
+
get(path)
|
167
|
+
end
|
168
|
+
|
169
|
+
# Get invite by id in an Organization
|
170
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_invitations_by_invitation_id
|
171
|
+
# @param organization_id [string] The Organization ID
|
172
|
+
# @param invitation_id [string] The invitation id
|
173
|
+
#
|
174
|
+
# @return [json] Returns the invitation for the given organization
|
175
|
+
def get_organizations_invite(organization_id, invitation_id)
|
176
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
177
|
+
raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
|
178
|
+
path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
|
179
|
+
get(path)
|
180
|
+
end
|
181
|
+
|
182
|
+
# Create an invitation in an organization
|
183
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_invitations
|
184
|
+
# @param organization_id [string] The Organization ID
|
185
|
+
# @param options [hash] See https://auth0.com/docs/api/management/v2/#!/Organizations/post_invitations
|
186
|
+
# @return [json] Returns the invitation for the given organization
|
187
|
+
def create_organizations_invite(organization_id, options = {})
|
188
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
189
|
+
path = "#{organizations_invitations_path(organization_id)}"
|
190
|
+
|
191
|
+
post(path, options)
|
192
|
+
end
|
193
|
+
alias add_organizations_invite create_organizations_invite
|
194
|
+
|
195
|
+
# Delete an invitation to organization
|
196
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_invitations_by_invitation_id
|
197
|
+
# @param organization_id [string] The Organization ID
|
198
|
+
# @param invitation_id [string] The Invitation id
|
199
|
+
def delete_organizations_invite(organization_id, invitation_id)
|
200
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
201
|
+
raise Auth0::InvalidParameter, 'Must supply a valid invitation id' if invitation_id.to_s.empty?
|
202
|
+
path = "#{organizations_invitations_path(organization_id)}/#{invitation_id}"
|
203
|
+
delete(path)
|
204
|
+
end
|
205
|
+
alias remove_organizations_invite delete_organizations_invite
|
206
|
+
|
207
|
+
### Organization Member
|
208
|
+
|
209
|
+
# Get Members in a Organization
|
210
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_members
|
211
|
+
# @param organization_id [string] The Organization ID
|
212
|
+
# @param user_id [string] The User ID
|
213
|
+
#
|
214
|
+
# @return [json] Returns the members for the given organization
|
215
|
+
def get_organizations_members(organization_id)
|
216
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
217
|
+
path = "#{organizations_members_path(organization_id)}"
|
218
|
+
get(path)
|
219
|
+
end
|
220
|
+
|
221
|
+
# Add members in an organization
|
222
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_members
|
223
|
+
# @param organization_id [string] The Organization ID
|
224
|
+
# @param members [array] Array of user IDs.
|
225
|
+
#
|
226
|
+
# @return [json] Returns the invitation for the given organization
|
227
|
+
def create_organizations_members(organization_id, members = [])
|
228
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
229
|
+
raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
|
230
|
+
path = "#{organizations_members_path(organization_id)}"
|
231
|
+
|
232
|
+
body = {}
|
233
|
+
body[:members] = members
|
234
|
+
|
235
|
+
post(path, body)
|
236
|
+
end
|
237
|
+
alias add_organizations_members create_organizations_members
|
238
|
+
|
239
|
+
# Remove members from an organization
|
240
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/delete_members
|
241
|
+
# @param organization_id [string] The Organization ID
|
242
|
+
# @param members [array] Array of user IDs.
|
243
|
+
def delete_organizations_members(organization_id, members = [])
|
244
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
245
|
+
raise Auth0::InvalidParameter, 'Must supply an array of member ids' if members.empty?
|
246
|
+
path = "#{organizations_members_path(organization_id)}"
|
247
|
+
|
248
|
+
body = {}
|
249
|
+
body[:members] = members
|
250
|
+
|
251
|
+
delete(path, body)
|
252
|
+
end
|
253
|
+
alias remove_organizations_members delete_organizations_members
|
254
|
+
|
255
|
+
### Organization Member Roles
|
256
|
+
|
257
|
+
# Get Roles assigned to a Member in an Organization
|
258
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_organization_member_roles
|
259
|
+
# @param organization_id [string] The Organization ID
|
260
|
+
# @param user_id [string] The User ID
|
261
|
+
#
|
262
|
+
# @return [json] Returns the member_roles for the given organization
|
263
|
+
def get_organizations_member_roles(organization_id, user_id)
|
264
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
265
|
+
raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
|
266
|
+
path = "#{organizations_member_roles_path(organization_id, user_id)}"
|
267
|
+
get(path)
|
268
|
+
end
|
269
|
+
|
270
|
+
# Assign roles to a member in an organization
|
271
|
+
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/post_organization_member_roles
|
272
|
+
# @param organization_id [string] The Organization ID
|
273
|
+
# @param user_id [string] The User ID
|
274
|
+
# @param roles [array] Array of role IDs.
|
275
|
+
#
|
276
|
+
# @return [json] Returns the invitation for the given organization
|
277
|
+
def create_organizations_member_roles(organization_id, user_id, roles = [])
|
278
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
279
|
+
raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
|
280
|
+
raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
|
281
|
+
path = "#{organizations_member_roles_path(organization_id, user_id)}"
|
282
|
+
|
283
|
+
body = {}
|
284
|
+
body[:roles] = roles
|
285
|
+
|
286
|
+
post(path, body)
|
287
|
+
end
|
288
|
+
alias add_organizations_member_roles create_organizations_member_roles
|
289
|
+
|
290
|
+
# Remove roles from a Member of an organization
|
291
|
+
# @https://auth0.com/docs/api/management/v2/#!/Organizations/delete_organization_member_roles
|
292
|
+
# @param organization_id [string] The Organization ID
|
293
|
+
# @param user_id [string] The User ID
|
294
|
+
# @param roles [array] Array of role IDs.
|
295
|
+
def delete_organizations_member_roles(organization_id, user_id, roles = [])
|
296
|
+
raise Auth0::MissingOrganizationId, 'Must supply a valid organization_id' if organization_id.to_s.empty?
|
297
|
+
raise Auth0::InvalidParameter, 'Must supply a valid user id' if user_id.to_s.empty?
|
298
|
+
raise Auth0::InvalidParameter, 'Must supply an array of role ids' if roles.empty?
|
299
|
+
path = "#{organizations_member_roles_path(organization_id, user_id)}"
|
300
|
+
|
301
|
+
body = {}
|
302
|
+
body[:roles] = roles
|
303
|
+
|
304
|
+
delete(path, body)
|
305
|
+
end
|
306
|
+
alias remove_organizations_member_roles delete_organizations_member_roles
|
307
|
+
|
308
|
+
private
|
309
|
+
# Organizations API path
|
310
|
+
def organizations_path
|
311
|
+
@organizations_path ||= '/api/v2/organizations'
|
312
|
+
end
|
313
|
+
|
314
|
+
def organizations_enabled_connections_path(org_id)
|
315
|
+
"#{organizations_path}/#{org_id}/enabled_connections"
|
316
|
+
end
|
317
|
+
|
318
|
+
def organizations_members_path(org_id)
|
319
|
+
"#{organizations_path}/#{org_id}/members"
|
320
|
+
end
|
321
|
+
|
322
|
+
def organizations_member_roles_path(org_id, user_id)
|
323
|
+
"#{organizations_path}/#{org_id}/members/#{user_id}/roles"
|
324
|
+
end
|
325
|
+
|
326
|
+
def organizations_invitations_path(org_id)
|
327
|
+
"#{organizations_path}/#{org_id}/invitations"
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
end
|
332
|
+
end
|
data/lib/auth0/api/v2/tickets.rb
CHANGED
@@ -15,9 +15,11 @@ module Auth0
|
|
15
15
|
# @param identity [hash] Used to verify secondary, federated, and passwordless-email identities.
|
16
16
|
# * :user_id [string] user_id of the identity.
|
17
17
|
# * :provider [string] provider of the identity.
|
18
|
+
# @param client_id [string] client id
|
19
|
+
# @param organization_id [string] organization id
|
18
20
|
#
|
19
21
|
# @return [json] Returns the created ticket url.
|
20
|
-
def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil)
|
22
|
+
def post_email_verification(user_id, result_url: nil, ttl_sec: nil, identity: nil, client_id: nil, organization_id: nil)
|
21
23
|
if user_id.to_s.empty?
|
22
24
|
raise Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
|
23
25
|
end
|
@@ -27,6 +29,8 @@ module Auth0
|
|
27
29
|
result_url: result_url,
|
28
30
|
ttl_sec: ttl_sec.is_a?(Integer) ? ttl_sec : nil
|
29
31
|
}
|
32
|
+
request_params[:client_id] = client_id unless client_id.nil?
|
33
|
+
request_params[:organization_id] = organization_id unless organization_id.nil?
|
30
34
|
|
31
35
|
if identity
|
32
36
|
unless identity.is_a? Hash
|
@@ -53,6 +57,8 @@ module Auth0
|
|
53
57
|
# @param includeEmailInRedirect [boolean] Whether or not we include the email as part of the returnUrl
|
54
58
|
# in the reset_email
|
55
59
|
# @param new_password [string] The password to be set for the user once the ticket is used.
|
60
|
+
# @param client_id [string] client id
|
61
|
+
# @param organization_id [string] organization id
|
56
62
|
#
|
57
63
|
# @return [json] Returns the created ticket url.
|
58
64
|
def post_password_change(
|
@@ -63,7 +69,10 @@ module Auth0
|
|
63
69
|
ttl_sec: nil,
|
64
70
|
mark_email_as_verified: nil,
|
65
71
|
includeEmailInRedirect: nil,
|
66
|
-
new_password: nil
|
72
|
+
new_password: nil,
|
73
|
+
client_id: nil,
|
74
|
+
organization_id: nil
|
75
|
+
)
|
67
76
|
|
68
77
|
booleans = [true, false]
|
69
78
|
path = "#{tickets_path}/password-change"
|
@@ -77,6 +86,9 @@ module Auth0
|
|
77
86
|
includeEmailInRedirect: booleans.include?(includeEmailInRedirect) ? includeEmailInRedirect : nil,
|
78
87
|
new_password: new_password
|
79
88
|
}
|
89
|
+
request_params[:client_id] = client_id unless client_id.nil?
|
90
|
+
request_params[:organization_id] = organization_id unless organization_id.nil?
|
91
|
+
|
80
92
|
post(path, request_params)
|
81
93
|
end
|
82
94
|
|
data/lib/auth0/api/v2/users.rb
CHANGED
@@ -43,13 +43,15 @@ module Auth0
|
|
43
43
|
# The attribute connection is always mandatory but depending on the type of connection you are using there
|
44
44
|
# could be others too. For instance, Auth0 DB Connections require email and password.
|
45
45
|
# @see https://auth0.com/docs/api/v2#!/Users/post_users
|
46
|
-
# @param
|
47
|
-
# @param options [hash]
|
48
|
-
# * :connection [string] The connection the user belongs to.
|
46
|
+
# @param connection [string] The connection the user belongs to.
|
47
|
+
# @param options [hash] See https://auth0.com/docs/api/management/v2#!/Users/post_users for available options
|
49
48
|
# @return [json] Returns the created user.
|
50
|
-
def create_user(
|
49
|
+
def create_user(connection, options = {})
|
50
|
+
if !connection.is_a?(String) || connection.empty?
|
51
|
+
raise Auth0::MissingParameter, 'Must supply a valid connection'
|
52
|
+
end
|
51
53
|
request_params = Hash[options.map { |(k, v)| [k.to_sym, v] }]
|
52
|
-
request_params[:
|
54
|
+
request_params[:connection] = connection
|
53
55
|
post(users_path, request_params)
|
54
56
|
end
|
55
57
|
|
@@ -248,11 +250,22 @@ module Auth0
|
|
248
250
|
# @see https://auth0.com/docs/api/management/v2#!/Users/get_permissions
|
249
251
|
#
|
250
252
|
# @param user_id [string] The user_id of the permissions to get.
|
253
|
+
# @param options [hash] A hash of options for getting permissions
|
254
|
+
# * :per_page [integer] The amount of permissions per page. (optional)
|
255
|
+
# * :page [integer] The page number. Zero based. (optional)
|
256
|
+
# * :include_totals [boolean] True if a query summary must be included in the result. (optional)
|
251
257
|
#
|
252
258
|
# @return [json] Returns permissions for the given user_id.
|
253
|
-
def get_user_permissions(user_id)
|
259
|
+
def get_user_permissions(user_id, options = {})
|
254
260
|
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
255
|
-
|
261
|
+
|
262
|
+
request_params = {
|
263
|
+
per_page: options.fetch(:per_page, nil),
|
264
|
+
page: options.fetch(:page, nil),
|
265
|
+
include_totals: options.fetch(:include_totals, nil)
|
266
|
+
}
|
267
|
+
|
268
|
+
get "#{users_path}/#{user_id}/permissions", request_params
|
256
269
|
end
|
257
270
|
|
258
271
|
# Remove one or more permissions from a specific user.
|
@@ -283,7 +296,7 @@ module Auth0
|
|
283
296
|
# @param user_id [string] The user_id of the recovery codes to regenerate.
|
284
297
|
def generate_recovery_code(user_id)
|
285
298
|
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
286
|
-
post "#{users_path}/#{user_id}/recovery-code-
|
299
|
+
post "#{users_path}/#{user_id}/recovery-code-regeneration"
|
287
300
|
end
|
288
301
|
|
289
302
|
# Invalidate all remembered browsers for all authentication factors for a specific user.
|
@@ -295,6 +308,18 @@ module Auth0
|
|
295
308
|
post "#{users_path}/#{user_id}/multifactor/actions/invalidate-remember-browser"
|
296
309
|
end
|
297
310
|
|
311
|
+
|
312
|
+
# Get a list of organizations for a user.
|
313
|
+
#
|
314
|
+
# @param user_id [string] The user_id of the permissions to get.
|
315
|
+
#
|
316
|
+
# @return [json] Returns organizations for the given user_id.
|
317
|
+
def get_user_organizations(user_id)
|
318
|
+
raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?
|
319
|
+
|
320
|
+
get "#{users_path}/#{user_id}/organizations"
|
321
|
+
end
|
322
|
+
|
298
323
|
private
|
299
324
|
|
300
325
|
# Users API path
|