summaryrefslogtreecommitdiffstats
path: root/docs/en/rst/api/core/v1/user.rst
blob: 3e3f64bd6a6f8fcda05897560ecec0be4fd26c64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
Users
=====

This part of the Bugzilla API allows you to create user accounts, get information
about user accounts and to log in or out using an existing account.

.. _rest_user_login:

Login
-----

Logging in with a username and password is required for many Bugzilla
installations, in order to search for private bugs, post new bugs, etc. This
method allows you to retrieve a token that can be used as authentication for
subsequent API calls. Otherwise yuou will need to pass your ``login`` and
``password`` with each call.

This method will be going away in the future in favor of using *API keys*.

**Request**

.. code-block:: text

   GET /rest/login?login=foo@example.com&password=toosecrettoshow

==============  =======  ========================================================
name            type     description
==============  =======  ========================================================
**login**       string   The user's login name.
**password**    string   The user's password.
restrict_login  boolean  If set to a true value, the token returned by this
                         method will only be valid from the IP address which
                         called this method.
==============  =======  ========================================================

**Response**

.. code-block:: js

   {
     "token": "786-OLaWfBisMY",
     "id": 786
   }

========  ======  ===============================================================
name      type    description
========  ======  ===============================================================
id        int     Numeric ID of the user that was logged in.
token     string  Token which can be passed in the parameters as
                  authentication in other calls. The token can be sent along
                  with any future requests to the webservice, for the duration
                  of the session, i.e. til :ref:`rest_user_logout` is called.
========  ======  ===============================================================

**Errors**

* 300 (Invalid Username or Password)
  The username does not exist, or the password is wrong.
* 301 (Login Disabled)
  The ability to login with this account has been disabled.  A reason may be
  specified with the error.
* 305 (New Password Required)
  The current password is correct, but the user is asked to change
  their password.
* 50 (Param Required)
  A login or password parameter was not provided.

.. _rest_user_logout:

Logout
------

Log out the user. Basically it invalidates the token provided so it cannot be
re-used. Does nothing if the token is not in use. Will also clear any existing
authentication cookies the client may still have stored.

**Request**

.. code-block:: text

   GET /rest/logout?token=1234-VWvO51X69r

=====  ======  ===================================================
name   type    description
=====  ======  ===================================================
token  string   The user's token used for authentication.
=====  ======  ===================================================

.. _rest_user_valid_login:

Valid Login
-----------

This method will verify whether a client's cookies or current login token is
still valid or have expired. A valid username that matches must be provided as
well.

**Request**

.. code-block:: text

   GET /rest/valid_login?login=foo@example.com&token=1234-VWvO51X69r

=========  =======  =============================================================
name       type     description
=========  =======  =============================================================
**login**  string   The login name that matches the provided cookies or token.
token      string   Persistent login token currently being used for
                    authentication.
=========  =======  =============================================================

**Response**

Returns true/false depending on if the current token is valid for the provided
username.

.. _rest_user_create:

Create User
-----------

Creates a user account directly in Bugzilla, password and all. Instead of this,
you should use **Offer Account by Email** when possible because that makes sure
that the email address specified can actually receive an email. This function
does not check that. You must be authenticated and be in the *editusers* group
to perform this action.

**Request**

.. code-block:: text

   POST /rest/user

.. code-block:: js

   {
     "email" : "user@bugzilla.org",
     "full_name" : "Test User",
     "password" : "K16ldRr922I1"
   }

==========  ======  =============================================================
name        type    description
==========  ======  =============================================================
**login**   string  The login name for the new user. Ignored if the
                    *use_email_as_login* parameter is true.
**email**   string  The email address for the new user.
full_name   string  The user's full name. Will be set to empty if not specified.
password    string  The password for the new user account, in plain text. It
                    will be stripped of leading and trailing whitespace. If
                    blank or not specified, the new created account will
                    exist in Bugzilla but will not be allowed to log in
                    using DB authentication until a password is set either
                    by the user (through resetting their password) or by the
                    administrator.
==========  ======  =============================================================

**Response**

.. code-block:: js

   {
     "id": 58707
   }

====  ====  ============================================
name  type  desciption
====  ====  ============================================
id    int   The numeric ID of the user that was created.
====  ====  ============================================

**Errors**

* 502 (Password Too Short)
  The password specified is too short. (Usually, this means the
  password is under three characters.)

