k2hr3-api 1.0.42 → 2.0.1
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 +4 -4
- 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
|
@@ -1,547 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* K2HR3 REST API
|
|
3
|
-
*
|
|
4
|
-
* Copyright 2017 Yahoo Japan Corporation.
|
|
5
|
-
*
|
|
6
|
-
* K2HR3 is K2hdkc based Resource and Roles and policy Rules, gathers
|
|
7
|
-
* common management information for the cloud.
|
|
8
|
-
* K2HR3 can dynamically manage information as "who", "what", "operate".
|
|
9
|
-
* These are stored as roles, resources, policies in K2hdkc, and the
|
|
10
|
-
* client system can dynamically read and modify these information.
|
|
11
|
-
*
|
|
12
|
-
* For the full copyright and license information, please view
|
|
13
|
-
* the license file that was distributed with this source code.
|
|
14
|
-
*
|
|
15
|
-
* AUTHOR: Takeshi Nakatani
|
|
16
|
-
* CREATE: Wed Jun 8 2017
|
|
17
|
-
* REVISION:
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
'use strict';
|
|
22
|
-
|
|
23
|
-
var http = require('http');
|
|
24
|
-
var https = require('https');
|
|
25
|
-
|
|
26
|
-
var cacerts = require('../lib/cacerts');
|
|
27
|
-
var apiutil = require('../lib/k2hr3apiutil');
|
|
28
|
-
var cliutil = require('../lib/k2hr3cliutil');
|
|
29
|
-
|
|
30
|
-
// Debug logging objects
|
|
31
|
-
var r3logger = require('../lib/dbglogging');
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
// Hostname and port from env
|
|
35
|
-
//
|
|
36
|
-
var hostname = apiutil.getSafeString(process.env.APIHOST);
|
|
37
|
-
var hostport = apiutil.getSafeString(process.env.APIPORT);
|
|
38
|
-
var is_https = apiutil.compareCaseString('yes', process.env.HTTPS_ENV);
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
// Request API for test
|
|
42
|
-
//
|
|
43
|
-
function getV1Role(token, name, is_expand)
|
|
44
|
-
{
|
|
45
|
-
var headers = {
|
|
46
|
-
'Content-Type': 'application/json',
|
|
47
|
-
'Content-Length': 0,
|
|
48
|
-
'X-Auth-Token': token
|
|
49
|
-
};
|
|
50
|
-
var options = {
|
|
51
|
-
'host': hostname,
|
|
52
|
-
'port': hostport,
|
|
53
|
-
'path': '/v1/role/' + name + (is_expand ? '' : '?expand=false'), // default expand is true
|
|
54
|
-
'method': 'GET',
|
|
55
|
-
'headers': headers
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
59
|
-
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
60
|
-
|
|
61
|
-
var httpobj;
|
|
62
|
-
if(is_https){
|
|
63
|
-
if(null !== cacerts.ca){
|
|
64
|
-
options.ca = cacerts.ca;
|
|
65
|
-
}
|
|
66
|
-
options.rejectUnauthorized = false; // always insecure for this manual test
|
|
67
|
-
options.agent = new https.Agent(options);
|
|
68
|
-
httpobj = https;
|
|
69
|
-
}else{
|
|
70
|
-
options.agent = new http.Agent(options);
|
|
71
|
-
httpobj = http;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
var req = httpobj.request(options, function(res)
|
|
75
|
-
{
|
|
76
|
-
var response = '';
|
|
77
|
-
console.log('RESPONSE CODE = ' + res.statusCode);
|
|
78
|
-
r3logger.dlog('response status = ' + res.statusCode);
|
|
79
|
-
r3logger.dlog('response header = ' + JSON.stringify(res.headers));
|
|
80
|
-
res.setEncoding('utf8');
|
|
81
|
-
|
|
82
|
-
res.on('data', function (chunk)
|
|
83
|
-
{
|
|
84
|
-
r3logger.dlog('response chunk = ' + chunk);
|
|
85
|
-
response += chunk;
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
res.on('end', function(result) // eslint-disable-line no-unused-vars
|
|
89
|
-
{
|
|
90
|
-
r3logger.mlog(r3logger.dump(response)); // response is object(or not)
|
|
91
|
-
console.log('RESPONSE BODY = ' + JSON.stringify(response));
|
|
92
|
-
process.exit(0);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
req.on('error', function(e)
|
|
97
|
-
{
|
|
98
|
-
r3logger.elog('problem with request: ' + e.message);
|
|
99
|
-
});
|
|
100
|
-
req.end();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function getV1RoleToken(token, name, expire)
|
|
104
|
-
{
|
|
105
|
-
var headers = {
|
|
106
|
-
'Content-Type': 'application/json',
|
|
107
|
-
'Content-Length': 0,
|
|
108
|
-
};
|
|
109
|
-
if(apiutil.isSafeString(token)){
|
|
110
|
-
headers['X-Auth-Token'] = token;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
var urlarg = '';
|
|
114
|
-
if(null !== expire && !isNaN(expire)){
|
|
115
|
-
urlarg = '?expire=' + String(expire);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
var options = {
|
|
119
|
-
'host': hostname,
|
|
120
|
-
'port': hostport,
|
|
121
|
-
'path': '/v1/role/token/' + name + urlarg,
|
|
122
|
-
'method': 'GET',
|
|
123
|
-
'headers': headers
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
127
|
-
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
128
|
-
|
|
129
|
-
var httpobj;
|
|
130
|
-
if(is_https){
|
|
131
|
-
if(null !== cacerts.ca){
|
|
132
|
-
options.ca = cacerts.ca;
|
|
133
|
-
}
|
|
134
|
-
options.rejectUnauthorized = false; // always insecure for this manual test
|
|
135
|
-
options.agent = new https.Agent(options);
|
|
136
|
-
httpobj = https;
|
|
137
|
-
}else{
|
|
138
|
-
options.agent = new http.Agent(options);
|
|
139
|
-
httpobj = http;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
var req = httpobj.request(options, function(res)
|
|
143
|
-
{
|
|
144
|
-
var response = '';
|
|
145
|
-
r3logger.dlog('response status = ' + res.statusCode);
|
|
146
|
-
r3logger.dlog('response header = ' + JSON.stringify(res.headers));
|
|
147
|
-
res.setEncoding('utf8');
|
|
148
|
-
|
|
149
|
-
res.on('data', function (chunk)
|
|
150
|
-
{
|
|
151
|
-
r3logger.dlog('response chunk = ' + chunk);
|
|
152
|
-
response += chunk;
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
res.on('end', function(result) // eslint-disable-line no-unused-vars
|
|
156
|
-
{
|
|
157
|
-
r3logger.mlog(r3logger.dump(response)); // response is object(or not)
|
|
158
|
-
console.log('RESPONSE =\n' + JSON.stringify(response));
|
|
159
|
-
process.exit(0);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
req.on('error', function(e)
|
|
164
|
-
{
|
|
165
|
-
r3logger.elog('problem with request: ' + e.message);
|
|
166
|
-
});
|
|
167
|
-
req.end();
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function getV1RoleTokenList(token, name, expand)
|
|
171
|
-
{
|
|
172
|
-
var headers = {
|
|
173
|
-
'Content-Type': 'application/json',
|
|
174
|
-
'Content-Length': 0,
|
|
175
|
-
};
|
|
176
|
-
if(apiutil.isSafeString(token)){
|
|
177
|
-
headers['X-Auth-Token'] = token;
|
|
178
|
-
}
|
|
179
|
-
var options = {
|
|
180
|
-
'host': hostname,
|
|
181
|
-
'port': hostport,
|
|
182
|
-
'path': '/v1/role/token/list/' + name + (expand ? '?expand=true' : '?expand=false'),
|
|
183
|
-
'method': 'GET',
|
|
184
|
-
'headers': headers
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
188
|
-
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
189
|
-
|
|
190
|
-
var httpobj;
|
|
191
|
-
if(is_https){
|
|
192
|
-
if(null !== cacerts.ca){
|
|
193
|
-
options.ca = cacerts.ca;
|
|
194
|
-
}
|
|
195
|
-
options.rejectUnauthorized = false; // always insecure for this manual test
|
|
196
|
-
options.agent = new https.Agent(options);
|
|
197
|
-
httpobj = https;
|
|
198
|
-
}else{
|
|
199
|
-
options.agent = new http.Agent(options);
|
|
200
|
-
httpobj = http;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
var req = httpobj.request(options, function(res)
|
|
204
|
-
{
|
|
205
|
-
var response = '';
|
|
206
|
-
r3logger.dlog('response status = ' + res.statusCode);
|
|
207
|
-
r3logger.dlog('response header = ' + JSON.stringify(res.headers));
|
|
208
|
-
res.setEncoding('utf8');
|
|
209
|
-
|
|
210
|
-
res.on('data', function (chunk)
|
|
211
|
-
{
|
|
212
|
-
r3logger.dlog('response chunk = ' + chunk);
|
|
213
|
-
response += chunk;
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
res.on('end', function(result) // eslint-disable-line no-unused-vars
|
|
217
|
-
{
|
|
218
|
-
r3logger.mlog(r3logger.dump(response)); // response is object(or not)
|
|
219
|
-
console.log('RESPONSE =\n' + JSON.stringify(response));
|
|
220
|
-
process.exit(0);
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
req.on('error', function(e)
|
|
225
|
-
{
|
|
226
|
-
r3logger.elog('problem with request: ' + e.message);
|
|
227
|
-
});
|
|
228
|
-
req.end();
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function headV1Role(token, roleyrn, port, cuk)
|
|
232
|
-
{
|
|
233
|
-
var headers = {
|
|
234
|
-
'Content-Type': 'application/json',
|
|
235
|
-
'Content-Length': 0
|
|
236
|
-
};
|
|
237
|
-
if(apiutil.isSafeString(token)){
|
|
238
|
-
headers['X-Auth-Token'] = token;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
var urlargs = '';
|
|
242
|
-
if(null !== port){
|
|
243
|
-
urlargs = '?port=' + String(port);
|
|
244
|
-
}
|
|
245
|
-
if(apiutil.isSafeString(cuk)){
|
|
246
|
-
if(apiutil.isSafeString(urlargs)){
|
|
247
|
-
urlargs += '&cuk=';
|
|
248
|
-
}else{
|
|
249
|
-
urlargs = '?cuk=';
|
|
250
|
-
}
|
|
251
|
-
urlargs += cuk;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
var options = {
|
|
255
|
-
'host': hostname,
|
|
256
|
-
'port': hostport,
|
|
257
|
-
'path': '/v1/role/' + roleyrn + urlargs,
|
|
258
|
-
'method': 'HEAD',
|
|
259
|
-
'headers': headers
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
r3logger.dlog('request options = ' + JSON.stringify(options));
|
|
263
|
-
r3logger.dlog('request headers = ' + JSON.stringify(headers));
|
|
264
|
-
|
|
265
|
-
var httpobj;
|
|
266
|
-
if(is_https){
|
|
267
|
-
if(null !== cacerts.ca){
|
|
268
|
-
options.ca = cacerts.ca;
|
|
269
|
-
}
|
|
270
|
-
options.rejectUnauthorized = false; // always insecure for this manual test
|
|
271
|
-
options.agent = new https.Agent(options);
|
|
272
|
-
httpobj = https;
|
|
273
|
-
}else{
|
|
274
|
-
options.agent = new http.Agent(options);
|
|
275
|
-
httpobj = http;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
var req = httpobj.request(options, function(res)
|
|
279
|
-
{
|
|
280
|
-
var response = '';
|
|
281
|
-
console.log('RESPONSE CODE = ' + res.statusCode);
|
|
282
|
-
r3logger.dlog('response status = ' + res.statusCode);
|
|
283
|
-
r3logger.dlog('response header = ' + JSON.stringify(res.headers));
|
|
284
|
-
res.setEncoding('utf8');
|
|
285
|
-
|
|
286
|
-
res.on('data', function (chunk)
|
|
287
|
-
{
|
|
288
|
-
r3logger.dlog('response chunk = ' + chunk);
|
|
289
|
-
response += chunk;
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
res.on('end', function(result) // eslint-disable-line no-unused-vars
|
|
293
|
-
{
|
|
294
|
-
r3logger.mlog(r3logger.dump(response)); // response is object(or not)
|
|
295
|
-
console.log('RESPONSE BODY = ' + JSON.stringify(response));
|
|
296
|
-
process.exit(0);
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
|
|
300
|
-
req.on('error', function(e)
|
|
301
|
-
{
|
|
302
|
-
r3logger.elog('problem with request: ' + e.message);
|
|
303
|
-
});
|
|
304
|
-
req.end();
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
//
|
|
308
|
-
// run
|
|
309
|
-
//
|
|
310
|
-
cliutil.getConsoleInput('Method(GET/HEAD) : ', true, false, function(isbreak, method)
|
|
311
|
-
{
|
|
312
|
-
if(isbreak){
|
|
313
|
-
process.exit(0);
|
|
314
|
-
}
|
|
315
|
-
var _method = method;
|
|
316
|
-
|
|
317
|
-
if(apiutil.compareCaseString('get', _method)){
|
|
318
|
-
|
|
319
|
-
cliutil.getConsoleInput('host or token or tokenlist : ', true, false, function(isbreak, type)
|
|
320
|
-
{
|
|
321
|
-
if(isbreak){
|
|
322
|
-
process.exit(0);
|
|
323
|
-
}
|
|
324
|
-
if(apiutil.compareCaseString('host', type)){
|
|
325
|
-
// get role data
|
|
326
|
-
cliutil.getConsoleInput('Scoped user token : ', true, false, function(isbreak, token)
|
|
327
|
-
{
|
|
328
|
-
if(isbreak){
|
|
329
|
-
process.exit(0);
|
|
330
|
-
}
|
|
331
|
-
var _token = token;
|
|
332
|
-
|
|
333
|
-
cliutil.getConsoleInput('Role name : ', true, false, function(isbreak, name)
|
|
334
|
-
{
|
|
335
|
-
if(isbreak){
|
|
336
|
-
process.exit(0);
|
|
337
|
-
}
|
|
338
|
-
var _name = name;
|
|
339
|
-
|
|
340
|
-
cliutil.getConsoleInput('Role expand(true/false) : ', true, false, function(isbreak, expand)
|
|
341
|
-
{
|
|
342
|
-
if(isbreak){
|
|
343
|
-
process.exit(0);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
var _is_expand = false;
|
|
347
|
-
if(apiutil.compareCaseString('true', expand)){
|
|
348
|
-
_is_expand = true;
|
|
349
|
-
}else if(apiutil.compareCaseString('false', expand)){
|
|
350
|
-
_is_expand = false;
|
|
351
|
-
}else{
|
|
352
|
-
console.log('resource expand must be TRUE or FALSE : ' + expand);
|
|
353
|
-
process.exit(0);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// run
|
|
357
|
-
getV1Role(_token, _name, _is_expand);
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
}else if(apiutil.compareCaseString('token', type)){
|
|
363
|
-
// get role token
|
|
364
|
-
cliutil.getConsoleInput('Role name : ', true, false, function(isbreak, name)
|
|
365
|
-
{
|
|
366
|
-
if(isbreak){
|
|
367
|
-
process.exit(0);
|
|
368
|
-
}
|
|
369
|
-
var _name = name;
|
|
370
|
-
|
|
371
|
-
cliutil.getConsoleInput('Token type USER/ROLE/NULL : ', true, false, function(isbreak, type)
|
|
372
|
-
{
|
|
373
|
-
if(isbreak){
|
|
374
|
-
process.exit(0);
|
|
375
|
-
}
|
|
376
|
-
var _token_type = type;
|
|
377
|
-
if(apiutil.compareCaseString('USER', type)){
|
|
378
|
-
_token_type = 'user';
|
|
379
|
-
}else if(apiutil.compareCaseString('ROLE', type)){
|
|
380
|
-
_token_type = 'role';
|
|
381
|
-
}else{
|
|
382
|
-
// run
|
|
383
|
-
getV1RoleToken(null, _name);
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
cliutil.getConsoleInput('Scoped ' + _token_type + ' token : ', true, false, function(isbreak, token)
|
|
388
|
-
{
|
|
389
|
-
if(isbreak){
|
|
390
|
-
process.exit(0);
|
|
391
|
-
}
|
|
392
|
-
var _token;
|
|
393
|
-
if('user' === _token_type){
|
|
394
|
-
_token = 'U=' + token;
|
|
395
|
-
}else{
|
|
396
|
-
_token = 'R=' + token;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
if('user' == _token_type){
|
|
400
|
-
cliutil.getConsoleInput('expire(default or number or no expire(NO)) : ', true, false, function(isbreak, expire)
|
|
401
|
-
{
|
|
402
|
-
if(isbreak){
|
|
403
|
-
process.exit(0);
|
|
404
|
-
}
|
|
405
|
-
var _expire = null;
|
|
406
|
-
if(!isNaN(expire)){
|
|
407
|
-
_expire = parseInt(expire);
|
|
408
|
-
}else if(apiutil.compareCaseString('no expire', expire) || apiutil.compareCaseString('no', expire)){
|
|
409
|
-
_expire = 0;
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// run
|
|
413
|
-
getV1RoleToken(_token, _name, _expire);
|
|
414
|
-
});
|
|
415
|
-
}else{
|
|
416
|
-
// run
|
|
417
|
-
getV1RoleToken(_token, _name);
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
}else if(apiutil.compareCaseString('tokenlist', type)){
|
|
424
|
-
// get role token list
|
|
425
|
-
cliutil.getConsoleInput('Role name : ', true, false, function(isbreak, name)
|
|
426
|
-
{
|
|
427
|
-
if(isbreak){
|
|
428
|
-
process.exit(0);
|
|
429
|
-
}
|
|
430
|
-
var _name = name;
|
|
431
|
-
|
|
432
|
-
cliutil.getConsoleInput('Scoped User token : ', true, false, function(isbreak, token)
|
|
433
|
-
{
|
|
434
|
-
if(isbreak){
|
|
435
|
-
process.exit(0);
|
|
436
|
-
}
|
|
437
|
-
var _token = 'U=' + token;
|
|
438
|
-
|
|
439
|
-
cliutil.getConsoleInput('expand(default yes) - y/n : ', true, false, function(isbreak, expand)
|
|
440
|
-
{
|
|
441
|
-
if(isbreak){
|
|
442
|
-
process.exit(0);
|
|
443
|
-
}
|
|
444
|
-
var _expand = true;
|
|
445
|
-
if(apiutil.compareCaseString('no', expand) || apiutil.compareCaseString('n', expand)){
|
|
446
|
-
_expand = false;
|
|
447
|
-
}else{
|
|
448
|
-
_expand = true;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
// run
|
|
452
|
-
getV1RoleTokenList(_token, _name, _expand);
|
|
453
|
-
});
|
|
454
|
-
});
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
}else{
|
|
458
|
-
console.log('resource type must be DATA or TOKEN : ' + type);
|
|
459
|
-
process.exit(0);
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
}else if(apiutil.compareCaseString('head', _method)){
|
|
464
|
-
|
|
465
|
-
cliutil.getConsoleInput('Token type USER/ROLE/NULL : ', true, false, function(isbreak, type)
|
|
466
|
-
{
|
|
467
|
-
if(isbreak){
|
|
468
|
-
process.exit(0);
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
var _type = null;
|
|
472
|
-
if(apiutil.compareCaseString('user', type)){
|
|
473
|
-
_type = 'user';
|
|
474
|
-
}else if(apiutil.compareCaseString('role', type)){
|
|
475
|
-
_type = 'role';
|
|
476
|
-
}else if(!apiutil.isSafeString(type) || apiutil.compareCaseString('null', type)){
|
|
477
|
-
_type = null;
|
|
478
|
-
}else{
|
|
479
|
-
console.log('token type must be USER or ROLE or NULL(empty) : ' + type);
|
|
480
|
-
process.exit(0);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
cliutil.getConsoleInput('Role(full yrn for ROLE/NULL) : ', true, false, function(isbreak, roleyrn)
|
|
484
|
-
{
|
|
485
|
-
if(isbreak){
|
|
486
|
-
process.exit(0);
|
|
487
|
-
}
|
|
488
|
-
var _roleyrn = roleyrn;
|
|
489
|
-
|
|
490
|
-
if('user' === _type || 'role' === _type){
|
|
491
|
-
|
|
492
|
-
cliutil.getConsoleInput('Scoped ' + _type + ' token : ', true, false, function(isbreak, token)
|
|
493
|
-
{
|
|
494
|
-
if(isbreak){
|
|
495
|
-
process.exit(0);
|
|
496
|
-
}
|
|
497
|
-
var _token;
|
|
498
|
-
if('user' === _type){
|
|
499
|
-
_token = 'U=' + token;
|
|
500
|
-
}else{
|
|
501
|
-
_token = 'R=' + token;
|
|
502
|
-
}
|
|
503
|
-
// run
|
|
504
|
-
headV1Role(_token, _roleyrn);
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
}else{
|
|
508
|
-
|
|
509
|
-
cliutil.getConsoleInput('port number(allow empty) : ', true, false, function(isbreak, port)
|
|
510
|
-
{
|
|
511
|
-
if(isbreak){
|
|
512
|
-
process.exit(0);
|
|
513
|
-
}
|
|
514
|
-
var _port = null;
|
|
515
|
-
if(!isNaN(port)){
|
|
516
|
-
_port = port;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
cliutil.getConsoleInput('cuk(allow empty, need for k8s) : ', true, false, function(isbreak, cuk)
|
|
520
|
-
{
|
|
521
|
-
if(isbreak){
|
|
522
|
-
process.exit(0);
|
|
523
|
-
}
|
|
524
|
-
var _cuk = cuk;
|
|
525
|
-
|
|
526
|
-
// run
|
|
527
|
-
headV1Role(null, _roleyrn, _port, _cuk);
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
});
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
}else{
|
|
535
|
-
console.log('method must be GET or HEAD : ' + _method);
|
|
536
|
-
process.exit(0);
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
/*
|
|
541
|
-
* Local variables:
|
|
542
|
-
* tab-width: 4
|
|
543
|
-
* c-basic-offset: 4
|
|
544
|
-
* End:
|
|
545
|
-
* vim600: noexpandtab sw=4 ts=4 fdm=marker
|
|
546
|
-
* vim<600: noexpandtab sw=4 ts=4
|
|
547
|
-
*/
|