From 1bb07f0227b05494104dd2235d07e6a562cb1561 Mon Sep 17 00:00:00 2001 From: Filip Bucek Date: Mon, 30 Sep 2019 13:19:03 +0200 Subject: [PATCH 1/5] restapi: added info about endpoinst + openapi 3.0 description --- README.md | 32 ++++++++++- openapi-testserver.yaml | 117 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 openapi-testserver.yaml diff --git a/README.md b/README.md index 96467dc..ca64db4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,34 @@ # colnod-connector +Acces Management System of Colsys: [Product info](http://produkty.colsys.cz/colnod/) -## Colnod +## RestAPI definitions -Acces Management System of Colsys: [Product info](http://produkty.colsys.cz/colnod/) \ No newline at end of file +- `openapi.yaml` ( editor `VSCode` with `Swagger Viewer` extension - ⌘+⇧+P `Preview Swagger` ) + +## Colnod Test server + +[Colnod server: confluence](https://spaceti.atlassian.net/wiki/spaces/IN/pages/97320961/Colsys+-+Colnod) + +- URL: `192.168.1.3:8843` +- `!!! No license!!!` - server will shutdown after 8 hours. + - restart: `sudo service cndserver start` + - check `nmap -p8443 192.168.1.3` or `nc -zvw3 192.168.1.3 8443` + - user: `spaceti` + - password: `` + - sha512: `E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0` + +```bash +curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0" -d '{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}' -H "Content-Type: application/json" https://192.168.1.3:8443/AaaManager/authSession +``` + +## Colnod Penta server + +- Acces through: `penta-master` IP:`172.16.3.4` +- URL: `192.168.254.11:8443` +- Port forwarding: `ssh -L 8443:192.168.254.11:8443 penta-master` + - `!!! does not work !!!` + +```bash +curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0" -d '{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}' -H "Content-Type: application/json" https://192.168.254.11:8443/AaaManager/authSession +``` diff --git a/openapi-testserver.yaml b/openapi-testserver.yaml new file mode 100644 index 0000000..c62d493 --- /dev/null +++ b/openapi-testserver.yaml @@ -0,0 +1,117 @@ +openapi: 3.0.0 +info: + description: "Colnod system: [Product information](http://produkty.colsys.cz/colnod) +Jira issues: + [Communicaiton with + Colnod](https://spaceti.atlassian.net/secure/RapidBoard.jspa?rapidView=78&p\ + rojectKey=INT&modal=detail&selectedIssue=INT-3563)" + version: 1.0.0 + title: Colnod server + contact: + name: Filip Bucek + email: filip.bucek@spaceti.com + +servers: + - url: http://192.168.1.3:8443 + +tags: + - name: login + description: Login information ( token ) + - name: user + description: Operations about user + - name: token + description: Working with tokens ( keys ) +paths: + /AaaManager/authSession: + post: + summary: Login user + description: Loging using sha512 hash + requestBody: + description: Optional description in *Markdown* + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/Login' + # content: + # "*/*": + # schema: + # $ref: "#/components/schemas/Login" + tags: + - login + # parameters: + # username: spaceti + # password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0 + responses: + "200": + description: Login success + content: + "*/*": + schema: + $ref: "#/components/schemas/Token" + "400": + description: "" + content: + "*/*": + schema: + $ref: "#/components/schemas/Token" + /SubjectManager/getSubjects: + get: + summary: Get subjects + tags: + - user + responses: + "200": + description: xxxxx + /TokenManager/getTokens: + get: + tags: + - token + responses: + "200": + description: xxxxx + /TokenManager/setTokens: + delete: + tags: + - token + responses: + "200": + description: xxxxx +components: + securitySchemes: + basicAuth: # <-- arbitrary name for the security scheme + type: http + scheme: basic + + + # petstore_auth: + # type: oauth2 + # flows: + # implicit: + # authorizationUrl: http://petstore.swagger.io/oauth/dialog + # scopes: + # write:pets: modify pets in your account + # read:pets: read your pets + # api_key: + # type: apiKey + # name: api_key + # in: header + schemas: + Login: + type: object + properties: + username: + type: string + password: + type: string + + Token: + type: object + properties: + tokenType: + type: string + tokenBits: + type: integer + +# security: +# - basicAuth: [d] # <-- use the same name here \ No newline at end of file From fdc6ec96d74f4698c6f2d4eda64b3d731cb57c78 Mon Sep 17 00:00:00 2001 From: Filip Bucek Date: Mon, 30 Sep 2019 17:23:11 +0200 Subject: [PATCH 2/5] Adding snowboard Blueprint API tool --- README.md | 12 ++++++++ colnod.apib | 63 +++++++++++++++++++++++++++++++++++++++++ openapi-testserver.yaml | 18 ++++++++---- snowboard.yml | 30 ++++++++++++++++++++ 4 files changed, 117 insertions(+), 6 deletions(-) create mode 100644 colnod.apib create mode 100644 snowboard.yml diff --git a/README.md b/README.md index ca64db4..5f6c816 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,15 @@ curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E847 ```bash curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0" -d '{"password":"E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0","username":"spaceti"}' -H "Content-Type: application/json" https://192.168.254.11:8443/AaaManager/authSession ``` + +## Testing Blueprint API + +### Snowboard + +`snowboard http -c snowboard.yml --playground colnod.apib` + +[Colnod API snowboard documentation](http://localhost:8088) + +#### Install snowboard + +`npm install -g snowboard` diff --git a/colnod.apib b/colnod.apib new file mode 100644 index 0000000..e818665 --- /dev/null +++ b/colnod.apib @@ -0,0 +1,63 @@ +FORMAT: 1A + +# JSON Schema +Every request and response can have a schema. Below you will find examples +using [JSON Schema](http://json-schema.org/) to describe the format of request +and response body content. + + +# Notes [/AaaManager/authSession] + ++ Body + + + username: spaceti (required) - User identifier + + password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0 (required) - sha512 password + +## Get a note [POST] +Gets a single note by its unique identifier. + ++ Request (application/json) + + + Body + + { + "user": "String", + "password": "String ", + } + + + Schema + + { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "password": { + "type": "string" + }, + } + } + ++ Response 200 (application/json) + + + Body + + { + "id": "String", + "token": "String ", + } + + + Schema + + { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "token": { + "type": "string" + }, + } + } \ No newline at end of file diff --git a/openapi-testserver.yaml b/openapi-testserver.yaml index c62d493..512fcdb 100644 --- a/openapi-testserver.yaml +++ b/openapi-testserver.yaml @@ -12,7 +12,7 @@ Jira issues: email: filip.bucek@spaceti.com servers: - - url: http://192.168.1.3:8443 + - url: https://192.168.1.3:8443 tags: - name: login @@ -26,6 +26,8 @@ paths: post: summary: Login user description: Loging using sha512 hash + security: + - basicAuth: [spaceti] requestBody: description: Optional description in *Markdown* required: true @@ -46,13 +48,13 @@ paths: "200": description: Login success content: - "*/*": + application/json: schema: $ref: "#/components/schemas/Token" "400": description: "" content: - "*/*": + application/json: schema: $ref: "#/components/schemas/Token" /SubjectManager/getSubjects: @@ -102,16 +104,20 @@ components: properties: username: type: string + example: spaceti password: type: string + example: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0 Token: type: object properties: - tokenType: + id: type: string - tokenBits: - type: integer + example: spaceti + token: + type: string + example: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0 # security: # - basicAuth: [d] # <-- use the same name here \ No newline at end of file diff --git a/snowboard.yml b/snowboard.yml new file mode 100644 index 0000000..9714a41 --- /dev/null +++ b/snowboard.yml @@ -0,0 +1,30 @@ +html: + playground: + enabled: true + env: development + environments: + development: + url: https://192.168.1.3:8443 + auth: + name: basic + options: + username: spaceti + password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0 + staging: + url: https://staging.example.com/ + auth: + name: basic + options: + username: admin + password: secret + production: + url: https://api.example.com + auth: + name: oauth2 + options: + authorizeUrl: https://accounts.example.com/oauth/authorize + tokenUrl: https://accounts.example.com/oauth/access_token + callbackUrl: https://www.example.com + clientId: + clientSecret: + scopes: \ No newline at end of file From f8e2593299abb9fb052ddc9dca39da32b7117041 Mon Sep 17 00:00:00 2001 From: Filip Bucek Date: Mon, 30 Sep 2019 18:14:14 +0200 Subject: [PATCH 3/5] working snowboard API --- README.md | 9 +++++++++ colnod.apib | 9 ++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5f6c816..07bf64f 100644 --- a/README.md +++ b/README.md @@ -37,10 +37,19 @@ curl -k --user "spaceti:E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E847 ### Snowboard +#### Necesarry to allow + +- Self signed certificate: [Stack overflow](https://superuser.com/a/1235250) +- Enable CORS: + - Safari: Develop->Disable cross origin restrictions + `snowboard http -c snowboard.yml --playground colnod.apib` [Colnod API snowboard documentation](http://localhost:8088) + + + #### Install snowboard `npm install -g snowboard` diff --git a/colnod.apib b/colnod.apib index e818665..a5e59a8 100644 --- a/colnod.apib +++ b/colnod.apib @@ -8,11 +8,6 @@ and response body content. # Notes [/AaaManager/authSession] -+ Body - - + username: spaceti (required) - User identifier - + password: E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0 (required) - sha512 password - ## Get a note [POST] Gets a single note by its unique identifier. @@ -21,8 +16,8 @@ Gets a single note by its unique identifier. + Body { - "user": "String", - "password": "String ", + "password": "E7FEA07DBC82FB9BA34B2E453E2EFE89F0583E7187543507EF11E84726071FE428445372F2E46B455EB0C79747C51E362F403CE39473A2A8C2DFA0CE5C9826C0", + "username": "spaceti" } + Schema From 6736fab27d58855a257e74f1e9fc07bc67d5d3b7 Mon Sep 17 00:00:00 2001 From: Filip Bucek Date: Mon, 30 Sep 2019 18:20:05 +0200 Subject: [PATCH 4/5] Update response --- colnod.apib | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/colnod.apib b/colnod.apib index a5e59a8..3ffe29f 100644 --- a/colnod.apib +++ b/colnod.apib @@ -5,10 +5,9 @@ Every request and response can have a schema. Below you will find examples using [JSON Schema](http://json-schema.org/) to describe the format of request and response body content. +# Login manager [/AaaManager/authSession] -# Notes [/AaaManager/authSession] - -## Get a note [POST] +## Get login token [POST] Gets a single note by its unique identifier. + Request (application/json) @@ -40,7 +39,6 @@ Gets a single note by its unique identifier. { "id": "String", - "token": "String ", } + Schema @@ -50,9 +48,6 @@ Gets a single note by its unique identifier. "properties": { "id": { "type": "string" - }, - "token": { - "type": "string" - }, + } } } \ No newline at end of file From 06626c01cb561832c40cf71a40f92bcab0760110 Mon Sep 17 00:00:00 2001 From: Filip Bucek Date: Tue, 1 Oct 2019 13:19:44 +0200 Subject: [PATCH 5/5] Added endpoints --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 07bf64f..7a95584 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ Acces Management System of Colsys: [Product info](http://produkty.colsys.cz/colnod/) +## Endpoints +1. POST request - `/AaaManager/authSession` - to login, return JSON with Auth token +2. GET request - `/SubjectManager/getSubjects` - get subjects +3. GET request - `/TokenManager/getTokens` - get tokens +4. POST request - `/TokenManager/setTokens` - set tokens + ## RestAPI definitions - `openapi.yaml` ( editor `VSCode` with `Swagger Viewer` extension - ⌘+⇧+P `Preview Swagger` )