-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathclient.js
More file actions
69 lines (65 loc) · 1.64 KB
/
client.js
File metadata and controls
69 lines (65 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const { sso } = require('node-expose-sspi');
const yargs = require('yargs');
const dbg = require('debug');
const debug = dbg('node-expose-sspi:client-runas');
const myArgv = yargs
.usage('$0 [url]', 'Request a url (by default http://localhost:3000)')
.option('url', {
type: 'string',
description: 'Absolute url',
default: 'http://localhost:3000',
})
.option('target', {
alias: 't',
type: 'string',
description: 'Specify the target name (SPN)',
})
.option('ssp', {
alias: 's',
type: 'string',
description: 'Specify the SSP (Kerberos, NTLM, Negotiate)',
})
.option('user', {
alias: 'u',
type: 'string',
description: 'Run as user',
})
.option('password', {
alias: 'p',
type: 'string',
description: 'user password',
})
.option('domain', {
alias: 'd',
type: 'string',
description: 'the windows domain',
default: 'LOCAL',
})
.help()
.alias('h', 'help').argv;
async function main(argv) {
debug('argv: ', argv);
const url = argv.url;
const client = new sso.Client();
try {
if (argv.user !== undefined) {
client.setCredentials(argv.domain, argv.user, argv.password);
}
if (argv.target !== undefined) {
client.setTargetName(argv.target);
}
if (argv.ssp !== undefined) {
client.setSSP(argv.ssp);
}
const response = await client.fetch(url);
debug('response: ', response);
if (response.status >= 400) {
throw new Error('fetch returned response with error ' + response.status);
}
const json = await response.json();
console.log('json: ', json);
} catch (e) {
console.error(e);
}
}
main(myArgv);