From fc0bbcef5a403505f4c3d1ccc6b387a5700cd3d9 Mon Sep 17 00:00:00 2001 From: Sander Jochems Date: Fri, 7 Feb 2025 22:41:10 +0100 Subject: [PATCH 1/7] Return stream object in stream list --- backend/schema/components/stream-list.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/schema/components/stream-list.json b/backend/schema/components/stream-list.json index 39789b4a7..b6e8b6d44 100644 --- a/backend/schema/components/stream-list.json +++ b/backend/schema/components/stream-list.json @@ -1,7 +1,7 @@ { "type": "array", - "description": "Proxy Hosts list", + "description": "Streams list", "items": { - "$ref": "./proxy-host-object.json" + "$ref": "./stream-object.json" } } From ee9a66971243eb1bcc05243a509db5d303de9d8e Mon Sep 17 00:00:00 2001 From: Sander Jochems Date: Sat, 8 Feb 2025 13:12:54 +0100 Subject: [PATCH 2/7] Improve access list API --- backend/schema/common.json | 32 +++++++ .../schema/components/access-list-object.json | 90 ++++++++++++++----- .../schema/paths/nginx/access-lists/get.json | 51 ++++++++++- .../paths/nginx/access-lists/listID/get.json | 72 +++++++++++++-- .../paths/nginx/access-lists/listID/put.json | 29 ++---- .../schema/paths/nginx/access-lists/post.json | 24 +---- 6 files changed, 226 insertions(+), 72 deletions(-) diff --git a/backend/schema/common.json b/backend/schema/common.json index 83de0143c..88a30a767 100644 --- a/backend/schema/common.json +++ b/backend/schema/common.json @@ -68,6 +68,38 @@ "type": "integer", "minimum": 0 }, + "access_directive": { + "type": "string", + "enum": ["allow", "deny"] + }, + "access_address": { + "oneOf": [ + { + "type": "string", + "pattern": "^([0-9]{1,3}\\.){3}[0-9]{1,3}(/([0-9]|[1-2][0-9]|3[0-2]))?$" + }, + { + "type": "string", + "pattern": "^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$" + }, + { + "type": "string", + "pattern": "^all$" + } + ] + }, + "authorization_username": { + "type": "string", + "minLength": 1 + }, + "authorization_password": { + "type": "string", + "minLength": 1 + }, + "authorization_hint": { + "type": "string", + "minLength": 1 + }, "domain_names": { "description": "Domain Names separated by a comma", "type": "array", diff --git a/backend/schema/components/access-list-object.json b/backend/schema/components/access-list-object.json index cd0218d72..1319dd97a 100644 --- a/backend/schema/components/access-list-object.json +++ b/backend/schema/components/access-list-object.json @@ -20,26 +20,6 @@ "type": "string", "minLength": 1 }, - "directive": { - "type": "string", - "enum": ["allow", "deny"] - }, - "address": { - "oneOf": [ - { - "type": "string", - "pattern": "^([0-9]{1,3}\\.){3}[0-9]{1,3}(/([0-9]|[1-2][0-9]|3[0-2]))?$" - }, - { - "type": "string", - "pattern": "^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$" - }, - { - "type": "string", - "pattern": "^all$" - } - ] - }, "satisfy_any": { "type": "boolean" }, @@ -48,6 +28,76 @@ }, "meta": { "type": "object" + }, + "owner": { + "$ref": "./user-object.json" + }, + "items": { + "type": "array", + "minItems": 0, + "items": { + "type": "object", + "required": ["id", "created_on", "modified_on", "access_list_id", "username", "password", "hint", "meta"], + "additionalProperties": false, + "properties": { + "id": { + "$ref": "../common.json#/properties/id" + }, + "created_on": { + "$ref": "../common.json#/properties/created_on" + }, + "modified_on": { + "$ref": "../common.json#/properties/modified_on" + }, + "access_list_id": { + "$ref": "../common.json#/properties/access_list_id" + }, + "username": { + "$ref": "../common.json#/properties/authorization_username" + }, + "password": { + "$ref": "../common.json#/properties/authorization_password" + }, + "hint": { + "$ref": "../common.json#/properties/authorization_hint" + }, + "meta": { + "type": "object" + } + } + } + }, + "clients": { + "type": "array", + "minItems": 0, + "items": { + "type": "object", + "required": ["id", "created_on", "modified_on", "access_list_id", "address", "directive", "meta"], + "additionalProperties": false, + "properties": { + "id": { + "$ref": "../common.json#/properties/id" + }, + "created_on": { + "$ref": "../common.json#/properties/created_on" + }, + "modified_on": { + "$ref": "../common.json#/properties/modified_on" + }, + "access_list_id": { + "$ref": "../common.json#/properties/access_list_id" + }, + "address": { + "$ref": "../common.json#/properties/access_address" + }, + "directive": { + "$ref": "../common.json#/properties/access_directive" + }, + "meta": { + "type": "object" + } + } + } } } } diff --git a/backend/schema/paths/nginx/access-lists/get.json b/backend/schema/paths/nginx/access-lists/get.json index a8b9adc69..ef9a6bf99 100644 --- a/backend/schema/paths/nginx/access-lists/get.json +++ b/backend/schema/paths/nginx/access-lists/get.json @@ -14,7 +14,7 @@ "description": "Expansions", "schema": { "type": "string", - "enum": ["owner", "items", "clients", "proxy_hosts"] + "enum": ["owner", "items", "clients"] } } ], @@ -35,7 +35,54 @@ "meta": {}, "satisfy_any": true, "pass_auth": false, - "proxy_host_count": 0 + "proxy_host_count": 0, + "owner": { + "id": 1, + "created_on": "2024-10-07T22:43:55.000Z", + "modified_on": "2024-10-08T12:52:54.000Z", + "is_deleted": false, + "is_disabled": false, + "email": "admin@example.com", + "name": "Administrator", + "nickname": "some guy", + "avatar": "//www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?default=mm", + "roles": [ + "admin" + ] + }, + "items": [ + { + "id": 1, + "created_on": "2024-10-08T22:15:40.000Z", + "modified_on": "2024-10-08T22:15:40.000Z", + "access_list_id": 1, + "username": "admin", + "password": "", + "meta": {}, + "hint": "a****" + }, + { + "id": 2, + "created_on": "2024-10-08T22:15:40.000Z", + "modified_on": "2024-10-08T22:15:40.000Z", + "access_list_id": 1, + "username": "asdad", + "password": "", + "meta": {}, + "hint": "a*****" + } + ], + "clients": [ + { + "id": 1, + "created_on": "2024-10-08T22:15:40.000Z", + "modified_on": "2024-10-08T22:15:40.000Z", + "access_list_id": 1, + "address": "127.0.0.1", + "directive": "allow", + "meta": {} + } + ] } ] } diff --git a/backend/schema/paths/nginx/access-lists/listID/get.json b/backend/schema/paths/nginx/access-lists/listID/get.json index e67023f89..e2e68af1d 100644 --- a/backend/schema/paths/nginx/access-lists/listID/get.json +++ b/backend/schema/paths/nginx/access-lists/listID/get.json @@ -17,6 +17,15 @@ }, "required": true, "example": 1 + }, + { + "in": "query", + "name": "expand", + "description": "Expansions", + "schema": { + "type": "string", + "enum": ["owner", "items", "clients"] + } } ], "responses": { @@ -28,14 +37,61 @@ "default": { "value": { "id": 1, - "created_on": "2020-01-30T09:36:08.000Z", - "modified_on": "2020-01-30T09:41:04.000Z", - "is_disabled": false, - "email": "jc@jc21.com", - "name": "Jamie Curnow", - "nickname": "James", - "avatar": "//www.gravatar.com/avatar/6193176330f8d38747f038c170ddb193?default=mm", - "roles": ["admin"] + "created_on": "2024-10-08T22:15:40.000Z", + "modified_on": "2024-10-08T22:15:40.000Z", + "owner_user_id": 1, + "name": "test1234", + "meta": {}, + "satisfy_any": true, + "pass_auth": false, + "proxy_host_count": 0, + "owner": { + "id": 1, + "created_on": "2024-10-07T22:43:55.000Z", + "modified_on": "2024-10-08T12:52:54.000Z", + "is_deleted": false, + "is_disabled": false, + "email": "admin@example.com", + "name": "Administrator", + "nickname": "some guy", + "avatar": "//www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?default=mm", + "roles": [ + "admin" + ] + }, + "items": [ + { + "id": 1, + "created_on": "2024-10-08T22:15:40.000Z", + "modified_on": "2024-10-08T22:15:40.000Z", + "access_list_id": 1, + "username": "admin", + "password": "", + "meta": {}, + "hint": "a****" + }, + { + "id": 2, + "created_on": "2024-10-08T22:15:40.000Z", + "modified_on": "2024-10-08T22:15:40.000Z", + "access_list_id": 1, + "username": "asdad", + "password": "", + "meta": {}, + "hint": "a*****" + } + ], + "clients": [ + { + "id": 1, + "created_on": "2024-10-08T22:15:40.000Z", + "modified_on": "2024-10-08T22:15:40.000Z", + "access_list_id": 1, + "address": "127.0.0.1", + "directive": "allow", + "meta": {} + } + ] } } }, diff --git a/backend/schema/paths/nginx/access-lists/listID/put.json b/backend/schema/paths/nginx/access-lists/listID/put.json index 7f887dad6..c8ef59099 100644 --- a/backend/schema/paths/nginx/access-lists/listID/put.json +++ b/backend/schema/paths/nginx/access-lists/listID/put.json @@ -45,11 +45,10 @@ "additionalProperties": false, "properties": { "username": { - "type": "string", - "minLength": 1 + "$ref": "../../../../common.json#/properties/authorization_username" }, "password": { - "type": "string" + "$ref": "../../../../common.json#/properties/authorization_password" } } } @@ -61,23 +60,10 @@ "additionalProperties": false, "properties": { "address": { - "oneOf": [ - { - "type": "string", - "pattern": "^([0-9]{1,3}\\.){3}[0-9]{1,3}(/([0-9]|[1-2][0-9]|3[0-2]))?$" - }, - { - "type": "string", - "pattern": "^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$" - }, - { - "type": "string", - "pattern": "^all$" - } - ] + "$ref": "../../../../common.json#/properties/access_address" }, "directive": { - "$ref": "../../../../components/access-list-object.json#/properties/directive" + "$ref": "../../../../common.json#/properties/access_directive" } } } @@ -97,9 +83,9 @@ "value": { "id": 1, "created_on": "2024-10-08T22:15:40.000Z", - "modified_on": "2024-10-08T22:34:34.000Z", + "modified_on": "2024-10-08T22:15:40.000Z", "owner_user_id": 1, - "name": "test123!!", + "name": "test1234", "meta": {}, "satisfy_any": true, "pass_auth": false, @@ -148,8 +134,7 @@ "directive": "allow", "meta": {} } - ], - "proxy_hosts": [] + ] } } }, diff --git a/backend/schema/paths/nginx/access-lists/post.json b/backend/schema/paths/nginx/access-lists/post.json index 4c5a4edd2..f4fb49fbf 100644 --- a/backend/schema/paths/nginx/access-lists/post.json +++ b/backend/schema/paths/nginx/access-lists/post.json @@ -33,12 +33,10 @@ "additionalProperties": false, "properties": { "username": { - "type": "string", - "minLength": 1 + "$ref": "../../../common.json#/properties/authorization_username" }, "password": { - "type": "string", - "minLength": 1 + "$ref": "../../../common.json#/properties/authorization_password" } } } @@ -50,23 +48,10 @@ "additionalProperties": false, "properties": { "address": { - "oneOf": [ - { - "type": "string", - "pattern": "^([0-9]{1,3}\\.){3}[0-9]{1,3}(/([0-9]|[1-2][0-9]|3[0-2]))?$" - }, - { - "type": "string", - "pattern": "^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(/([0-9]|[1-9][0-9]|1[0-1][0-9]|12[0-8]))?$" - }, - { - "type": "string", - "pattern": "^all$" - } - ] + "$ref": "../../../common.json#/properties/access_address" }, "directive": { - "$ref": "../../../components/access-list-object.json#/properties/directive" + "$ref": "../../../common.json#/properties/access_directive" } } } @@ -130,7 +115,6 @@ "hint": "a*****" } ], - "proxy_hosts": [], "clients": [ { "id": 1, From 2da158d20c3dad5f1d8f7b78111ac83133b02c48 Mon Sep 17 00:00:00 2001 From: Sander Jochems Date: Sat, 8 Feb 2025 13:15:48 +0100 Subject: [PATCH 3/7] Add expand query parameter to single selection --- backend/schema/paths/nginx/certificates/certID/get.json | 9 +++++++++ backend/schema/paths/nginx/dead-hosts/hostID/get.json | 9 +++++++++ backend/schema/paths/nginx/proxy-hosts/hostID/get.json | 9 +++++++++ .../schema/paths/nginx/redirection-hosts/hostID/get.json | 9 +++++++++ backend/schema/paths/nginx/streams/streamID/get.json | 9 +++++++++ backend/schema/paths/users/userID/get.json | 9 +++++++++ 6 files changed, 54 insertions(+) diff --git a/backend/schema/paths/nginx/certificates/certID/get.json b/backend/schema/paths/nginx/certificates/certID/get.json index 22317b337..e10dde227 100644 --- a/backend/schema/paths/nginx/certificates/certID/get.json +++ b/backend/schema/paths/nginx/certificates/certID/get.json @@ -17,6 +17,15 @@ }, "required": true, "example": 1 + }, + { + "in": "query", + "name": "expand", + "description": "Expansions", + "schema": { + "type": "string", + "enum": ["owner"] + } } ], "responses": { diff --git a/backend/schema/paths/nginx/dead-hosts/hostID/get.json b/backend/schema/paths/nginx/dead-hosts/hostID/get.json index 47e2f8b12..6cf9d22a1 100644 --- a/backend/schema/paths/nginx/dead-hosts/hostID/get.json +++ b/backend/schema/paths/nginx/dead-hosts/hostID/get.json @@ -17,6 +17,15 @@ }, "required": true, "example": 1 + }, + { + "in": "query", + "name": "expand", + "description": "Expansions", + "schema": { + "type": "string", + "enum": ["owner", "certificate"] + } } ], "responses": { diff --git a/backend/schema/paths/nginx/proxy-hosts/hostID/get.json b/backend/schema/paths/nginx/proxy-hosts/hostID/get.json index 5e10a9cfd..37d0b4174 100644 --- a/backend/schema/paths/nginx/proxy-hosts/hostID/get.json +++ b/backend/schema/paths/nginx/proxy-hosts/hostID/get.json @@ -17,6 +17,15 @@ }, "required": true, "example": 1 + }, + { + "in": "query", + "name": "expand", + "description": "Expansions", + "schema": { + "type": "string", + "enum": ["access_list", "owner", "certificate"] + } } ], "responses": { diff --git a/backend/schema/paths/nginx/redirection-hosts/hostID/get.json b/backend/schema/paths/nginx/redirection-hosts/hostID/get.json index d780f874b..f2a090cdc 100644 --- a/backend/schema/paths/nginx/redirection-hosts/hostID/get.json +++ b/backend/schema/paths/nginx/redirection-hosts/hostID/get.json @@ -17,6 +17,15 @@ }, "required": true, "example": 1 + }, + { + "in": "query", + "name": "expand", + "description": "Expansions", + "schema": { + "type": "string", + "enum": ["owner", "certificate"] + } } ], "responses": { diff --git a/backend/schema/paths/nginx/streams/streamID/get.json b/backend/schema/paths/nginx/streams/streamID/get.json index 801af13a7..cfb6478cf 100644 --- a/backend/schema/paths/nginx/streams/streamID/get.json +++ b/backend/schema/paths/nginx/streams/streamID/get.json @@ -17,6 +17,15 @@ }, "required": true, "example": 2 + }, + { + "in": "query", + "name": "expand", + "description": "Expansions", + "schema": { + "type": "string", + "enum": ["owner", "certificate"] + } } ], "responses": { diff --git a/backend/schema/paths/users/userID/get.json b/backend/schema/paths/users/userID/get.json index cb8ac61b4..27099970a 100644 --- a/backend/schema/paths/users/userID/get.json +++ b/backend/schema/paths/users/userID/get.json @@ -26,6 +26,15 @@ "required": true, "description": "User ID or 'me' for yourself", "example": 1 + }, + { + "in": "query", + "name": "expand", + "description": "Expansions", + "schema": { + "type": "string", + "enum": ["permissions"] + } } ], "responses": { From ae4d342b8eea52309e5322ccde5b983bff1251ff Mon Sep 17 00:00:00 2001 From: Sander Jochems Date: Sat, 8 Feb 2025 13:50:53 +0100 Subject: [PATCH 4/7] Fix list type for access list list --- backend/schema/components/access-list-list.json | 7 +++++++ backend/schema/paths/nginx/access-lists/get.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 backend/schema/components/access-list-list.json diff --git a/backend/schema/components/access-list-list.json b/backend/schema/components/access-list-list.json new file mode 100644 index 000000000..3745129d1 --- /dev/null +++ b/backend/schema/components/access-list-list.json @@ -0,0 +1,7 @@ +{ + "type": "array", + "description": "Access list list", + "items": { + "$ref": "./access-list-object.json" + } +} diff --git a/backend/schema/paths/nginx/access-lists/get.json b/backend/schema/paths/nginx/access-lists/get.json index ef9a6bf99..a5e39c227 100644 --- a/backend/schema/paths/nginx/access-lists/get.json +++ b/backend/schema/paths/nginx/access-lists/get.json @@ -88,7 +88,7 @@ } }, "schema": { - "$ref": "../../../components/access-list-object.json" + "$ref": "../../../components/access-list-list.json" } } } From f80c18758178ee4245e9200d13b6f5a85ddd3968 Mon Sep 17 00:00:00 2001 From: Sander Jochems Date: Sat, 8 Feb 2025 14:46:11 +0100 Subject: [PATCH 5/7] Fix user and permissions --- backend/schema/components/permission-object.json | 3 ++- backend/schema/components/user-object.json | 16 ++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/backend/schema/components/permission-object.json b/backend/schema/components/permission-object.json index b852a014d..955c20c64 100644 --- a/backend/schema/components/permission-object.json +++ b/backend/schema/components/permission-object.json @@ -1,6 +1,7 @@ { "type": "object", - "minProperties": 1, + "required": ["visibility", "access_lists", "dead_hosts", "proxy_hosts", "redirection_hosts", "streams", "certificates"], + "additionalProperties": false, "properties": { "visibility": { "type": "string", diff --git a/backend/schema/components/user-object.json b/backend/schema/components/user-object.json index 180e8f197..0daa9b0ba 100644 --- a/backend/schema/components/user-object.json +++ b/backend/schema/components/user-object.json @@ -5,20 +5,13 @@ "additionalProperties": false, "properties": { "id": { - "type": "integer", - "description": "User ID", - "minimum": 1, - "example": 1 + "$ref": "../common.json#/properties/id" }, "created_on": { - "type": "string", - "description": "Created Date", - "example": "2020-01-30T09:36:08.000Z" + "$ref": "../common.json#/properties/created_on" }, "modified_on": { - "type": "string", - "description": "Modified Date", - "example": "2020-01-30T09:41:04.000Z" + "$ref": "../common.json#/properties/modified_on" }, "is_disabled": { "type": "boolean", @@ -54,6 +47,9 @@ "items": { "type": "string" } + }, + "permissions": { + "$ref": "./permission-object.json" } } } From 7b492c5cd572f9dd607a4becfdd68ed9b4999f96 Mon Sep 17 00:00:00 2001 From: Sander Jochems Date: Sat, 22 Feb 2025 14:57:46 +0100 Subject: [PATCH 6/7] Set format to binary for certificate files --- .../paths/nginx/certificates/certID/upload/post.json | 9 ++++++--- .../schema/paths/nginx/certificates/validate/post.json | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/schema/paths/nginx/certificates/certID/upload/post.json b/backend/schema/paths/nginx/certificates/certID/upload/post.json index f38b8102a..711e16c40 100644 --- a/backend/schema/paths/nginx/certificates/certID/upload/post.json +++ b/backend/schema/paths/nginx/certificates/certID/upload/post.json @@ -30,13 +30,16 @@ "required": ["certificate", "certificate_key"], "properties": { "certificate": { - "type": "string" + "type": "string", + "format": "binary" }, "certificate_key": { - "type": "string" + "type": "string", + "format": "binary" }, "intermediate_certificate": { - "type": "string" + "type": "string", + "format": "binary" } } } diff --git a/backend/schema/paths/nginx/certificates/validate/post.json b/backend/schema/paths/nginx/certificates/validate/post.json index 21eb325ef..f8f9531dc 100644 --- a/backend/schema/paths/nginx/certificates/validate/post.json +++ b/backend/schema/paths/nginx/certificates/validate/post.json @@ -18,13 +18,16 @@ "required": ["certificate", "certificate_key"], "properties": { "certificate": { - "type": "string" + "type": "string", + "format": "binary" }, "certificate_key": { - "type": "string" + "type": "string", + "format": "binary" }, "intermediate_certificate": { - "type": "string" + "type": "string", + "format": "binary" } } } From bcdf9f3031f6bf977f404b3bf92d473e291fd765 Mon Sep 17 00:00:00 2001 From: Sander Jochems Date: Thu, 6 Mar 2025 22:12:48 +0100 Subject: [PATCH 7/7] Remove getUserOmisionsByAccess --- backend/internal/user.js | 15 --------------- backend/routes/users.js | 1 - 2 files changed, 16 deletions(-) diff --git a/backend/internal/user.js b/backend/internal/user.js index 742ab65d3..020355489 100644 --- a/backend/internal/user.js +++ b/backend/internal/user.js @@ -337,21 +337,6 @@ const internalUser = { }); }, - /** - * @param {Access} access - * @param {Integer} [id_requested] - * @returns {[String]} - */ - getUserOmisionsByAccess: (access, id_requested) => { - let response = []; // Admin response - - if (!access.token.hasScope('admin') && access.token.getUserId(0) !== id_requested) { - response = ['roles', 'is_deleted']; // Restricted response - } - - return response; - }, - /** * @param {Access} access * @param {Object} data diff --git a/backend/routes/users.js b/backend/routes/users.js index f8ce366c9..bb55b7551 100644 --- a/backend/routes/users.js +++ b/backend/routes/users.js @@ -111,7 +111,6 @@ router return internalUser.get(res.locals.access, { id: data.user_id, expand: data.expand, - omit: internalUser.getUserOmisionsByAccess(res.locals.access, data.user_id) }); }) .then((user) => {