k2hr3-api 1.0.42 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/k2hr3-init.sh.templ +2 -2
- package/dist/.gitkeep +0 -0
- package/dist/src/app.js +262 -0
- package/{bin → dist/src/bin}/run.sh +1 -1
- package/dist/src/bin/watcher.js +113 -0
- package/dist/src/bin/www.js +217 -0
- package/dist/src/lib/basicipcheck.js +392 -0
- package/dist/src/lib/cacerts.js +106 -0
- package/dist/src/lib/dbglogging.js +190 -0
- package/dist/src/lib/dummyuserapi.js +719 -0
- package/dist/src/lib/ipwatch.js +354 -0
- package/dist/src/lib/k2hr3acrutil.js +532 -0
- package/dist/src/lib/k2hr3apiutil.js +1444 -0
- package/dist/src/lib/k2hr3cliutil.js +183 -0
- package/dist/src/lib/k2hr3config.js +832 -0
- package/dist/src/lib/k2hr3cryptutil.js +258 -0
- package/dist/src/lib/k2hr3dkc.js +12121 -0
- package/dist/src/lib/k2hr3extdata.js +198 -0
- package/dist/src/lib/k2hr3keys.js +207 -0
- package/dist/src/lib/k2hr3resutil.js +111 -0
- package/dist/src/lib/k2hr3template.js +6546 -0
- package/dist/src/lib/k2hr3tokens.js +2643 -0
- package/dist/src/lib/k2hr3userdata.js +296 -0
- package/dist/src/lib/k8soidc.js +1000 -0
- package/dist/src/lib/openstackapiv2.js +695 -0
- package/dist/src/lib/openstackapiv3.js +932 -0
- package/dist/src/lib/openstackep.js +667 -0
- package/{tests/auto_common.js → dist/src/lib/types.js} +4 -38
- package/dist/src/routes/acr.js +704 -0
- package/dist/src/routes/debugVerify.js +294 -0
- package/dist/src/routes/extdata.js +219 -0
- package/dist/src/routes/list.js +264 -0
- package/dist/src/routes/policy.js +840 -0
- package/dist/src/routes/resource.js +1489 -0
- package/dist/src/routes/role.js +2627 -0
- package/dist/src/routes/service.js +908 -0
- package/dist/src/routes/tenant.js +1141 -0
- package/dist/src/routes/userTokens.js +482 -0
- package/dist/src/routes/userdata.js +212 -0
- package/dist/src/routes/version.js +103 -0
- package/package.json +152 -121
- package/ChangeLog +0 -378
- package/app.js +0 -292
- package/bin/watcher +0 -122
- package/bin/www +0 -180
- package/eslint.config.mjs +0 -68
- package/lib/basicipcheck.js +0 -376
- package/lib/cacerts.js +0 -71
- package/lib/dbglogging.js +0 -151
- package/lib/dummyuserapi.js +0 -766
- package/lib/ipwatch.js +0 -379
- package/lib/k2hr3acrutil.js +0 -516
- package/lib/k2hr3apiutil.js +0 -1494
- package/lib/k2hr3cliutil.js +0 -191
- package/lib/k2hr3config.js +0 -826
- package/lib/k2hr3cryptutil.js +0 -254
- package/lib/k2hr3dkc.js +0 -12632
- package/lib/k2hr3extdata.js +0 -198
- package/lib/k2hr3keys.js +0 -234
- package/lib/k2hr3resutil.js +0 -100
- package/lib/k2hr3template.js +0 -6925
- package/lib/k2hr3tokens.js +0 -2799
- package/lib/k2hr3userdata.js +0 -312
- package/lib/k8soidc.js +0 -1012
- package/lib/openstackapiv2.js +0 -764
- package/lib/openstackapiv3.js +0 -1032
- package/lib/openstackep.js +0 -553
- package/routes/acr.js +0 -738
- package/routes/debugVerify.js +0 -263
- package/routes/extdata.js +0 -232
- package/routes/list.js +0 -270
- package/routes/policy.js +0 -869
- package/routes/resource.js +0 -1441
- package/routes/role.js +0 -2664
- package/routes/service.js +0 -894
- package/routes/tenant.js +0 -1095
- package/routes/userTokens.js +0 -511
- package/routes/userdata.js +0 -218
- package/routes/version.js +0 -108
- package/templ/Dockerfile.templ +0 -71
- package/tests/auto_acr.js +0 -1101
- package/tests/auto_acr_spec.js +0 -79
- package/tests/auto_all_spec.js +0 -142
- package/tests/auto_control_subprocess.sh +0 -243
- package/tests/auto_extdata.js +0 -220
- package/tests/auto_extdata_spec.js +0 -79
- package/tests/auto_init_config_json.sh +0 -275
- package/tests/auto_k2hdkc_server.ini +0 -109
- package/tests/auto_k2hdkc_slave.ini +0 -83
- package/tests/auto_list.js +0 -439
- package/tests/auto_list_spec.js +0 -79
- package/tests/auto_policy.js +0 -1579
- package/tests/auto_policy_spec.js +0 -79
- package/tests/auto_resource.js +0 -10956
- package/tests/auto_resource_spec.js +0 -79
- package/tests/auto_role.js +0 -6150
- package/tests/auto_role_spec.js +0 -79
- package/tests/auto_service.js +0 -770
- package/tests/auto_service_spec.js +0 -79
- package/tests/auto_subprocesses.js +0 -114
- package/tests/auto_template.sh +0 -126
- package/tests/auto_tenant.js +0 -1100
- package/tests/auto_tenant_spec.js +0 -79
- package/tests/auto_token_util.js +0 -219
- package/tests/auto_userdata.js +0 -292
- package/tests/auto_userdata_spec.js +0 -79
- package/tests/auto_usertokens.js +0 -565
- package/tests/auto_usertokens_spec.js +0 -79
- package/tests/auto_version.js +0 -127
- package/tests/auto_version_spec.js +0 -79
- package/tests/auto_watcher.js +0 -157
- package/tests/auto_watcher_spec.js +0 -79
- package/tests/k2hdkc_test.data +0 -986
- package/tests/k2hdkc_test_load.sh +0 -255
- package/tests/k2hr3template_test.js +0 -187
- package/tests/k2hr3template_test.sh +0 -339
- package/tests/k2hr3template_test_async.js +0 -216
- package/tests/k2hr3template_test_template.result +0 -7117
- package/tests/k2hr3template_test_template.txt +0 -3608
- package/tests/k2hr3template_test_vars.js +0 -194
- package/tests/manual_acr_delete.js +0 -143
- package/tests/manual_acr_get.js +0 -297
- package/tests/manual_acr_postput.js +0 -215
- package/tests/manual_allusertenant_get.js +0 -113
- package/tests/manual_extdata_get.js +0 -191
- package/tests/manual_k2hr3keys_get.js +0 -84
- package/tests/manual_list_gethead.js +0 -230
- package/tests/manual_policy_delete.js +0 -132
- package/tests/manual_policy_gethead.js +0 -275
- package/tests/manual_policy_postput.js +0 -297
- package/tests/manual_resource_delete.js +0 -433
- package/tests/manual_resource_gethead.js +0 -423
- package/tests/manual_resource_postput.js +0 -487
- package/tests/manual_role_delete.js +0 -404
- package/tests/manual_role_gethead.js +0 -547
- package/tests/manual_role_postput.js +0 -544
- package/tests/manual_service_delete.js +0 -153
- package/tests/manual_service_gethead.js +0 -178
- package/tests/manual_service_postput.js +0 -348
- package/tests/manual_tenant_delete.js +0 -186
- package/tests/manual_tenant_gethead.js +0 -268
- package/tests/manual_tenant_postput.js +0 -293
- package/tests/manual_test.sh +0 -352
- package/tests/manual_userdata_get.js +0 -173
- package/tests/manual_usertoken_gethead.js +0 -136
- package/tests/manual_usertoken_postput.js +0 -310
- package/tests/manual_version_get.js +0 -127
- package/tests/run_local_test_k2hdkc.sh +0 -174
- package/tests/test.sh +0 -333
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* K2HR3 REST API
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2018 Yahoo Japan Corporation.
|
|
6
|
+
*
|
|
7
|
+
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
8
|
+
* common management information for the cloud.
|
|
9
|
+
* K2HR3 can dynamically manage information as "who", "what", "operate".
|
|
10
|
+
* These are stored as roles, resources, policies in K2hdkc, and the
|
|
11
|
+
* client system can dynamically read and modify these information.
|
|
12
|
+
*
|
|
13
|
+
* For the full copyright and license information, please view
|
|
14
|
+
* the license file that was distributed with this source code.
|
|
15
|
+
*
|
|
16
|
+
* AUTHOR: Takeshi Nakatani
|
|
17
|
+
* CREATE: Tue Oct 2 2018
|
|
18
|
+
* REVISION:
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const k2hr3apiutil_1 = __importDefault(require("../lib/k2hr3apiutil"));
|
|
26
|
+
const dbglogging_1 = __importDefault(require("../lib/dbglogging"));
|
|
27
|
+
const k2hr3resutil_1 = __importDefault(require("../lib/k2hr3resutil"));
|
|
28
|
+
const k2hr3userdata_1 = __importDefault(require("../lib/k2hr3userdata"));
|
|
29
|
+
const express_1 = __importDefault(require("express"));
|
|
30
|
+
const router = express_1.default.Router();
|
|
31
|
+
//---------------------------------------------------------
|
|
32
|
+
// Router GET
|
|
33
|
+
//---------------------------------------------------------
|
|
34
|
+
//
|
|
35
|
+
// Mountpath : '/v1/userdata/*'
|
|
36
|
+
//
|
|
37
|
+
// GET '/v1/userdata/<encrypted data>' : get userdata for openstack on version 1
|
|
38
|
+
// response : compressed(gzip) userdata(binary) for openstack
|
|
39
|
+
//
|
|
40
|
+
// This mount point is for getting compressed userdata of openstack which is
|
|
41
|
+
// used at creating instance.
|
|
42
|
+
// The response data is compressed by gzip, and it included multipart userdata.
|
|
43
|
+
// The userdata probably has "cloud-config" and "script" for registering ip
|
|
44
|
+
// address to k2hr3 role as its member.
|
|
45
|
+
// The url last path part is url encoded string which is base64 and encrypted
|
|
46
|
+
// role-token and role name. This userdata script will register ip address.
|
|
47
|
+
//
|
|
48
|
+
router.get('/', (req, res, next) => {
|
|
49
|
+
dbglogging_1.default.dlog('CALL:', req.method, req.url);
|
|
50
|
+
if ('GET' !== req.method) {
|
|
51
|
+
// HEAD request comes here, so it should be routed to head(not defined) function.
|
|
52
|
+
next();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!k2hr3apiutil_1.default.isPlainObject(req) ||
|
|
56
|
+
!k2hr3apiutil_1.default.isSafeString(req.baseUrl) ||
|
|
57
|
+
!k2hr3apiutil_1.default.isPlainObject(req.headers)) // Must User-Agent in header
|
|
58
|
+
{
|
|
59
|
+
const result = {
|
|
60
|
+
result: false,
|
|
61
|
+
message: 'GET request or url is wrong'
|
|
62
|
+
};
|
|
63
|
+
dbglogging_1.default.elog(result.message);
|
|
64
|
+
res.type('application/json; charset=utf-8');
|
|
65
|
+
k2hr3resutil_1.default.errResponse(req, res, 400, result); // 400: Bad Request
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
//------------------------------
|
|
69
|
+
// Check headers
|
|
70
|
+
//------------------------------
|
|
71
|
+
let isGzip = false;
|
|
72
|
+
const tmpAgent = req.headers['user-agent'];
|
|
73
|
+
if (!k2hr3apiutil_1.default.isSafeEntity(tmpAgent)) {
|
|
74
|
+
// 'User-Agent' Must have 'Cloud-Init'
|
|
75
|
+
const result = {
|
|
76
|
+
result: false,
|
|
77
|
+
message: 'GET request does not have User-Agent header'
|
|
78
|
+
};
|
|
79
|
+
dbglogging_1.default.elog(result.message);
|
|
80
|
+
res.type('application/json; charset=utf-8');
|
|
81
|
+
k2hr3resutil_1.default.errResponse(req, res, 400, result); // 400: Bad Request
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const strtmp = tmpAgent.toLowerCase();
|
|
86
|
+
if (-1 == strtmp.indexOf('cloud-init')) {
|
|
87
|
+
// 'User-Agent' Must have 'Cloud-Init'
|
|
88
|
+
const result = {
|
|
89
|
+
result: false,
|
|
90
|
+
message: 'GET request is not allowed from your client'
|
|
91
|
+
};
|
|
92
|
+
dbglogging_1.default.elog(result.message);
|
|
93
|
+
res.type('application/json; charset=utf-8');
|
|
94
|
+
k2hr3resutil_1.default.errResponse(req, res, 400, result); // 400: Bad Request
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Check version
|
|
98
|
+
const ciptn = new RegExp('cloud-init/([0-9]+).([0-9]+).([0-9]+)'); // regex = /Cloud-Init\/([0-9]+)\.([0-9]+)\.([0-9]+)/
|
|
99
|
+
const cimatchs = decodeURI(strtmp).match(ciptn);
|
|
100
|
+
if (k2hr3apiutil_1.default.isStringArray(cimatchs) && k2hr3apiutil_1.default.isNotEmptyArray(cimatchs) && 3 < cimatchs.length) {
|
|
101
|
+
const tmp_match_1 = k2hr3apiutil_1.default.cvtToNumber(cimatchs[1]);
|
|
102
|
+
const tmp_match_2 = k2hr3apiutil_1.default.cvtToNumber(cimatchs[2]);
|
|
103
|
+
const tmp_match_3 = k2hr3apiutil_1.default.cvtToNumber(cimatchs[3]);
|
|
104
|
+
if ((k2hr3apiutil_1.default.isSafeNumber(tmp_match_1) && 0 < tmp_match_1) ||
|
|
105
|
+
(k2hr3apiutil_1.default.isSafeNumber(tmp_match_2) && 7 < tmp_match_2) ||
|
|
106
|
+
(k2hr3apiutil_1.default.isSafeNumber(tmp_match_3) && 9 <= tmp_match_3)) {
|
|
107
|
+
// [FORCE]
|
|
108
|
+
// Cloud-Init is 0.7.9 or after it, this version supports gzip compressed
|
|
109
|
+
// userdata. Thus we return gzip compressed userdata.
|
|
110
|
+
dbglogging_1.default.dlog('Cloud-Init version is over 0.7.9, thus we force return gzip compressed userdata');
|
|
111
|
+
isGzip = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const tmpContent = req.headers['content-type'];
|
|
116
|
+
if (k2hr3apiutil_1.default.isSafeString(tmpContent)) {
|
|
117
|
+
if (!k2hr3apiutil_1.default.hasPartString(tmpContent, ';', 'application/octet-stream', true)) {
|
|
118
|
+
// should be 'application/octet-stream', but all type is allowed
|
|
119
|
+
dbglogging_1.default.dlog('GET request Content-Type is not application/octet-stream, but continue...');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
//r3logger.dlog('GET request doe not have Content-Type, but continue...');
|
|
124
|
+
}
|
|
125
|
+
const tmpEnc = req.headers['accept-encoding'];
|
|
126
|
+
if (k2hr3apiutil_1.default.isSafeEntity(tmpEnc)) {
|
|
127
|
+
if (k2hr3apiutil_1.default.hasPartString(tmpEnc, ',', ['gzip', 'deflate'], true)) {
|
|
128
|
+
isGzip = true;
|
|
129
|
+
}
|
|
130
|
+
else if (!isGzip) {
|
|
131
|
+
// Accept-Encoding should have 'gzip' or 'deflate', but all type is allowed
|
|
132
|
+
dbglogging_1.default.dlog('Get request Accept-Encoding does not have gzip nor deflate, but continue...');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
//r3logger.dlog('GET request doe not have Accept-Encoding, but continue...');
|
|
137
|
+
}
|
|
138
|
+
//------------------------------
|
|
139
|
+
// get url last path and decode it
|
|
140
|
+
//------------------------------
|
|
141
|
+
// check path matching
|
|
142
|
+
const requestptn = new RegExp('^/v1/userdata/(.*)'); // regex = /^\/v1\/userdata\/(.*)/
|
|
143
|
+
const reqmatchs = decodeURI(req.baseUrl).match(requestptn);
|
|
144
|
+
if (!k2hr3apiutil_1.default.isStringArray(reqmatchs) || !k2hr3apiutil_1.default.isNotEmptyArray(reqmatchs) || reqmatchs.length < 2 || '' === k2hr3apiutil_1.default.getSafeString(reqmatchs[1])) {
|
|
145
|
+
const result = {
|
|
146
|
+
result: false,
|
|
147
|
+
message: 'GET request url does not have userdata path parameter'
|
|
148
|
+
};
|
|
149
|
+
dbglogging_1.default.elog(result.message);
|
|
150
|
+
res.type('application/json; charset=utf-8');
|
|
151
|
+
k2hr3resutil_1.default.errResponse(req, res, 400, result); // 400: Bad Request
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
// decode and check userdata parameter
|
|
155
|
+
const udproc = new k2hr3userdata_1.default;
|
|
156
|
+
const roleinfo = udproc.decryptRoleInfo(reqmatchs[1]);
|
|
157
|
+
let errorMsg = null;
|
|
158
|
+
if (!k2hr3apiutil_1.default.isValTypeRoleInfo(roleinfo)) {
|
|
159
|
+
// [NOTE]
|
|
160
|
+
// continue for returning error script
|
|
161
|
+
//
|
|
162
|
+
errorMsg = 'Get userdata path is invalid.';
|
|
163
|
+
dbglogging_1.default.elog(errorMsg);
|
|
164
|
+
}
|
|
165
|
+
//------------------------------
|
|
166
|
+
// Make response
|
|
167
|
+
//------------------------------
|
|
168
|
+
if (isGzip) {
|
|
169
|
+
// Gzip
|
|
170
|
+
const responsebody = udproc.getGzipMultipartUserdata((k2hr3apiutil_1.default.isValTypeRoleInfo(roleinfo) ? roleinfo : {}), errorMsg);
|
|
171
|
+
const tmp_length = (k2hr3apiutil_1.default.isPlainObject(responsebody) && k2hr3apiutil_1.default.isSafeNumber(responsebody.length)) ? responsebody.length : 0;
|
|
172
|
+
res.type('application/zip');
|
|
173
|
+
res.setHeader('Content-Encoding', 'gzip');
|
|
174
|
+
res.setHeader('Content-Transfer-Encoding', 'binary');
|
|
175
|
+
res.setHeader('Content-Disposition', 'attachment; filename=k2hr3-userdata.gz');
|
|
176
|
+
res.setHeader('Content-Length', tmp_length);
|
|
177
|
+
dbglogging_1.default.dlog('succeed : (response body is gzip compressed)');
|
|
178
|
+
res.status(200); // 200: OK
|
|
179
|
+
res.send(responsebody?.data ?? '');
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// Text
|
|
183
|
+
const multiobj = udproc.getMultipartUserdata((k2hr3apiutil_1.default.isValTypeRoleInfo(roleinfo) ? roleinfo : {}), errorMsg);
|
|
184
|
+
const responsebody = multiobj.body;
|
|
185
|
+
if (k2hr3apiutil_1.default.isSafeString(multiobj.type)) {
|
|
186
|
+
res.type(multiobj.type);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
res.type('application/json; charset=utf-8');
|
|
190
|
+
}
|
|
191
|
+
res.setHeader(multiobj.mimeverkey, multiobj.mimeverval);
|
|
192
|
+
res.setHeader(multiobj.partcntkey, multiobj.partcntval);
|
|
193
|
+
dbglogging_1.default.dlog('succeed : (response body is not gzip compressed)');
|
|
194
|
+
res.status(200); // 200: OK
|
|
195
|
+
res.send(responsebody);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
//---------------------------------------------------------
|
|
199
|
+
// Exports
|
|
200
|
+
//---------------------------------------------------------
|
|
201
|
+
//
|
|
202
|
+
// Functions
|
|
203
|
+
//
|
|
204
|
+
exports.default = router;
|
|
205
|
+
/*
|
|
206
|
+
* Local variables:
|
|
207
|
+
* tab-width: 4
|
|
208
|
+
* c-basic-offset: 4
|
|
209
|
+
* End:
|
|
210
|
+
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
211
|
+
* vim<600: noexpandtab sw=4 ts=4
|
|
212
|
+
*/
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* K2HR3 REST API
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2017 Yahoo Japan Corporation.
|
|
6
|
+
*
|
|
7
|
+
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
8
|
+
* common management information for the cloud.
|
|
9
|
+
* K2HR3 can dynamically manage information as "who", "what", "operate".
|
|
10
|
+
* These are stored as roles, resources, policies in K2hdkc, and the
|
|
11
|
+
* client system can dynamically read and modify these information.
|
|
12
|
+
*
|
|
13
|
+
* For the full copyright and license information, please view
|
|
14
|
+
* the license file that was distributed with this source code.
|
|
15
|
+
*
|
|
16
|
+
* AUTHOR: Takeshi Nakatani
|
|
17
|
+
* CREATE: Wed Jun 8 2017
|
|
18
|
+
* REVISION:
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
const dbglogging_1 = __importDefault(require("../lib/dbglogging"));
|
|
26
|
+
const express_1 = __importDefault(require("express"));
|
|
27
|
+
const router = express_1.default.Router();
|
|
28
|
+
//
|
|
29
|
+
// GET '/' : get all API version
|
|
30
|
+
// output : {'version': 'v1'}
|
|
31
|
+
//
|
|
32
|
+
router.get('/', (req, res, _) => {
|
|
33
|
+
dbglogging_1.default.dlog('CALL:', req.method, req.url);
|
|
34
|
+
const result = { 'version': ['v1'] };
|
|
35
|
+
res.type('application/json; charset=utf-8');
|
|
36
|
+
res.send(result);
|
|
37
|
+
});
|
|
38
|
+
//
|
|
39
|
+
// GET '/v1': get all API for version 1
|
|
40
|
+
// output : {'type': {'uri': ['method', ...], ...}, ...}
|
|
41
|
+
//
|
|
42
|
+
router.get('/v1', (req, res, _) => {
|
|
43
|
+
dbglogging_1.default.dlog('CALL:', req.method, req.url);
|
|
44
|
+
res.type('application/json; charset=utf-8');
|
|
45
|
+
const result = {
|
|
46
|
+
'version': {
|
|
47
|
+
'/': ['GET'],
|
|
48
|
+
'/v1': ['GET']
|
|
49
|
+
},
|
|
50
|
+
'user token': {
|
|
51
|
+
'/v1/user/tokens': ['HEAD', 'GET', 'POST']
|
|
52
|
+
},
|
|
53
|
+
'host': {
|
|
54
|
+
'/v1/host': ['GET', 'PUT', 'POST', 'DELETE'],
|
|
55
|
+
'/v1/host/{port}': ['PUT', 'POST', 'DELETE'],
|
|
56
|
+
'/v1/host/FQDN': ['DELETE'],
|
|
57
|
+
'/v1/host/FQDN:{port}': ['DELETE'],
|
|
58
|
+
'/v1/host/IP': ['DELETE'],
|
|
59
|
+
'/v1/host/IP:{port}': ['DELETE']
|
|
60
|
+
},
|
|
61
|
+
'service': {
|
|
62
|
+
'/v1/service': ['PUT', 'POST'],
|
|
63
|
+
'/v1/service/{service}': ['GET', 'HEAD', 'PUT', 'POST', 'DELETE']
|
|
64
|
+
},
|
|
65
|
+
'role': {
|
|
66
|
+
'/v1/role': ['PUT', 'POST'],
|
|
67
|
+
'/v1/role/{role}': ['HEAD', 'GET', 'PUT', 'POST', 'DELETE'],
|
|
68
|
+
'/v1/role/token/{role}': ['GET']
|
|
69
|
+
},
|
|
70
|
+
'resource': {
|
|
71
|
+
'/v1/resource': ['PUT', 'POST'],
|
|
72
|
+
'/v1/resource/{resource}': ['HEAD', 'GET', 'DELETE']
|
|
73
|
+
},
|
|
74
|
+
'policy': {
|
|
75
|
+
'/v1/policy': ['PUT', 'POST'],
|
|
76
|
+
'/v1/policy/{policy}': ['HEAD', 'GET', 'DELETE']
|
|
77
|
+
},
|
|
78
|
+
'list': {
|
|
79
|
+
'/v1/list': ['HEAD', 'GET'],
|
|
80
|
+
'/v1/list/{role, resource, policy}/{path}': ['HEAD', 'GET']
|
|
81
|
+
},
|
|
82
|
+
'acr': {
|
|
83
|
+
'/v1/acr/{service}': ['GET', 'PUT', 'POST', 'DELETE']
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
res.status(200); // 200: OK
|
|
87
|
+
res.send(JSON.stringify(result));
|
|
88
|
+
});
|
|
89
|
+
//---------------------------------------------------------
|
|
90
|
+
// Exports
|
|
91
|
+
//---------------------------------------------------------
|
|
92
|
+
//
|
|
93
|
+
// Functions
|
|
94
|
+
//
|
|
95
|
+
exports.default = router;
|
|
96
|
+
/*
|
|
97
|
+
* Local variables:
|
|
98
|
+
* tab-width: 4
|
|
99
|
+
* c-basic-offset: 4
|
|
100
|
+
* End:
|
|
101
|
+
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
102
|
+
* vim<600: noexpandtab sw=4 ts=4
|
|
103
|
+
*/
|