Skip to content

Added two init/destroy methods to use key based Exchange authentication #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added examples, tests and readme.
  • Loading branch information
nestor-fedyk-wpp committed Dec 4, 2020
commit 92f601717874b19ff29a2e30b0dc453f5e88ef48
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ This script simply exports a few useful pre-defined parameter sets (that one wou

3) From within this project install the necessary npm dependencies for this module, including [stateful-process-command-proxy](https://github.com/bitsofinfo/stateful-process-command-proxy). You can checkout the latter manually and do a ```npm install stateful-process-command-proxy```

4) Configure ```example.js``` appropriately, in particular the ```initCommands``` for the StatefulProcessCommandProxy; the paths to the items you created via the second step above
4) Configure ```example.js```/```example_key_auth.js```/```examplekey_thumb_auth.js``` appropriately, in particular the ```initCommands``` for the StatefulProcessCommandProxy; the paths to the items you created via the second step above

5) Tweak the group that is fetched at the bottom of ```example.js```
5) Tweak the group that is fetched at the bottom of ```example.js```/```example_key_auth.js```/```examplekey_thumb_auth.js```

7) There is also a unit-test (```test\all.js```) for the command registry in ```o365Utils.js``` which gives an example of usage.
7) There is also a unit-test (```test\all.js```) for the command registry in ```o365Utils.js``` which gives an example of usage for all thre possible Exchange connect variations.

### <a id="history"></a>History

```
v1.1.0 - 2020-12-03
- Added option for key and thumbprint based Exchange authentication

v1.0.0 - 2016-06-08
- Get-DistributionGroupMember - added "-ResultSize Unlimited"

Expand Down
1 change: 0 additions & 1 deletion example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var Promise = require('promise');
var StatefulProcessCommandProxy = require("stateful-process-command-proxy");
var PSCommandService = require('./psCommandService');
var o365Utils = require('./o365Utils');
Expand Down
81 changes: 81 additions & 0 deletions example_key_auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
var StatefulProcessCommandProxy = require("stateful-process-command-proxy");
var PSCommandService = require('./psCommandService');
var o365Utils = require('./o365Utils');




var statefulProcessCommandProxy = new StatefulProcessCommandProxy({
name: "StatefulProcessCommandProxy",
max: 1,
min: 1,
idleTimeoutMS:120000,
log: function(severity,origin,msg) {
console.log(severity.toUpperCase() + " " +origin+" "+ msg);
},

processCommand: 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
processArgs: ['-Command','-'],


processRetainMaxCmdHistory : 20,
processInvalidateOnRegex : {
'any':[],
'stdout':[],
'stderr':[{'regex':'.*error.*'}]
},
processCwd : null,
processEnvMap : null,
processUid : null,
processGid : null,

initCommands: o365Utils.getO365PSKeyInitCommands(
'C:\\pathto\\decryptUtil.ps1',
'C:\\pathto\\encrypted.credentials',
'C:\\pathto\\secret.key',
'C:\\pathto\\certificate',
'certificatePassword',
'00000000-00000000-00000000-00000000',
'your.exhange.domain.name',
10000,30000,60000),


validateFunction: function(processProxy) {
var isValid = processProxy.isValid();
if(!isValid) {
console.log("ProcessProxy.isValid() returns FALSE!");
}
return isValid;
},


preDestroyCommands: o365Utils.getO365PSKeyDestroyCommands(),

processCmdWhitelistRegex: o365Utils.getO365WhitelistedCommands(),

processCmdBlacklistRegex: o365Utils.getO365BlacklistedCommands(),

autoInvalidationConfig: o365Utils.getO365AutoInvalidationConfig(30000)

});

var myLogFunction = function(severity,origin,message) {
console.log(severity.toUpperCase() + ' ' + origin + ' ' + message);
}


/**
* Fetch a group!
*/
var psCommandService = new PSCommandService(statefulProcessCommandProxy,
o365Utils.o365CommandRegistry,
myLogFunction);

psCommandService.execute('getDistributionGroup',{'Identity':"someGroupName"})
.then(function(groupJson) {
console.log(groupJson);
}).catch(function(error) {
console.log(error);
});

setTimeout(function(){statefulProcessCommandProxy.shutdown()},80000);
80 changes: 80 additions & 0 deletions example_key_thumb_auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
var StatefulProcessCommandProxy = require("stateful-process-command-proxy");
var PSCommandService = require('./psCommandService');
var o365Utils = require('./o365Utils');




var statefulProcessCommandProxy = new StatefulProcessCommandProxy({
name: "StatefulProcessCommandProxy",
max: 1,
min: 1,
idleTimeoutMS:120000,
log: function(severity,origin,msg) {
console.log(severity.toUpperCase() + " " +origin+" "+ msg);
},

processCommand: 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',
processArgs: ['-Command','-'],


processRetainMaxCmdHistory : 20,
processInvalidateOnRegex : {
'any':[],
'stdout':[],
'stderr':[{'regex':'.*error.*'}]
},
processCwd : null,
processEnvMap : null,
processUid : null,
processGid : null,

initCommands: o365Utils.getO365PSThumbprintInitCommands(
'C:\\pathto\\decryptUtil.ps1',
'C:\\pathto\\encrypted.credentials',
'C:\\pathto\\secret.key',
'certificatethumbprint',
'00000000-00000000-00000000-00000000',
'your.exhange.domain.name',
10000,30000,60000),


validateFunction: function(processProxy) {
var isValid = processProxy.isValid();
if(!isValid) {
console.log("ProcessProxy.isValid() returns FALSE!");
}
return isValid;
},


preDestroyCommands: o365Utils.getO365PSThumbprintDestroyCommands(),

processCmdWhitelistRegex: o365Utils.getO365WhitelistedCommands(),

processCmdBlacklistRegex: o365Utils.getO365BlacklistedCommands(),

autoInvalidationConfig: o365Utils.getO365AutoInvalidationConfig(30000)

});

var myLogFunction = function(severity,origin,message) {
console.log(severity.toUpperCase() + ' ' + origin + ' ' + message);
}


/**
* Fetch a group!
*/
var psCommandService = new PSCommandService(statefulProcessCommandProxy,
o365Utils.o365CommandRegistry,
myLogFunction);

psCommandService.execute('getDistributionGroup',{'Identity':"someGroupName"})
.then(function(groupJson) {
console.log(groupJson);
}).catch(function(error) {
console.log(error);
});

setTimeout(function(){statefulProcessCommandProxy.shutdown()},80000);
Loading