joyent/node-triton#120 triton -r,--role ROLE ...
to be able to take up an RBAC role
This commit is contained in:
parent
9b099a91e9
commit
ad20360306
@ -5,9 +5,9 @@ Known issues:
|
|||||||
- `triton ssh ...` disables ssh ControlMaster to avoid issue #52.
|
- `triton ssh ...` disables ssh ControlMaster to avoid issue #52.
|
||||||
|
|
||||||
|
|
||||||
## 4.11.1 (not yet released)
|
## 4.12.0 (not yet released)
|
||||||
|
|
||||||
(nothing yet)
|
- [#120] `triton -r,--role ROLE ...` option to take up an RBAC role(s).
|
||||||
|
|
||||||
|
|
||||||
## 4.11.0
|
## 4.11.0
|
||||||
|
16
lib/cli.js
16
lib/cli.js
@ -115,14 +115,13 @@ var OPTIONS = [
|
|||||||
'or SDC_USER=USER.',
|
'or SDC_USER=USER.',
|
||||||
helpArg: 'USER'
|
helpArg: 'USER'
|
||||||
},
|
},
|
||||||
// TODO: full rbac support
|
{
|
||||||
//{
|
names: ['role', 'r'],
|
||||||
// names: ['role'],
|
type: 'arrayOfCommaSepString',
|
||||||
// type: 'arrayOfString',
|
env: 'MANTA_ROLE',
|
||||||
// env: 'MANTA_ROLE',
|
help: 'Assume an RBAC role. Use multiple times or once with a list',
|
||||||
// help: 'Assume a role. Use multiple times or once with a list',
|
helpArg: 'ROLE,ROLE,...'
|
||||||
// helpArg: 'ROLE,ROLE,...'
|
},
|
||||||
//},
|
|
||||||
{
|
{
|
||||||
names: ['keyId', 'k'],
|
names: ['keyId', 'k'],
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -562,6 +561,7 @@ CLI.prototype._applyProfileOverrides =
|
|||||||
[
|
[
|
||||||
{oname: 'account', pname: 'account'},
|
{oname: 'account', pname: 'account'},
|
||||||
{oname: 'user', pname: 'user'},
|
{oname: 'user', pname: 'user'},
|
||||||
|
{oname: 'role', pname: 'roles'},
|
||||||
{oname: 'url', pname: 'url'},
|
{oname: 'url', pname: 'url'},
|
||||||
{oname: 'keyId', pname: 'keyId'},
|
{oname: 'keyId', pname: 'keyId'},
|
||||||
{oname: 'insecure', pname: 'insecure'},
|
{oname: 'insecure', pname: 'insecure'},
|
||||||
|
@ -67,6 +67,7 @@ var OS_PLATFORM = os.platform();
|
|||||||
* - {String} account (required) The account login name.
|
* - {String} account (required) The account login name.
|
||||||
* - {Function} sign (required) An http-signature auth signing function
|
* - {Function} sign (required) An http-signature auth signing function
|
||||||
* - {String} user (optional) The RBAC user login name.
|
* - {String} user (optional) The RBAC user login name.
|
||||||
|
* - {Array of String} roles (optional) RBAC role(s) to take up.
|
||||||
* - {String} version (optional) Used for the accept-version header. This
|
* - {String} version (optional) Used for the accept-version header. This
|
||||||
* defaults to '*', meaning that over time you could experience breaking
|
* defaults to '*', meaning that over time you could experience breaking
|
||||||
* changes. Specifying a value is strongly recommended. E.g. '~7.1'.
|
* changes. Specifying a value is strongly recommended. E.g. '~7.1'.
|
||||||
@ -91,12 +92,14 @@ function CloudApi(options) {
|
|||||||
assert.string(options.account, 'options.account');
|
assert.string(options.account, 'options.account');
|
||||||
assert.func(options.sign, 'options.sign');
|
assert.func(options.sign, 'options.sign');
|
||||||
assert.optionalString(options.user, 'options.user');
|
assert.optionalString(options.user, 'options.user');
|
||||||
|
assert.optionalArrayOfString(options.roles, 'options.roles');
|
||||||
assert.optionalString(options.version, 'options.version');
|
assert.optionalString(options.version, 'options.version');
|
||||||
assert.optionalObject(options.log, 'options.log');
|
assert.optionalObject(options.log, 'options.log');
|
||||||
|
|
||||||
this.url = options.url;
|
this.url = options.url;
|
||||||
this.account = options.account;
|
this.account = options.account;
|
||||||
this.user = options.user; // optional RBAC subuser
|
this.user = options.user; // optional RBAC subuser
|
||||||
|
this.roles = options.roles;
|
||||||
this.sign = options.sign;
|
this.sign = options.sign;
|
||||||
this.log = options.log || new bunyannoop.BunyanNoopLogger();
|
this.log = options.log || new bunyannoop.BunyanNoopLogger();
|
||||||
if (!options.version) {
|
if (!options.version) {
|
||||||
@ -228,6 +231,14 @@ CloudApi.prototype._request = function _request(opts, cb) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.roles && self.roles.length > 0) {
|
||||||
|
if (opts.path.indexOf('?') !== -1) {
|
||||||
|
opts.path += '&as-role=' + self.roles.join(',');
|
||||||
|
} else {
|
||||||
|
opts.path += '?as-role=' + self.roles.join(',');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self._getAuthHeaders(function (err, headers) {
|
self._getAuthHeaders(function (err, headers) {
|
||||||
if (err) {
|
if (err) {
|
||||||
cb(err);
|
cb(err);
|
||||||
|
@ -177,6 +177,7 @@ TritonApi.prototype._cloudapiFromProfile =
|
|||||||
assert.string(profile.keyId, 'profile.keyId');
|
assert.string(profile.keyId, 'profile.keyId');
|
||||||
assert.string(profile.url, 'profile.url');
|
assert.string(profile.url, 'profile.url');
|
||||||
assert.optionalString(profile.user, 'profile.user');
|
assert.optionalString(profile.user, 'profile.user');
|
||||||
|
assert.optionalArrayOfString(profile.roles, 'profile.roles');
|
||||||
assert.optionalString(profile.privKey, 'profile.privKey');
|
assert.optionalString(profile.privKey, 'profile.privKey');
|
||||||
assert.optionalBool(profile.insecure, 'profile.insecure');
|
assert.optionalBool(profile.insecure, 'profile.insecure');
|
||||||
assert.optionalString(profile.acceptVersion, 'profile.acceptVersion');
|
assert.optionalString(profile.acceptVersion, 'profile.acceptVersion');
|
||||||
@ -204,6 +205,7 @@ TritonApi.prototype._cloudapiFromProfile =
|
|||||||
url: profile.url,
|
url: profile.url,
|
||||||
account: profile.actAsAccount || profile.account,
|
account: profile.actAsAccount || profile.account,
|
||||||
user: profile.user,
|
user: profile.user,
|
||||||
|
roles: profile.roles,
|
||||||
version: acceptVersion,
|
version: acceptVersion,
|
||||||
rejectUnauthorized: rejectUnauthorized,
|
rejectUnauthorized: rejectUnauthorized,
|
||||||
sign: sign,
|
sign: sign,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "triton",
|
"name": "triton",
|
||||||
"description": "Joyent Triton CLI and client (https://www.joyent.com/triton)",
|
"description": "Joyent Triton CLI and client (https://www.joyent.com/triton)",
|
||||||
"version": "4.11.1",
|
"version": "4.12.0",
|
||||||
"author": "Joyent (joyent.com)",
|
"author": "Joyent (joyent.com)",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"assert-plus": "0.2.0",
|
"assert-plus": "0.2.0",
|
||||||
|
Reference in New Issue
Block a user