Permalink
Browse files

feat(remote cli): Implement basic remote passthrough of credentials

  • Loading branch information...
zakhenry committed Jul 20, 2016
1 parent e94b2f4 commit 15a8095ec63033f0aa4792fb346a0f58a6593485
Showing with 45 additions and 18 deletions.
  1. +17 −17 package.json
  2. +24 −1 src/server/services/remoteCli.service.ts
  3. +4 −0 src/server/services/vantage.d.ts
View
@@ -9,7 +9,7 @@
"test": "u test -s",
"coveralls": "u coveralls",
"build": "u build",
"preparepublish": "cp -r lib/* .",
"preparepublish": "u build && cp -r lib/* .",
"postpublish": "u changelog && u doc build && u deploy docs"
},
"repository": {
@@ -35,6 +35,20 @@
"@angular/router": "3.0.0-beta.2",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.4",
"@types/chalk": "^0.4.28",
"@types/chance": "^0.7.28",
"@types/dotenv": "^2.0.17",
"@types/express": "^4.0.29",
"@types/express-serve-static-core": "^4.0.29",
"@types/hapi": "^13.0.28",
"@types/jasmine": "^2.2.29",
"@types/lodash": "0.0.27",
"@types/moment": "^2.11.28",
"@types/node": "^4.0.29",
"@types/proxyquire": "^1.3.26",
"@types/socket.io": "^1.4.26",
"@types/validator": "^4.5.26",
"@xiphiaz/vantage": "^1.7.1",
"chalk": "^1.1.3",
"chance": "^1.0.3",
"class-validator": "^0.4.0-alpha.3",
@@ -52,21 +66,7 @@
"table": "^3.7.8",
"timestamp": "0.0.1",
"typeorm": "0.0.2-alpha.43",
"vantage": "^1.7.0",
"zone.js": "^0.6.12",
"@types/chalk": "^0.4.28",
"@types/chance": "^0.7.28",
"@types/dotenv": "^2.0.17",
"@types/express": "^4.0.29",
"@types/express-serve-static-core": "^4.0.29",
"@types/hapi": "^13.0.28",
"@types/jasmine": "^2.2.29",
"@types/lodash": "0.0.27",
"@types/moment": "^2.11.28",
"@types/node": "^4.0.29",
"@types/proxyquire": "^1.3.26",
"@types/socket.io": "^1.4.26",
"@types/validator": "^4.5.26"
"zone.js": "^0.6.12"
},
"devDependencies": {
"@ubiquits/toolchain": "^0.2.2",
@@ -75,4 +75,4 @@
"directories": {
"doc": "docs"
}
}
}
@@ -9,7 +9,7 @@ import { Server, RouteConfig } from '../servers/abstract.server';
import * as chalk from 'chalk';
import { Response } from '../controllers/response';
import { PromiseFactory } from '../../common/util/serialPromise';
import * as Vantage from 'vantage';
import * as Vantage from '@xiphiaz/vantage';
import { Service } from '../../common/registry/decorators';
import { AbstractService } from '../../common/services/service';
@@ -103,6 +103,8 @@ export class RemoteCli extends AbstractService {
this.vantage.delimiter('ubiquits-runtime~$');
this.registerAuthenticationStrategy();
let displayBanner = `Welcome to Ubiquits runtime cli. Type 'help' for commands`;
if ((<any>process.stdout).columns > 68) {
displayBanner = `${banner}\n${displayBanner}`;
@@ -164,6 +166,8 @@ export class RemoteCli extends AbstractService {
};
}
this.logger.debug('Auth function', this.vantage._authFn);
this.vantage.listen(port, callback);
this.logger.info(`Vantage server started on ${port}`);
@@ -181,4 +185,23 @@ export class RemoteCli extends AbstractService {
return table(data, config);
}
protected registerAuthenticationStrategy(): void {
this.vantage.auth((vantage: any, options: any) => {
return (args: any, cb: Function) => {
try {
if (args.client && args.client.auth == 'zak:password'){
return cb('Ok', true);
}
return cb("Credentials are incorrect", false);
} catch (e){
this.logger.error('Authentication error', e);
cb(null, false);
}
}
});
this.logger.debug('Registered vantage authentication strategy');
}
}
@@ -40,3 +40,7 @@ declare module 'vantage' {
import alias = require('~vantage/index');
export = alias;
}
declare module '@xiphiaz/vantage' {
import alias = require('~vantage/index');
export = alias;
}

0 comments on commit 15a8095

Please sign in to comment.