Skip to content

Commit ee9a669

Browse files
committed
Improve access list API
1 parent fc0bbce commit ee9a669

File tree

6 files changed

+226
-72
lines changed

6 files changed

+226
-72
lines changed

backend/schema/common.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,38 @@
6868
"type": "integer",
6969
"minimum": 0
7070
},
71+
"access_directive": {
72+
"type": "string",
73+
"enum": ["allow", "deny"]
74+
},
75+
"access_address": {
76+
"oneOf": [
77+
{
78+
"type": "string",
79+
"pattern": "^([0-9]{1,3}\\.){3}[0-9]{1,3}(/([0-9]|[1-2][0-9]|3[0-2]))?$"
80+
},
81+
{
82+
"type": "string",
83+
"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]))?$"
84+
},
85+
{
86+
"type": "string",
87+
"pattern": "^all$"
88+
}
89+
]
90+
},
91+
"authorization_username": {
92+
"type": "string",
93+
"minLength": 1
94+
},
95+
"authorization_password": {
96+
"type": "string",
97+
"minLength": 1
98+
},
99+
"authorization_hint": {
100+
"type": "string",
101+
"minLength": 1
102+
},
71103
"domain_names": {
72104
"description": "Domain Names separated by a comma",
73105
"type": "array",

backend/schema/components/access-list-object.json

Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,6 @@
2020
"type": "string",
2121
"minLength": 1
2222
},
23-
"directive": {
24-
"type": "string",
25-
"enum": ["allow", "deny"]
26-
},
27-
"address": {
28-
"oneOf": [
29-
{
30-
"type": "string",
31-
"pattern": "^([0-9]{1,3}\\.){3}[0-9]{1,3}(/([0-9]|[1-2][0-9]|3[0-2]))?$"
32-
},
33-
{
34-
"type": "string",
35-
"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]))?$"
36-
},
37-
{
38-
"type": "string",
39-
"pattern": "^all$"
40-
}
41-
]
42-
},
4323
"satisfy_any": {
4424
"type": "boolean"
4525
},
@@ -48,6 +28,76 @@
4828
},
4929
"meta": {
5030
"type": "object"
31+
},
32+
"owner": {
33+
"$ref": "./user-object.json"
34+
},
35+
"items": {
36+
"type": "array",
37+
"minItems": 0,
38+
"items": {
39+
"type": "object",
40+
"required": ["id", "created_on", "modified_on", "access_list_id", "username", "password", "hint", "meta"],
41+
"additionalProperties": false,
42+
"properties": {
43+
"id": {
44+
"$ref": "../common.json#/properties/id"
45+
},
46+
"created_on": {
47+
"$ref": "../common.json#/properties/created_on"
48+
},
49+
"modified_on": {
50+
"$ref": "../common.json#/properties/modified_on"
51+
},
52+
"access_list_id": {
53+
"$ref": "../common.json#/properties/access_list_id"
54+
},
55+
"username": {
56+
"$ref": "../common.json#/properties/authorization_username"
57+
},
58+
"password": {
59+
"$ref": "../common.json#/properties/authorization_password"
60+
},
61+
"hint": {
62+
"$ref": "../common.json#/properties/authorization_hint"
63+
},
64+
"meta": {
65+
"type": "object"
66+
}
67+
}
68+
}
69+
},
70+
"clients": {
71+
"type": "array",
72+
"minItems": 0,
73+
"items": {
74+
"type": "object",
75+
"required": ["id", "created_on", "modified_on", "access_list_id", "address", "directive", "meta"],
76+
"additionalProperties": false,
77+
"properties": {
78+
"id": {
79+
"$ref": "../common.json#/properties/id"
80+
},
81+
"created_on": {
82+
"$ref": "../common.json#/properties/created_on"
83+
},
84+
"modified_on": {
85+
"$ref": "../common.json#/properties/modified_on"
86+
},
87+
"access_list_id": {
88+
"$ref": "../common.json#/properties/access_list_id"
89+
},
90+
"address": {
91+
"$ref": "../common.json#/properties/access_address"
92+
},
93+
"directive": {
94+
"$ref": "../common.json#/properties/access_directive"
95+
},
96+
"meta": {
97+
"type": "object"
98+
}
99+
}
100+
}
51101
}
52102
}
53103
}

backend/schema/paths/nginx/access-lists/get.json

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"description": "Expansions",
1515
"schema": {
1616
"type": "string",
17-
"enum": ["owner", "items", "clients", "proxy_hosts"]
17+
"enum": ["owner", "items", "clients"]
1818
}
1919
}
2020
],
@@ -35,7 +35,54 @@
3535
"meta": {},
3636
"satisfy_any": true,
3737
"pass_auth": false,
38-
"proxy_host_count": 0
38+
"proxy_host_count": 0,
39+
"owner": {
40+
"id": 1,
41+
"created_on": "2024-10-07T22:43:55.000Z",
42+
"modified_on": "2024-10-08T12:52:54.000Z",
43+
"is_deleted": false,
44+
"is_disabled": false,
45+
"email": "[email protected]",
46+
"name": "Administrator",
47+
"nickname": "some guy",
48+
"avatar": "//www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?default=mm",
49+
"roles": [
50+
"admin"
51+
]
52+
},
53+
"items": [
54+
{
55+
"id": 1,
56+
"created_on": "2024-10-08T22:15:40.000Z",
57+
"modified_on": "2024-10-08T22:15:40.000Z",
58+
"access_list_id": 1,
59+
"username": "admin",
60+
"password": "",
61+
"meta": {},
62+
"hint": "a****"
63+
},
64+
{
65+
"id": 2,
66+
"created_on": "2024-10-08T22:15:40.000Z",
67+
"modified_on": "2024-10-08T22:15:40.000Z",
68+
"access_list_id": 1,
69+
"username": "asdad",
70+
"password": "",
71+
"meta": {},
72+
"hint": "a*****"
73+
}
74+
],
75+
"clients": [
76+
{
77+
"id": 1,
78+
"created_on": "2024-10-08T22:15:40.000Z",
79+
"modified_on": "2024-10-08T22:15:40.000Z",
80+
"access_list_id": 1,
81+
"address": "127.0.0.1",
82+
"directive": "allow",
83+
"meta": {}
84+
}
85+
]
3986
}
4087
]
4188
}