**History**

The *login* parameter has been added in Bugzilla 6.0.

.. _rest_user_update:

Update User
-----------

Updates an existing user account in Bugzilla. You must be authenticated and be
in the *editusers* group to perform this action.

If you are not in the *editusers* group, you may add or remove users from groups
if you have bless permissions for the groups you wish to modify. All other changes
will be ignored.

**Request**

.. code-block:: text

   PUT /rest/user/(id_or_name)

You can edit a single user by passing the ID or login name of the user
in the URL. To edit more than one user, you can specify addition IDs or
login names using the ``ids`` or ``names`` parameters respectively.

=================  =======  =====================================================
 name              type     description
=================  =======  =====================================================
**id_or_name**     mixed    Either the ID or the login name of the user to
                            update.
**ids**            array    Additional IDs of users to update.
**names**          array    Additional login names of users to update.
full_name          string   The new name of the user.
email              string   The email of the user. Also note that you can only
                            update one user at a time when changing the login
                            name / email. (An error will be thrown if you try to
                            update this field for multiple users at once.)
password           string   The password of the user.
email_enabled      boolean  A boolean value to enable/disable sending
                            bug-related mail to the user.
login_denied_text  string   A text field that holds the reason for disabling a
                            user from logging into Bugzilla. If empty, then the
                            user account is enabled; otherwise it is
                            disabled/closed.
groups             object   These specify the groups that this user is directly
                            a member of. To set these, you should pass an object
                            as the value. The object's items are described in
                            the Groups update objects below.
bless_groups       object   This is the same as groups but affects what groups
                            a user has direct membership to bless that group.
                            It takes the same inputs as groups.
=================  =======  =====================================================

Groups and bless groups update object:

======  =====  ==================================================================
name    type   description
======  =====  ==================================================================
add     array  The group IDs or group names that the user should be added to.
remove  array  The group IDs or group names that the user should be removed from.
set     array  Integers or strings which are an exact set of group IDs and group
               names that the user should be a member of. This does not remove
               groups from the user when the person making the change does not
               have the bless privilege for the group.
======  =====  ==================================================================

If you specify ``set``, then ``add`` and ``remove`` will be ignored. A group in
both the ``add`` and ``remove`` list will be added. Specifying a group that the
user making the change does not have bless rights will generate an error.

**Response**

* users: (array) List of user change objects with the following items:

=======  ======  ================================================================
name     type    description
=======  ======  ================================================================
id       int     The ID of the user that was updated.
changes  object  The changes that were actually done on this user. The keys
                 are the names of the fields that were changed, and the values
                 are an object with two items:

                 * added: (string) The values that were added to this field,
                   possibly a comma-and-space-separated list if multiple values
                   were added.
                 * removed: (string) The values that were removed from this
                   field, possibly a comma-and-space-separated list if multiple
                   values were removed.
=======  ======  ================================================================

**Errors**

* 51 (Bad Login Name)
  You passed an invalid login name in the "names" array.
* 304 (Authorization Required)
  Logged-in users are not authorized to edit other users.

.. _rest_user_get:

Get User
--------

Gets information about user accounts in Bugzilla.

**Request**

To get information about a single user in Bugzilla:

.. code-block:: text

   GET /rest/user/(id_or_name)

To get multiple users by name or ID:

.. code-block:: text

   GET /rest/user?names=foo@bar.com&name=test@bugzilla.org
   GET /rest/user?ids=123&ids=321

To get user matching a search string:

.. code-block:: text

   GET /rest/user?match=foo

To get user by using an integer ID value or by using ``match``, you must be
authenticated.

================  =======  ======================================================
name              type     description
================  =======  ======================================================
id_or_name        mixed    An integer user ID or login name of the user.
ids               array    Integer user IDs. Logged=out users cannot pass
                           this parameter to this function. If they try,
                           they will get an error. Logged=in users will get
                           an error if they specify the ID of a user they
                           cannot see.
names             array    Login names.
match             array    This works just like "user matching" in Bugzilla
                           itself. Users will be returned whose real name
                           or login name contains any one of the specified
                           strings. Users that you cannot see will not be
                           included in the returned list.

                           Most installations have a limit on how many
                           matches are returned for each string; the default
                           is 1000 but can be changed by the Bugzilla
                           administrator.

                           Logged-out users cannot use this argument, and
                           an error will be thrown if they try. (This is to
                           make it harder for spammers to harvest email
                           addresses from Bugzilla, and also to enforce the
                           user visibility restrictions that are
                           implemented on some Bugzillas.)
