Skip to content

Latest commit

 

History

History
76 lines (62 loc) · 2.42 KB

user.md

File metadata and controls

76 lines (62 loc) · 2.42 KB

User

Model definition

Required attributes:

  • login / id (string) : login of the user
  • userName (text) : Full name of the user
  • roles (multi-userRole) : Array containing roles of the user (read, write or admin)
  • status (userStatus) : Ok or Locked default=Ok
  • preference (string) : JSON object containing user preference default={}

Optional attributes:

  • avatar (string) : avatar of user. It is an image encoded in base 64
  • password (string) : user password if local authentication is used

Attributes generated by the backend:

  • key (uuid) : API key to authenticate this user (deprecated)

User Manipulation

User methods

HTTP Method URI Action
GET /api/logout Logout
POST /api/login User login
GET /api/user/current Get current user
POST /api/user/_search Find user
POST /api/user Create a user
GET /api/user/:userId Get a user
DELETE /api/user/:userId Delete a user
PATCH /api/user/:userId Update user details
POST /api/user/:userId/password/set Set password
POST /api/user/:userId/password/change Change password
  • with-key (boolean)

Create a User

A user can be created using the following URL:

POST     /api/user

Required case attributes (cf. models) must be provided.

This call returns attributes of the created user.

This call is authenticated and requires admin role.

Examples

Creation of a user:

curl -XPOST -H 'Authorization: Bearer ***API*KEY***' -H 'Content-Type: application/json' http://127.0.0.1:9000/api/user -d '{
  "login": "georges",
  "name": "Georges Abitbol",
  "roles": ["read", "write"],
  "password": "La classe"
}'

It returns:

{
  "createdBy": "myuser",
  "name":"Georges Abitbol",
  "roles": ["read", "write" ],
  "_id": "georges",
  "user": "myuser",
  "createdAt": 1496561862924,
  "status": "Ok",
  "id": "georges",
  "_type": "user",
  "has-key":false
}

If external authentication is used (LDAP or AD) password field must not be provided.