backend/schema/paths/nginx/access-lists/listID/get.json

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
},
1818
"required": true,
1919
"example": 1
20+
},
21+
{
22+
"in": "query",
23+
"name": "expand",
24+
"description": "Expansions",
25+
"schema": {
26+
"type": "string",
27+
"enum": ["owner", "items", "clients"]
28+
}
2029
}
2130
],
2231
"responses": {
@@ -28,14 +37,61 @@
2837
"default": {
2938
"value": {
3039
"id": 1,
31-
"created_on": "2020-01-30T09:36:08.000Z",
32-
"modified_on": "2020-01-30T09:41:04.000Z",
33-
"is_disabled": false,
34-
"email": "[email protected]",
35-
"name": "Jamie Curnow",
36-
"nickname": "James",
37-
"avatar": "//www.gravatar.com/avatar/6193176330f8d38747f038c170ddb193?default=mm",
38-
"roles": ["admin"]
40+
"created_on": "2024-10-08T22:15:40.000Z",
41+
"modified_on": "2024-10-08T22:15:40.000Z",
42+
"owner_user_id": 1,
43+
"name": "test1234",
44+
"meta": {},
45+
"satisfy_any": true,
46+
"pass_auth": false,
47+
"proxy_host_count": 0,
48+
"owner": {
49+
"id": 1,
50+
"created_on": "2024-10-07T22:43:55.000Z",
51+
"modified_on": "2024-10-08T12:52:54.000Z",
52+
"is_deleted": false,
53+
"is_disabled": false,
54+
"email": "[email protected]",
55+
"name": "Administrator",
56+
"nickname": "some guy",
57+
"avatar": "//www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?default=mm",
58+
"roles": [
59+
"admin"
60+
]
61+
},
62+
"items": [
63+
{
64+
"id": 1,
65+
"created_on": "2024-10-08T22:15:40.000Z",
66+
"modified_on": "2024-10-08T22:15:40.000Z",
67+
"access_list_id": 1,
68+
"username": "admin",
69+
"password": "",
70+
"meta": {},
71+
"hint": "a****"
72+
},
73+
{
74+
"id": 2,
75+
"created_on": "2024-10-08T22:15:40.000Z",
76+
"modified_on": "2024-10-08T22:15:40.000Z",
77+
"access_list_id": 1,
78+
"username": "asdad",
79+
"password": "",
80+
"meta": {},
81+
"hint": "a*****"
82+
}
83+
],
84+
"clients": [
85+
{
86+
"id": 1,
87+
"created_on": "2024-10-08T22:15:40.000Z",
88+
"modified_on": "2024-10-08T22:15:40.000Z",
89+
"access_list_id": 1,
90+
"address": "127.0.0.1",
91+
"directive": "allow",
92+
"meta": {}
93+
}
94+
]
3995
}
4096
}
4197
},

backend/schema/paths/nginx/access-lists/listID/put.json

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@
4545
"additionalProperties": false,
4646
"properties": {
4747
"username": {
48-
"type": "string",
49-
"minLength": 1
48+
"$ref": "../../../../common.json#/properties/authorization_username"
5049
},
5150
"password": {
52-
"type": "string"
51+
"$ref": "../../../../common.json#/properties/authorization_password"
5352
}
5453
}
5554
}
@@ -61,23 +60,10 @@
6160
"additionalProperties": false,
6261
"properties": {
6362
"address": {
64-
"oneOf": [
65-
{
66-
"type": "string",
67-
"pattern": "^([0-9]{1,3}\\.){3}[0-9]{1,3}(/([0-9]|[1-2][0-9]|3[0-2]))?$"
68-
},
69-
{
70-
"type": "string",
71-
"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]))?$"
72-
},
73-
{
74-
"type": "string",
75-
"pattern": "^all$"
76-
}
77-
]
63+
"$ref": "../../../../common.json#/properties/access_address"
7864
},
7965
"directive": {
80-
"$ref": "../../../../components/access-list-object.json#/properties/directive"
66+
"$ref": "../../../../common.json#/properties/access_directive"
8167
}
8268
}
8369
}
@@ -97,9 +83,9 @@
9783
"value": {
9884
"id": 1,
9985
"created_on": "2024-10-08T22:15:40.000Z",
100-
"modified_on": "2024-10-08T22:34:34.000Z",
86+
"modified_on": "2024-10-08T22:15:40.000Z",
10187
"owner_user_id": 1,
102-
"name": "test123!!",
88+
"name": "test1234",
10389
"meta": {},
10490
"satisfy_any": true,
10591
"pass_auth": false,
@@ -148,8 +134,7 @@
148134
"directive": "allow",
149135
"meta": {}
150136
}
151-
],
152-
"proxy_hosts": []
137+
]
153138
}
154139
}
155140
},

0 commit comments

Comments
 (0)