NGSI Go tutorial for Keyrock
Identity Management
Get settings of alias
ngsi server get --host keyrock
ngsi server get --host keyrock
serverType keyrock
serverHost http://keyrock:3000
IdmType idm
IdmHost http://keyrock:3000/v1/auth/tokens
Username keyrock@letsfiware.jp
Password 1234
Get version
ngsi version --host keyrock --pretty
{
"keyrock": {
"version": "7.0.1",
"release_date": "2018-06-25",
"uptime": "01:51:01.1",
"git_hash": "https://github.com/ging/fiware-idm/releases/tag/7.0.1",
"doc": "https://fiware-idm.readthedocs.io/en/7.0.1/",
"api": {
"version": "v1",
"link": "https://keyrock.e-suda.info/v1"
}
}
}
Get a token
ngsi token --host keyrock
871d471b-1ed2-4c80-b8f5-a4439cf26f51
Create a user
ngsi users create --username alice --email alice@test.com --password test --pretty
{
"user": {
"id": "8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9",
"image": "default",
"gravatar": false,
"enabled": true,
"admin": false,
"starters_tour_ended": false,
"eidas_id": null,
"username": "alice",
"email": "alice@test.com",
"salt": "94416345423767ac",
"date_password": "2021-02-21T01:07:57.806Z"
}
}
ngsi users create --username bob --email bob-the-manager@test.com --password test
9813fa3e-bc32-4466-8c97-a60a4e61735b
ngsi users create --username charlie --email charlie-security@test.com --password test
cb4242ca-8f8f-4162-9fc8-3a8a9dd10977
ngsi users create --username manager1 --email manager1@test.com --password test
86d68660-7b83-454a-b49b-b4cba1842542
ngsi users create --username manager2 --email manager2@test.com --password test
a66bb706-60f7-413a-8380-d2ced6e295ab
ngsi users create --username detective1 --email detective1@test.com --password test
fdd692b8-bc08-4b88-a189-8dce222ed770
ngsi users create --username detective2 --email detective2@test.com --password test
ddb88540-b7cc-4c9e-b927-a6ae65b7e36f
Get all users
ngsi users list --pretty
{
"users": [
{
"scope": [],
"id": "86d68660-7b83-454a-b49b-b4cba1842542",
"username": "manager1",
"email": "manager1@test.com",
"enabled": true,
"gravatar": false,
"date_password": "2021-02-21T01:10:40.000Z",
"description": null,
"website": null
},
{
"scope": [],
"id": "8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9",
"username": "alice",
"email": "alice@test.com",
"enabled": true,
"gravatar": false,
"date_password": "2021-02-21T01:07:57.000Z",
"description": null,
"website": null
},
{
"scope": [],
"id": "9813fa3e-bc32-4466-8c97-a60a4e61735b",
"username": "bob",
"email": "bob-the-manager@test.com",
"enabled": true,
"gravatar": false,
"date_password": "2021-02-21T01:09:21.000Z",
"description": null,
"website": null
},
{
"scope": [],
"id": "a66bb706-60f7-413a-8380-d2ced6e295ab",
"username": "manager2",
"email": "manager2@test.com",
"enabled": true,
"gravatar": false,
"date_password": "2021-02-21T01:10:46.000Z",
"description": null,
"website": null
},
{
"scope": [],
"id": "admin",
"username": "admin",
"email": "keyrock@letsfiware.jp",
"enabled": true,
"gravatar": false,
"date_password": "2021-02-21T01:05:37.000Z",
"description": null,
"website": null
},
{
"scope": [],
"id": "cb4242ca-8f8f-4162-9fc8-3a8a9dd10977",
"username": "charlie",
"email": "charlie-security@test.com",
"enabled": true,
"gravatar": false,
"date_password": "2021-02-21T01:09:57.000Z",
"description": null,
"website": null
},
{
"scope": [],
"id": "ddb88540-b7cc-4c9e-b927-a6ae65b7e36f",
"username": "detective2",
"email": "detective2@test.com",
"enabled": true,
"gravatar": false,
"date_password": "2021-02-21T01:11:15.000Z",
"description": null,
"website": null
},
{
"scope": [],
"id": "fdd692b8-bc08-4b88-a189-8dce222ed770",
"username": "detective1",
"email": "detective1@test.com",
"enabled": true,
"gravatar": false,
"date_password": "2021-02-21T01:11:09.000Z",
"description": null,
"website": null
}
]
}
Get a user
ngsi users get --uid 8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9 --pretty
{
"user": {
"scope": [],
"id": "8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9",
"username": "alice",
"email": "alice@test.com",
"enabled": true,
"admin": false,
"image": "default",
"gravatar": false,
"date_password": "2021-02-21T01:07:57.000Z",
"description": null,
"website": null
}
}
Update a user
ngsi users update --uid 8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9 --description "Alice works for FIWARE"
{
"values_updated": {
"description": "Alice works for FIWARE"
}
}
ngsi users get --uid 8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9 --pretty
{
"user": {
"scope": [],
"id": "8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9",
"username": "alice",
"email": "alice@test.com",
"enabled": true,
"admin": false,
"image": "default",
"gravatar": false,
"date_password": "2021-02-21T01:07:57.000Z",
"description": "Alice works for FIWARE",
"website": null
}
}
Create an organization
ngsi organizations create --name Security --description "This group is for the store detectives"
c2ad7373-a166-4b6f-9f51-a9af7ecf919e
Get an organization
ngsi organizations get --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e --pretty
{
"organization": {
"id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"name": "Security",
"description": "This group is for the store detectives",
"website": null,
"image": "default"
}
}
List all organizations
ngsi organizations list --pretty
{
"organizations": [
{
"role": "owner",
"Organization": {
"id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"name": "Security",
"description": "This group is for the store detectives",
"image": "default",
"website": null
}
}
]
}
Update an organization
ngsi organizations update --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e \
--name "FIWARE Security" \
--description "The FIWARE Foundation is the .." \
--website "https://fiware.org"
{
"values_updated": {
"name": "FIWARE Security",
"description": "The FIWARE Foundation is the ..",
"website": "https://fiware.org"
}
}
ngsi organizations get --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e --pretty
{
"organization": {
"id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"name": "FIWARE Security",
"description": "The FIWARE Foundation is the ..",
"website": "https://fiware.org",
"image": "default"
}
}
Add a user as a member of an organization
ngsi organizations users --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e list
admin
ngsi organizations users --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e \ create --uid 8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9 --orid member --pretty
{
"user_organization_assignments": {
"role": "member",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"user_id": "8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9"
}
}
ngsi organizations users --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e list --pretty
{
"organization_users": [
{
"user_id": "admin",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"role": "owner"
},
{
"user_id": "8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"role": "member"
}
]
}
Add a user as an owner of an organization
ngsi organizations users --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e \
add --uid 9813fa3e-bc32-4466-8c97-a60a4e61735b --orid owner --pretty
```json
{
"user_organization_assignments": {
"role": "owner",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"user_id": "9813fa3e-bc32-4466-8c97-a60a4e61735b"
}
}
ngsi organizations users --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e list --pretty
{
"organization_users": [
{
"user_id": "admin",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"role": "owner"
},
{
"user_id": "8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"role": "member"
},
{
"user_id": "9813fa3e-bc32-4466-8c97-a60a4e61735b",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"role": "owner"
}
]
}
Read user roles within an organizatioN
ngsi organizations users --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e \
get --uid 9813fa3e-bc32-4466-8c97-a60a4e61735b --pretty
{
"organization_user": {
"user_id": "9813fa3e-bc32-4466-8c97-a60a4e61735b",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"role": "owner"
}
}
Remove a user from an organization
ngsi organizations users --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e \
remove --uid 9813fa3e-bc32-4466-8c97-a60a4e61735b --orid owner
ngsi organizations users --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e list --pretty
{
"organization_users": [
{
"user_id": "admin",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"role": "owner"
},
{
"user_id": "8f0f155a-3ea1-4871-99ea-a1eb61bbf9f9",
"organization_id": "c2ad7373-a166-4b6f-9f51-a9af7ecf919e",
"role": "member"
}
]
}
Delete an organizatioN
ngsi organizations delete --oid c2ad7373-a166-4b6f-9f51-a9af7ecf919e
ngsi organizations list
Organizations not found