User Management API
Endpoints to perform user and session management
Auth ¶
Session management ¶
Create sessionPOST/
Authenticate with the system, returning a session token to be used with API
Example URI
Headers
Content-Type: application/json
Body
{
"username": "testadm",
"passwd": "admin"
}
200
Headers
Content-Type: application/json
Body
{
"jwt": "eyJhb ... pXVCJ9.eyJpc ... 3MIn0.j1iYHo ... yae88PvodY"
}
400
Headers
Content-Type: application/json
Body
{
"status": 400,
"message": "invalid mimetype"
}
400
Headers
Content-Type: application/json
Body
{
"status": 400,
"message": "missing passswd"
}
400
Headers
Content-Type: application/json
Body
{
"status": 400,
"message": "missing username"
}
400
Headers
Content-Type: application/json
Body
{
"message": "not authorized",
"status": 401
}
Known users manipulation ¶
List known usersGET/user
Lists all users known to the platform
Example URI
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"users": [
{
"created_by": "0",
"created_date": "2018-01-03 12:49:25.717374",
"email": "admin@noemail.com",
"id": "1",
"name": "Admin (superuser)",
"profile": "testadm",
"service": "admin",
"username": "testadm"
},
{
"created_by": "1",
"created_date": "2018-01-04 13:09:03.568749",
"email": "test@noemail.com",
"id": "2",
"name": "test",
"profile": "testuser",
"service": "test",
"username": "test"
}
]
}
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized"
}
Register a new userPOST/user
Creates a new user, assigning it a service.
Service is the token that associates the user with the set of devices and flows it has access to.
Example URI
Headers
Content-Type: application/json
Authorization: Bearer JWT
Body
{
"username": "test",
"service": "test",
"email": "test@noemail.com",
"name": "test",
"profile": "testuser"
}
200
Headers
Content-Type: application/json
Body
[
{
"user": {
"id": "2",
"name": "test",
"username": "test",
"service": "test",
"email": "test@noemail.com",
"profile": "testuser",
"created_date": "2018-01-04 13:09:03.568749",
"created_by": "0"
},
"groups": [
"testuser"
],
"could not add": [],
"message": "user created"
}
]
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized"
}
Individual user settings ¶
Access a user’s authorization and identification information
Get user infoGET/user/{id}
Retrieves all information from a specific registered user
Example URI
- id
string
(required) Example: 1The user ID
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"user": {
"created_by": "0",
"created_date": "2018-01-03 12:49:25.717374",
"email": "testadm@noemail.com",
"id": "1",
"name": "testadm",
"profile": "testadm",
"service": "admin",
"username": "testadm"
}
}
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized"
}
404
Headers
Content-Type: application/json
Body
{
"message": "No user found with this ID",
"status": 404
}
Update user infoPUT/user/{id}
Replaces user information. Fields or attributes that are not informed will revert to their defaults.
Example URI
- id
string
(required) Example: 1The user ID
Headers
Content-Type: application/json
Authorization: Bearer JWT
Body
{
"service": "test",
"email": "test_new@noemail.com",
"name": "test"
}
200
Headers
Content-Type: application/json
Body
{
"message": "ok",
"status": 200
}
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized"
}
404
Headers
Content-Type: application/json
Body
{
"message": "Unknown user id",
"status": 404
}
Remove userDELETE/user/{id}
Removes a user from the system
Example URI
- id
string
(required) Example: 1The user ID
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"message": "User removed",
"status": 200
}
401
Headers
Content-Type: application/json
Body
{
"message": "Unauthorized"
}
404
Headers
Content-Type: application/json
Body
{
"message": "User was not found",
"status": 200
}
List tenant services ¶
List all known tenants in dojot
This is an internal call used for debugging, and for service initialization procedure. Hence only calls issued from within the platform will be accepted.
List tenantsGET/admin/tenants
List all tenants currently configured in dojot
Example URI
200
Headers
Content-Type: application/json
Body
{
"tenants": [
"admin",
"test"
]
}
FORMAT: 1A
CRUD Permissions and Group ¶
Permissions creation and search ¶
Create a new permissionPOST/pap/permission
Notice that regular expressions can be used on the ‘path’ and ‘method’ fields, and all slashes that serve to escape some characters (’*’, in the example) must also be escaped
Example URI
Headers
Content-Type: application/json
Authorization: Bearer JWT
Body
{
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit",
"name": "device_write_operations"
}
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"id": 131
}
Search permissionGET/pap/permission?{path,method,permission,type}
Example URI
- path
string
(optional) Example: \/devices\/infoa path string.
- method
enum
(optional) Example: POSTone HTTP method.
- permission
enum
(optional) Example: permit“permit” or “deny”.
- type
enum
(optional) Example: api“api” or “system”
Headers
Content-Type: application/json
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"permissions": [
{
"id": 131,
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit",
"type": "api"
}
]
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No permission found with these filters"
}
Permissions management ¶
Get a permissionGET/pap/permission/{id}
Example URI
- id
integer
(required) Example: 1The permission ID
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"id": 131,
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit",
"type": "api"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No permission found with this ID"
}
Update a permissionPUT/pap/permission/{id}
Example URI
- id
integer
(required) Example: 1The permission ID
Headers
Content-Type: application/json
Authorization: Bearer JWT
Body
{
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit",
"name": "sample_permission"
}
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No permission with found this ID"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No permission with found this ID"
}
405
Headers
Content-Type: application/json
Body
{
"status": 405,
"message": "Can't edit a system permission"
}
Remove a permissionDELETE/pap/permission/{id}
Example URI
- id
integer
(required) Example: 1The permission ID
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No permission found with this ID"
}
405
Headers
Content-Type: application/json
Body
{
"status": 405,
"message": "Can't delete a system permission"
}
Group creation ¶
Create a new groupPOST/pap/group
Example URI
Headers
Content-Type: application/json
Authorization: Bearer JWT
Body
{
"name": "group1",
"description": "a fine group"
}
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"id": 3
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "Group named group1 already exists"
}
Search GroupsGET/pap/group?name={name}
Example URI
- name
string
(optional) Example: testadma group name, or part of a group name.
200
Headers
Content-Type: application/json
Body
{
"groups": [
{
"id": 3,
"name": "testadm",
"description": "Full privilege group"
}
]
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with these filters"
}
Group management ¶
Get a groupGET/pap/group/{id}
Example URI
- id
integer
(required) Example: 1group ID
200
Headers
Content-Type: application/json
Body
{
"id": 3,
"name": "group1",
"description": null
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with this ID"
}
Update a groupPUT/pap/group/{id}
Example URI
- id
integer
(required) Example: 1group ID
Headers
Content-Type: application/json
Authorization: Bearer JWT
Body
{
"name": "testadm",
"description": "projectX"
}
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with this ID"
}
405
Headers
Content-Type: application/json
Body
{
"status": 405,
"message": "Can't edit admin group"
}
Remove a groupDELETE/pap/group/{id}
Example URI
- id
integer
(required) Example: 1group ID
Headers
Content-Type: application/json
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with this ID"
}
405
Headers
Content-Type: application/json
Body
{
"status": 405,
"message": "Can't delete admin group""
}
FORMAT: 1A
Relationship management ¶
Manage relationships between users and groups ¶
Add user to groupPOST/pap/usergroup/{user_id}/{group_id}
Example URI
- user_id
string
(required) Example: 1The user ID
- group_id
string
(required) Example: 101The group ID
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No user found with this ID"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with this ID"
}
Remove a user from groupDELETE/pap/usergroup/{user_id}/{group_id}
Example URI
- user_id
string
(required) Example: 1The user ID
- group_id
string
(required) Example: 101The group ID
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No user found with this ID"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with this ID"
}
404
Headers
Content-Type: application/json
Body
{
"status": 400,
"message": "Can't remove user. A user must always be in one role group"
}
Manage relationships between users and permissions ¶
Give a permission to a userPOST/pap/userpermissions/{user_id}/{permission_id}
Example URI
- user_id
string
(required) Example: 1The user ID
- permission_id
string
(required) Example: 201The permission ID to be changed
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No user found with this ID"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No permission found with this ID"
}
Revoke a user permissionDELETE/pap/userpermissions/{user_id}/{permission_id}
Example URI
- user_id
string
(required) Example: 1The user ID
- permission_id
string
(required) Example: 201The permission ID to be changed
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No user found with this ID"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No permission found with this ID"
}
Manage relationships between group and permissions ¶
Give a permission to a groupPOST/pap/grouppermissions/{group_id}/{permission_id}
Example URI
- group_id
string
(required) Example: 101The group ID
- permission_id
string
(required) Example: 201The permission ID to be changed
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with this ID"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No permission found with this ID"
}
Revoke a group permissionDELETE/pap/grouppermissions/{group_id}/{permission_id}
Example URI
- group_id
string
(required) Example: 101The group ID
- permission_id
string
(required) Example: 201The permission ID to be changed
Headers
Authorization: Bearer JWT
200
Headers
Content-Type: application/json
Body
{
"status": 200,
"message": "ok"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with this ID"
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No permission found with this ID"
}
FORMAT: 1A
Reports ¶
User direct permissions ¶
Retrieve user direct permissionsGET/pap/user/{user}/directpermissions
Example URI
- user
string
(required) Example: testadmuser being requested.
200
Headers
Content-Type: application/json
Body
{
"permissions": [
{
"id": 130,
"path": "/exceptional/path\\*",
"method": "POST|PUT|DELETE",
"permission": "permit"
},
{
"id": 136,
"path": "/cantaccess",
"method": "\\*",
"permission": "deny"
}
]
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No user found with tihs username or ID"
}
All user permissions ¶
Retrieve all user permissionsGET/pap/user/{user}/allpermissions
Example URI
- user
string
(required) Example: testadmuser being requested.
200
Headers
Content-Type: application/json
Body
{
"permissions": [
{
"id": 131,
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit"
},
{
"id": 132,
"path": "/auth/user",
"method": "\\*",
"permission": "deny"
}
]
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No user found with tihs username or ID"
}
User groups ¶
Retrieve all user groupsGET/pap/user/{user}/groups
Example URI
- user
string
(required) Example: testadmuser being requested.
200
Headers
Content-Type: application/json
Body
{
"groups": [
{
"id": 3,
"name": "group1"
},
{
"id": 4,
"name": "testadm"
}
]
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No user found with tihs username or ID"
}
Group permissions ¶
Retrieve all group permissionsGET/pap/group/{group}/permissions
Example URI
- group
string
(required) Example: usersuser being requested.
200
Headers
Content-Type: application/json
Body
{
"permissions": [
{
"id": 131,
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit"
},
{
"id": 132,
"path": "/auth/user",
"method": "\\*",
"permission": "deny"
}
]
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with this name or ID"
}
Group users ¶
Retrieve all users from a groupGET/pap/group/{group}/users
Example URI
- group
string
(required) Example: usersuser being requested.
200
Headers
Content-Type: application/json
Body
{
"users": [
{
"id": 3252352,
"name": "Alexandre Vasconcellos",
"email": "alex@noemai.com",
"username": "aexv",
"service": "user"
},
{
"id": 1124235532,
"name": "John Wayne",
"email": "wayne@company.com",
"username": "johnw",
"service": "user"
}
]
}
404
Headers
Content-Type: application/json
Body
{
"status": 404,
"message": "No group found with this name or ID"
}