limit             int      Limit the number of users matched by the
                           ``match`` parameter. If the value is greater than the
                           system limit, the system limit will be used.
                           This parameter is only valid when using the ``match``
                           parameter.
group_ids         array    Numeric IDs for groups that a user can be in.
groups            array    Names of groups that a user can be in. If
                           ``group_ids`` or ``groups`` are specified, they
                           limit the return value to users who are in *any*
                           of the groups specified.
include_disabled  boolean  By default, when using the ``match`` parameter,
                           disabled users are excluded from the returned
                           results unless their full username is identical
                           to the match string. Setting ``include_disabled`` to
                           ``true`` will include disabled users in the returned
                           results even if their username doesn't fully match
                           the input string.
================  =======  ======================================================

**Response**

* users: (array) Each object describes a user and has the following items:

=================  =======  =====================================================
name               type     description
=================  =======  =====================================================
id                 int      The unique integer ID that Bugzilla uses to represent
                            this user. Even if the user's login name changes,
                            this will not change.
real_name          string   The actual name of the user. May be blank.
email              string   The email address of the user.
name               string   The login name of the user.
can_login          boolean  A boolean value to indicate if the user can login
                            into bugzilla.
email_enabled      boolean  A boolean value to indicate if bug-related mail will
                            be sent to the user or not.
login_denied_text  string   A text field that holds the reason for disabling a
                            user from logging into Bugzilla. If empty then the
                            user account is enabled; otherwise it is
                            disabled/closed.
groups             array    Groups the user is a member of. If the currently
                            logged in user is querying their own account or is a
                            member of the 'editusers' group, the array will
                            contain all the groups that the user is a member of.
                            Otherwise, the array will only contain groups that
                            the logged in user can bless. Each object describes
                            the group and contains the items described in the
                            Group object below.
saved_searches     array    User's saved searches, each having the following
                            Search object items described below.
saved_reports      array    User's saved reports, each having the following
                            Search object items described below.
=================  =======  =====================================================

Group object:

===========  ======  ============================================================
name         type    description
===========  ======  ============================================================
id           int     The group ID
name         string  The name of the group
description  string  The description for the group
===========  ======  ============================================================

Search object:

=====  ======  ==================================================================
name   type    description
=====  ======  ==================================================================
id     int     An integer ID uniquely identifying the saved report.
name   string  The name of the saved report.
query  string  The CGI parameters for the saved report.
=====  ======  ==================================================================

If you are not authenticated when you call this function, you will only be
returned the ``id``, ``name``, and ``real_name`` items. If you are authenticated
and not in 'editusers' group, you will only be returned the ``id``, ``name``,
``real_name``, ``can_login``, and ``groups`` items. The groups
returned are filtered based on your permission to bless each group. The
``saved_searches`` and ``saved_reports`` items are only returned if you are
querying your own account, even if you are in the editusers group.

**Errors**

* 51 (Bad Login Name or Group ID)
  You passed an invalid login name in the "names" array or a bad
  group ID in the "group_ids" argument.
* 52 (Invalid Parameter)
  The value used must be an integer greater than zero.
* 304 (Authorization Required)
  You are logged in, but you are not authorized to see one of the users you
  wanted to get information about by user id.
* 505 (User Access By Id or User-Matching Denied)
  Logged-out users cannot use the "ids" or "match" arguments to this
  function.
* 804 (Invalid Group Name)
  You passed a group name in the "groups" argument which either does not
  exist or you do not belong to it.

.. _rest_user_whoami:

Who Am I
--------

Allows for validating a user's API key, token, or username and password.
If sucessfully authenticated, it returns simple information about the
logged in user.

**Request**

.. code-block:: text

   GET /rest/whoami

**Response**

.. code-block:: js

   {
     "id" : "1234",
     "name" : "user@bugzulla.org",
     "real_name" : "Test User",
   }

========== ======  =====================================================
name       type    description
========== ======  =====================================================
id         int     The unique integer ID that Bugzilla uses to represent
                   this user. Even if the user's login name changes,
                   this will not change.
real_name  string  The actual name of the user. May be blank.
name       string  string  The login name of the user.
========== ======  =====================================================