From 10a28f4e89d11da9883bc802d80c274e7d8dfa4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=90=99PiperYxzzy?= Date: Sun, 29 May 2022 19:32:00 +0200 Subject: [PATCH] Swagger tweak, removing manually built postman build --- Prepack.postman_collection.json | 295 -------------------------------- controllers/core/core.go | 8 + docs/docs.go | 41 ++++- docs/swagger.json | 41 ++++- docs/swagger.yaml | 28 ++- 5 files changed, 103 insertions(+), 310 deletions(-) delete mode 100644 Prepack.postman_collection.json diff --git a/Prepack.postman_collection.json b/Prepack.postman_collection.json deleted file mode 100644 index 2f75c16..0000000 --- a/Prepack.postman_collection.json +++ /dev/null @@ -1,295 +0,0 @@ -{ - "info": { - "_postman_id": "6485c58d-0675-4f5d-9eed-4c2ecd8174ae", - "name": "Prepack", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Unauthenticated", - "item": [ - { - "name": "V1 Doot", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "localhost:9091/v1/doot", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "doot" - ] - } - }, - "response": [] - }, - { - "name": "V1 Signup", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"userkey\": \"newser@user.com\",\n \"password\": \"NewPass\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "localhost:9091/v1/signup", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "signup" - ] - } - }, - "response": [] - }, - { - "name": "V1 User Forgot Password", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"userkey\": \"newser@user.com\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "localhost:9091/v1/forgot", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "forgot" - ] - } - }, - "response": [] - }, - { - "name": "V1 User Reset Password", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTE0MjYzMjYsImlhdCI6MTY1MTQyNTQyNiwicm9sZSI6InJlc2V0Iiwic3ViIjoiZDFkNDBkMmUtOTFlYy00ZTBiLWEzY2EtM2U1ZTBkNGU5MTkxIn0.NE_0oV5MGJzuQuad-TUen1c7VCfFW9t6LMJPag8XC38\",\n \"password\": \"ChangedPass\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "localhost:9091/v1/reset", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "reset" - ] - } - }, - "response": [] - }, - { - "name": "V1 User Login", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"userkey\": \"newser@user.com\",\n \"password\": \"ChangedPass\",\n \"twofactorcode\": \"393939\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "localhost:9091/v1/login", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "login" - ] - } - }, - "response": [] - }, - { - "name": "V1 User Verify", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "localhost:9091/v1/verify?verify=TOKEN", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "verify" - ], - "query": [ - { - "key": "verify", - "value": "TOKEN" - } - ] - } - }, - "response": [] - }, - { - "name": "V1 Admin Login", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"userkey\": \"admin@admin.invalid\",\n \"password\": \"PASS_WOOOORD\",\n \"twofactorcode\": \"057192\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "localhost:9091/v1/admin", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "admin" - ] - } - }, - "response": [] - }, - { - "name": "Fresh Admin", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"userkey\": \"admin@admin.invalid\",\n \"password\": \"q7irwc34h6rv4t34v\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "localhost:9091/{UUID}", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "{UUID}" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "/sec (User)", - "item": [ - { - "name": "V1 Secured Doot", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "localhost:9091/v1/sec/doot", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "sec", - "doot" - ] - } - }, - "response": [] - }, - { - "name": "V1 Secured Doot Copy", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "localhost:9091/v1/sec/2fa-doot", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "sec", - "2fa-doot" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "/adm (Admin)", - "item": [ - { - "name": "V1 Admin Doot", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "localhost:9091/v1/adm/doot", - "host": [ - "localhost" - ], - "port": "9091", - "path": [ - "v1", - "adm", - "doot" - ] - } - }, - "response": [] - } - ] - } - ] -} \ No newline at end of file diff --git a/controllers/core/core.go b/controllers/core/core.go index 145ba7d..ae5604d 100644 --- a/controllers/core/core.go +++ b/controllers/core/core.go @@ -556,3 +556,11 @@ func checkTwoFactorNotReused(a *models.Auth, tfCode string) bool { return true } + +// Secure ping functionality +// @Summary 2FA-Restricted Ping +// @Product json +// @Param twofactorcode query string true "2FA authentication code" +// @Router /sec/2fa-doot [get] +// @Success 200 +func secureDootDefinition() {} diff --git a/docs/docs.go b/docs/docs.go index 78daeda..9f91974 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -18,7 +18,7 @@ const docTemplate = `{ "paths": { "/adm/doot": { "get": { - "summary": "Admin ming", + "summary": "Admin ping", "parameters": [ { "type": "string", @@ -28,7 +28,11 @@ const docTemplate = `{ "required": true } ], - "responses": {} + "responses": { + "200": { + "description": "" + } + } } }, "/admin": { @@ -40,7 +44,7 @@ const docTemplate = `{ "produces": [ "application/json" ], - "summary": "User login", + "summary": "Admin login", "parameters": [ { "description": "email, password and 2FA code. 2FA code is required", @@ -74,7 +78,11 @@ const docTemplate = `{ "/doot": { "get": { "summary": "Unauthenticated Ping", - "responses": {} + "responses": { + "200": { + "description": "" + } + } } }, "/forgot": { @@ -182,6 +190,25 @@ const docTemplate = `{ } } }, + "/sec/2fa-doot": { + "get": { + "summary": "2FA-Restricted Ping", + "parameters": [ + { + "type": "string", + "description": "2FA authentication code", + "name": "twofactorcode", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "" + } + } + } + }, "/sec/doot": { "get": { "summary": "User ping", @@ -194,7 +221,11 @@ const docTemplate = `{ "required": true } ], - "responses": {} + "responses": { + "200": { + "description": "" + } + } } }, "/signup": { diff --git a/docs/swagger.json b/docs/swagger.json index b032fc8..9ef6fa0 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -9,7 +9,7 @@ "paths": { "/adm/doot": { "get": { - "summary": "Admin ming", + "summary": "Admin ping", "parameters": [ { "type": "string", @@ -19,7 +19,11 @@ "required": true } ], - "responses": {} + "responses": { + "200": { + "description": "" + } + } } }, "/admin": { @@ -31,7 +35,7 @@ "produces": [ "application/json" ], - "summary": "User login", + "summary": "Admin login", "parameters": [ { "description": "email, password and 2FA code. 2FA code is required", @@ -65,7 +69,11 @@ "/doot": { "get": { "summary": "Unauthenticated Ping", - "responses": {} + "responses": { + "200": { + "description": "" + } + } } }, "/forgot": { @@ -173,6 +181,25 @@ } } }, + "/sec/2fa-doot": { + "get": { + "summary": "2FA-Restricted Ping", + "parameters": [ + { + "type": "string", + "description": "2FA authentication code", + "name": "twofactorcode", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "" + } + } + } + }, "/sec/doot": { "get": { "summary": "User ping", @@ -185,7 +212,11 @@ "required": true } ], - "responses": {} + "responses": { + "200": { + "description": "" + } + } } }, "/signup": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 7f3b50c..d52a54e 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -52,8 +52,10 @@ paths: name: jwt required: true type: string - responses: {} - summary: Admin ming + responses: + "200": + description: "" + summary: Admin ping /admin: post: consumes: @@ -79,10 +81,12 @@ paths: description: userkey, 2fa token or password missing "401": description: not found or credentials invalid - summary: User login + summary: Admin login /doot: get: - responses: {} + responses: + "200": + description: "" summary: Unauthenticated Ping /forgot: post: @@ -152,6 +156,18 @@ paths: "401": description: bad token or user not found summary: Password reset + /sec/2fa-doot: + get: + parameters: + - description: 2FA authentication code + in: query + name: twofactorcode + required: true + type: string + responses: + "200": + description: "" + summary: 2FA-Restricted Ping /sec/doot: get: parameters: @@ -160,7 +176,9 @@ paths: name: jwt required: true type: string - responses: {} + responses: + "200": + description: "" summary: User ping /signup: post: