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/jsonBody
{
"username": "admin",
"passwd": "admin"
}200Headers
Content-Type: application/jsonBody
{
"jwt": "eyJhb ... pXVCJ9.eyJpc ... 3MIn0.j1iYHo ... yae88PvodY"
}400Headers
Content-Type: application/jsonBody
{
"status": 400,
"message": "invalid mimetype"
}400Headers
Content-Type: application/jsonBody
{
"status": 400,
"message": "missing passswd"
}400Headers
Content-Type: application/jsonBody
{
"status": 400,
"message": "missing username"
}400Headers
Content-Type: application/jsonBody
{
"message": "not authorized",
"status": 401
}Known users manipulation ¶
List known usersGET/user
Lists all users known to the platform
Example URI
Headers
Authorization: Bearer JWT200Headers
Content-Type: application/jsonBody
{
"users": [
{
"created_by": "0",
"created_date": "2018-01-03 12:49:25.717374",
"email": "admin@noemail.com",
"id": "1",
"name": "Admin (superuser)",
"profile": "admin",
"service": "admin",
"username": "admin"
},
{
"created_by": "1",
"created_date": "2018-01-04 13:09:03.568749",
"email": "test@noemail.com",
"id": "2",
"name": "test",
"profile": "user",
"service": "test",
"username": "test"
}
]
}401Headers
Content-Type: application/jsonBody
{
"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 JWTBody
{
"username": "test",
"service": "test",
"email": "test@noemail.com",
"name": "test",
"profile": "user"
}200Headers
Content-Type: application/jsonBody
[
{
"user": {
"id": "2",
"name": "test",
"username": "test",
"service": "test",
"email": "test@noemail.com",
"profile": "user",
"created_date": "2018-01-04 13:09:03.568749",
"created_by": "0"
},
"groups": [
"user"
],
"could not add": [],
"message": "user created"
}
]401Headers
Content-Type: application/jsonBody
{
"message": "Unauthorized"
}Individual user settings ¶
Access a user’s authorization and identification information
Get user infoGET/user/
Retrieves all information from a specific registered user
Example URI
Headers
Authorization: Bearer JWT200Headers
Content-Type: application/jsonBody
{
"user": {
"created_by": "0",
"created_date": "2018-01-03 12:49:25.717374",
"email": "admin@noemail.com",
"id": "1",
"name": "Admin (superuser)",
"profile": "admin",
"service": "admin",
"username": "admin"
}
}401Headers
Content-Type: application/jsonBody
{
"message": "Unauthorized"
}404Headers
Content-Type: application/jsonBody
{
"message": "No user found with this ID",
"status": 404
}Update user infoPUT/user/
Replaces user information. Fields or attributes that are not informed will revert to their defaults.
Example URI
Headers
Content-Type: application/json
Authorization: Bearer JWTBody
{
"service": "test",
"email": "test_new@noemail.com",
"name": "test",
"profile": "user"
}200Headers
Content-Type: application/jsonBody
{
"message": "ok",
"status": 200
}401Headers
Content-Type: application/jsonBody
{
"message": "Unauthorized"
}404Headers
Content-Type: application/jsonBody
{
"message": "Unknown user id",
"status": 404
}Remove userDELETE/user/
Removes a user from the system
Example URI
Headers
Authorization: Bearer JWT200Headers
Content-Type: application/jsonBody
{
"message": "User removed",
"status": 200
}401Headers
Content-Type: application/jsonBody
{
"message": "Unauthorized"
}404Headers
Content-Type: application/jsonBody
{
"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
200Headers
Content-Type: application/jsonBody
{
"tenants": [
"admin",
"test"
]
}
FORMAT: 1ACRUD 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 JWTBody
{
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit",
"name": "device_write_operations"
}200Headers
Content-Type: application/jsonBody
{
"status": 200,
"id": 131
}Search permissionGET/pap/permission?{path,method,permission}
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”.
Headers
Content-Type: application/json
Authorization: Bearer JWT200Headers
Content-Type: application/jsonBody
{
"permissions": [
{
"id": 131,
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit"
}
]
}404Headers
Content-Type: application/jsonBody
{
"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 JWT200Headers
Content-Type: application/jsonBody
{
"id": 131,
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit"
}404Headers
Content-Type: application/jsonBody
{
"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 JWTBody
{
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit",
"name": "sample_permission"
}200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No permission with found this ID"
}Remove a permissionDELETE/pap/permission/{id}
Example URI
- id
integer(required) Example: 1The permission ID
Headers
Authorization: Bearer JWT200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No permission found with this ID"
}Group creation ¶
Create a new groupPOST/pap/group
Example URI
Headers
Content-Type: application/json
Authorization: Bearer JWTBody
{
"name": "group1",
"description": "a fine group"
}200Headers
Content-Type: application/jsonBody
{
"status": 200,
"id": 3
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "Group named group1 already exists"
}Search GroupsGET/pap/group?name={name}
Example URI
- name
string(optional) Example: admina group name, or part of a group name.
200Headers
Content-Type: application/jsonBody
{
"groups": [
{
"id": 3,
"name": "admin",
"description": "Full privilege group"
}
]
}404Headers
Content-Type: application/jsonBody
{
"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
200Headers
Content-Type: application/jsonBody
{
"id": 3,
"name": "group1",
"description": null
}404Headers
Content-Type: application/jsonBody
{
"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 JWTBody
{
"name": "admin",
"description": "projectX"
}200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No group found with this ID"
}Remove a groupDELETE/pap/group/{id}
Example URI
- id
integer(required) Example: 1group ID
Headers
Content-Type: application/json
Authorization: Bearer JWT200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No group found with this ID"
}
FORMAT: 1ARelationship 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 JWT200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No user found with this ID"
}404Headers
Content-Type: application/jsonBody
{
"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 JWT200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No user found with this ID"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No group found with this ID"
}404Headers
Content-Type: application/jsonBody
{
"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 JWT200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No user found with this ID"
}404Headers
Content-Type: application/jsonBody
{
"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 JWT200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No user found with this ID"
}404Headers
Content-Type: application/jsonBody
{
"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 JWT200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No group found with this ID"
}404Headers
Content-Type: application/jsonBody
{
"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 JWT200Headers
Content-Type: application/jsonBody
{
"status": 200,
"message": "ok"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No group found with this ID"
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No permission found with this ID"
}
FORMAT: 1AReports ¶
User direct permissions ¶
Retrieve user direct permissionsGET/pap/user/{user}/directpermissions
Example URI
- user
string(required) Example: adminuser being requested.
200Headers
Content-Type: application/jsonBody
{
"permissions": [
{
"id": 130,
"path": "/exceptional/path\\*",
"method": "POST|PUT|DELETE",
"permission": "permit"
},
{
"id": 136,
"path": "/cantaccess",
"method": "\\*",
"permission": "deny"
}
]
}404Headers
Content-Type: application/jsonBody
{
"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: adminuser being requested.
200Headers
Content-Type: application/jsonBody
{
"permissions": [
{
"id": 131,
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit"
},
{
"id": 132,
"path": "/auth/user",
"method": "\\*",
"permission": "deny"
}
]
}404Headers
Content-Type: application/jsonBody
{
"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: adminuser being requested.
200Headers
Content-Type: application/jsonBody
{
"groups": [
{
"id": 3,
"name": "group1"
},
{
"id": 4,
"name": "admin"
}
]
}404Headers
Content-Type: application/jsonBody
{
"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.
200Headers
Content-Type: application/jsonBody
{
"permissions": [
{
"id": 131,
"path": "/devices/info/\\*",
"method": "POST|PUT|DELETE",
"permission": "permit"
},
{
"id": 132,
"path": "/auth/user",
"method": "\\*",
"permission": "deny"
}
]
}404Headers
Content-Type: application/jsonBody
{
"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.
200Headers
Content-Type: application/jsonBody
{
"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"
}
]
}404Headers
Content-Type: application/jsonBody
{
"status": 404,
"message": "No group found with this name or ID"
}