win-sso 1.1.4 → 1.1.5
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/package.json +12 -14
- package/src/win-sso.ts +57 -31
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -7
- package/dist/os-supported.d.ts +0 -5
- package/dist/os-supported.js +0 -15
- package/dist/utils/debug.logger.d.ts +0 -2
- package/dist/utils/debug.logger.js +0 -5
- package/dist/win-sso.d.ts +0 -58
- package/dist/win-sso.js +0 -147
- package/prebuilds/win32-ia32/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "win-sso",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "NTLM single-sign-on for Node.js. Only Windows OS supported.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -39,24 +39,22 @@
|
|
|
39
39
|
"bindings": "*",
|
|
40
40
|
"cross-spawn": "^7.0.3",
|
|
41
41
|
"debug": "^4.3.1",
|
|
42
|
-
"node-addon-api": "^3.
|
|
43
|
-
"node-gyp": "^8.
|
|
44
|
-
"node-gyp-build": "
|
|
42
|
+
"node-addon-api": "^4.3.0",
|
|
43
|
+
"node-gyp": "^8.4.1",
|
|
44
|
+
"node-gyp-build": "4.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/
|
|
48
|
-
"@types/
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/node": "^15.0.2",
|
|
47
|
+
"@types/debug": "^4.1.7",
|
|
48
|
+
"@types/mocha": "^9.1.0",
|
|
49
|
+
"@types/node": "^16.11.22",
|
|
51
50
|
"asn1-parser": "^1.1.8",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"ts-node": "^9.1.1",
|
|
51
|
+
"mocha": "^9.2.0",
|
|
52
|
+
"prebuildify": "^5.0.0",
|
|
53
|
+
"shx": "^0.3.4",
|
|
54
|
+
"ts-node": "^10.5.0",
|
|
57
55
|
"tslint": "^6.1.3",
|
|
58
56
|
"tslint-eslint-rules": "^5.4.0",
|
|
59
|
-
"typescript": "
|
|
57
|
+
"typescript": "4.5",
|
|
60
58
|
"vrsource-tslint-rules": "^6.0.0"
|
|
61
59
|
},
|
|
62
60
|
"gypfile": true
|
package/src/win-sso.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { debug } from
|
|
2
|
-
import { PeerCertificate } from
|
|
3
|
-
import path from
|
|
1
|
+
import { debug } from "./utils/debug.logger";
|
|
2
|
+
import { PeerCertificate } from "tls";
|
|
3
|
+
import path from "path";
|
|
4
4
|
|
|
5
5
|
let winSsoAddon: any;
|
|
6
6
|
try {
|
|
7
|
-
winSsoAddon = require(
|
|
8
|
-
debug(
|
|
7
|
+
winSsoAddon = require("node-gyp-build")(path.join(__dirname, ".."));
|
|
8
|
+
debug("Loaded win-sso native module");
|
|
9
9
|
} catch (err) {
|
|
10
|
-
debug(
|
|
10
|
+
debug("Could not load win-sso native module");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Creates authentication tokens for NTLM or Negotiate handshake using the executing users credentials.
|
|
15
15
|
*/
|
|
16
16
|
export class WinSso {
|
|
17
|
-
private static NEGOTIATE_NTLM2_KEY = 1<<19;
|
|
17
|
+
private static NEGOTIATE_NTLM2_KEY = 1 << 19;
|
|
18
18
|
|
|
19
19
|
private authContextId: number;
|
|
20
20
|
private securityPackage: string;
|
|
@@ -27,18 +27,26 @@ export class WinSso {
|
|
|
27
27
|
* @param targetHost {string | undefind} The FQDN hostname of the target (optional)
|
|
28
28
|
* @param peerCert {PeerCertificate | undefined} The certificate of the target server (optional, for HTTPS channel binding)
|
|
29
29
|
*/
|
|
30
|
-
constructor(
|
|
30
|
+
constructor(
|
|
31
|
+
securityPackage: string,
|
|
32
|
+
targetHost: string | undefined,
|
|
33
|
+
peerCert: PeerCertificate | undefined
|
|
34
|
+
) {
|
|
31
35
|
this.securityPackage = securityPackage;
|
|
32
36
|
let applicationData: Buffer;
|
|
33
37
|
if (!targetHost) {
|
|
34
|
-
targetHost =
|
|
38
|
+
targetHost = "";
|
|
35
39
|
}
|
|
36
40
|
if (peerCert) {
|
|
37
41
|
applicationData = this.getChannelBindingsApplicationData(peerCert);
|
|
38
42
|
} else {
|
|
39
43
|
applicationData = Buffer.alloc(0);
|
|
40
44
|
}
|
|
41
|
-
this.authContextId = winSsoAddon.createAuthContext(
|
|
45
|
+
this.authContextId = winSsoAddon.createAuthContext(
|
|
46
|
+
securityPackage,
|
|
47
|
+
targetHost,
|
|
48
|
+
applicationData
|
|
49
|
+
);
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
/**
|
|
@@ -55,10 +63,12 @@ export class WinSso {
|
|
|
55
63
|
*/
|
|
56
64
|
private getChannelBindingsApplicationData(peerCert: PeerCertificate): Buffer {
|
|
57
65
|
let cert: any = peerCert;
|
|
58
|
-
let hash = cert.fingerprint256.replace(/:/g,
|
|
59
|
-
let hashBuf = Buffer.from(hash,
|
|
60
|
-
let tlsServerEndPoint =
|
|
61
|
-
let applicationDataBuffer = Buffer.alloc(
|
|
66
|
+
let hash = cert.fingerprint256.replace(/:/g, "");
|
|
67
|
+
let hashBuf = Buffer.from(hash, "hex");
|
|
68
|
+
let tlsServerEndPoint = "tls-server-end-point:";
|
|
69
|
+
let applicationDataBuffer = Buffer.alloc(
|
|
70
|
+
tlsServerEndPoint.length + hashBuf.length
|
|
71
|
+
);
|
|
62
72
|
applicationDataBuffer.write(tlsServerEndPoint, 0, "ascii");
|
|
63
73
|
hashBuf.copy(applicationDataBuffer, tlsServerEndPoint.length);
|
|
64
74
|
return applicationDataBuffer;
|
|
@@ -73,14 +83,16 @@ export class WinSso {
|
|
|
73
83
|
winSsoAddon.freeAuthContext(this.authContextId);
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
|
|
77
86
|
/**
|
|
78
87
|
* Creates an authentication request token
|
|
79
88
|
* @returns {Buffer} Raw token buffer
|
|
80
89
|
*/
|
|
81
90
|
createAuthRequest(): Buffer {
|
|
82
91
|
let token = winSsoAddon.createAuthRequest(this.authContextId);
|
|
83
|
-
debug(
|
|
92
|
+
debug(
|
|
93
|
+
"Created " + this.securityPackage + " authentication request token",
|
|
94
|
+
token.toString("base64")
|
|
95
|
+
);
|
|
84
96
|
return token;
|
|
85
97
|
}
|
|
86
98
|
|
|
@@ -89,7 +101,8 @@ export class WinSso {
|
|
|
89
101
|
* @returns {string} The www-authenticate header
|
|
90
102
|
*/
|
|
91
103
|
createAuthRequestHeader(): string {
|
|
92
|
-
let header =
|
|
104
|
+
let header =
|
|
105
|
+
this.securityPackage + " " + this.createAuthRequest().toString("base64");
|
|
93
106
|
return header;
|
|
94
107
|
}
|
|
95
108
|
|
|
@@ -99,30 +112,43 @@ export class WinSso {
|
|
|
99
112
|
* @returns {Buffer} Raw token buffer. May be empty if Negotiate handshake is complete.
|
|
100
113
|
*/
|
|
101
114
|
createAuthResponse(inTokenHeader: string): Buffer {
|
|
102
|
-
debug(
|
|
103
|
-
let packageMatch = new RegExp(
|
|
115
|
+
debug("Received www-authentication response", inTokenHeader);
|
|
116
|
+
let packageMatch = new RegExp(
|
|
117
|
+
"^" + this.securityPackage + "\\s([^,\\s]+)"
|
|
118
|
+
).exec(inTokenHeader);
|
|
104
119
|
|
|
105
|
-
|
|
120
|
+
if (!packageMatch) {
|
|
106
121
|
throw new Error(
|
|
107
|
-
|
|
122
|
+
"Invalid input token, missing " +
|
|
123
|
+
this.securityPackage +
|
|
124
|
+
" prefix: " +
|
|
125
|
+
inTokenHeader
|
|
108
126
|
);
|
|
109
127
|
}
|
|
110
|
-
let inToken = Buffer.from(packageMatch[1],
|
|
128
|
+
let inToken = Buffer.from(packageMatch[1], "base64");
|
|
111
129
|
try {
|
|
112
130
|
let token = winSsoAddon.createAuthResponse(this.authContextId, inToken);
|
|
113
131
|
if (token.length > 0) {
|
|
114
|
-
debug(
|
|
132
|
+
debug(
|
|
133
|
+
"Created " + this.securityPackage + " authentication response token",
|
|
134
|
+
token.toString("base64")
|
|
135
|
+
);
|
|
115
136
|
} else {
|
|
116
|
-
debug(
|
|
137
|
+
debug("No response token, authentication complete");
|
|
117
138
|
}
|
|
118
139
|
return token;
|
|
119
140
|
} catch (err) {
|
|
120
|
-
if (
|
|
141
|
+
if (
|
|
142
|
+
(err as Error).message ===
|
|
143
|
+
"Could not init security context. Result: -2146893054"
|
|
144
|
+
) {
|
|
121
145
|
// If incoming token is for NTLMv1, this error can occur when LMCompatibilityLevel prevents the client to send NTLMv1 messages
|
|
122
|
-
if (this.securityPackage ===
|
|
123
|
-
throw new Error(
|
|
124
|
-
|
|
125
|
-
|
|
146
|
+
if (this.securityPackage === "NTLM" && this.IsNtlmV1(inToken)) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
"Could not create NTLM type 3 message. Incoming type 2 message uses NTLMv1, " +
|
|
149
|
+
"it is likely that the client is prevented from sending such messages. " +
|
|
150
|
+
"Update target host to use NTLMv2 (recommended) or adjust LMCompatibilityLevel on the client (insecure)"
|
|
151
|
+
);
|
|
126
152
|
}
|
|
127
153
|
}
|
|
128
154
|
throw err;
|
|
@@ -147,9 +173,9 @@ export class WinSso {
|
|
|
147
173
|
createAuthResponseHeader(inTokenHeader: string): string {
|
|
148
174
|
const tokenBuffer = this.createAuthResponse(inTokenHeader);
|
|
149
175
|
if (tokenBuffer.length == 0) {
|
|
150
|
-
return
|
|
176
|
+
return "";
|
|
151
177
|
}
|
|
152
|
-
let header = this.securityPackage +
|
|
178
|
+
let header = this.securityPackage + " " + tokenBuffer.toString("base64");
|
|
153
179
|
return header;
|
|
154
180
|
}
|
|
155
181
|
}
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.osSupported = exports.WinSso = void 0;
|
|
4
|
-
const win_sso_1 = require("./win-sso");
|
|
5
|
-
Object.defineProperty(exports, "WinSso", { enumerable: true, get: function () { return win_sso_1.WinSso; } });
|
|
6
|
-
const os_supported_1 = require("./os-supported");
|
|
7
|
-
Object.defineProperty(exports, "osSupported", { enumerable: true, get: function () { return os_supported_1.osSupported; } });
|
package/dist/os-supported.d.ts
DELETED
package/dist/os-supported.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.osSupported = void 0;
|
|
7
|
-
const os_1 = __importDefault(require("os"));
|
|
8
|
-
/**
|
|
9
|
-
* Returns true if the current platform is supported by the win-sso module. Only Windows OSs are supported.
|
|
10
|
-
* If false, all other methods in the module will throw.
|
|
11
|
-
*/
|
|
12
|
-
function osSupported() {
|
|
13
|
-
return (os_1.default.platform() === 'win32');
|
|
14
|
-
}
|
|
15
|
-
exports.osSupported = osSupported;
|
package/dist/win-sso.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { PeerCertificate } from 'tls';
|
|
3
|
-
/**
|
|
4
|
-
* Creates authentication tokens for NTLM or Negotiate handshake using the executing users credentials.
|
|
5
|
-
*/
|
|
6
|
-
export declare class WinSso {
|
|
7
|
-
private static NEGOTIATE_NTLM2_KEY;
|
|
8
|
-
private authContextId;
|
|
9
|
-
private securityPackage;
|
|
10
|
-
/**
|
|
11
|
-
* Creates an authentication context for SSO.
|
|
12
|
-
* This allocates memory buffers, the freeAuthContext method should be called
|
|
13
|
-
* to free them (on error or after authentication is no longer needed)
|
|
14
|
-
* @param securityPackage {string} The name of the security package (NTLM or Negotiate)
|
|
15
|
-
* @param targetHost {string | undefind} The FQDN hostname of the target (optional)
|
|
16
|
-
* @param peerCert {PeerCertificate | undefined} The certificate of the target server (optional, for HTTPS channel binding)
|
|
17
|
-
*/
|
|
18
|
-
constructor(securityPackage: string, targetHost: string | undefined, peerCert: PeerCertificate | undefined);
|
|
19
|
-
/**
|
|
20
|
-
* Retrieves the username of the logged in user
|
|
21
|
-
* @returns {string} user name including domain
|
|
22
|
-
*/
|
|
23
|
-
static getLogonUserName(): string;
|
|
24
|
-
/**
|
|
25
|
-
* Transforms target TLS certificate into a channel binding application data buffer
|
|
26
|
-
* @param peerCert {PeerCertificate} Target TLS certificate
|
|
27
|
-
*/
|
|
28
|
-
private getChannelBindingsApplicationData;
|
|
29
|
-
/**
|
|
30
|
-
* Releases all allocated resources for the authorization context.
|
|
31
|
-
* Should be called when the context is no longer required, such as when the
|
|
32
|
-
* socket was closed.
|
|
33
|
-
*/
|
|
34
|
-
freeAuthContext(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Creates an authentication request token
|
|
37
|
-
* @returns {Buffer} Raw token buffer
|
|
38
|
-
*/
|
|
39
|
-
createAuthRequest(): Buffer;
|
|
40
|
-
/**
|
|
41
|
-
* Creates an authentication request header
|
|
42
|
-
* @returns {string} The www-authenticate header
|
|
43
|
-
*/
|
|
44
|
-
createAuthRequestHeader(): string;
|
|
45
|
-
/**
|
|
46
|
-
* Creates an authentication response token
|
|
47
|
-
* @param inTokenHeader {string} The www-authentication header received from the target in reponse to the authentication request
|
|
48
|
-
* @returns {Buffer} Raw token buffer. May be empty if Negotiate handshake is complete.
|
|
49
|
-
*/
|
|
50
|
-
createAuthResponse(inTokenHeader: string): Buffer;
|
|
51
|
-
private IsNtlmV1;
|
|
52
|
-
/**
|
|
53
|
-
* Creates an authentication response header
|
|
54
|
-
* @param inTokenHeader {string} The www-authentication header received from the target in reponse to the authentication request
|
|
55
|
-
* @returns {string} The www-authenticate header. May be an empty string if Negotiate handshake is complete.
|
|
56
|
-
*/
|
|
57
|
-
createAuthResponseHeader(inTokenHeader: string): string;
|
|
58
|
-
}
|
package/dist/win-sso.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WinSso = void 0;
|
|
7
|
-
const debug_logger_1 = require("./utils/debug.logger");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
let winSsoAddon;
|
|
10
|
-
try {
|
|
11
|
-
winSsoAddon = require('node-gyp-build')(path_1.default.join(__dirname, '..'));
|
|
12
|
-
debug_logger_1.debug('Loaded win-sso native module');
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
debug_logger_1.debug('Could not load win-sso native module');
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Creates authentication tokens for NTLM or Negotiate handshake using the executing users credentials.
|
|
19
|
-
*/
|
|
20
|
-
class WinSso {
|
|
21
|
-
/**
|
|
22
|
-
* Creates an authentication context for SSO.
|
|
23
|
-
* This allocates memory buffers, the freeAuthContext method should be called
|
|
24
|
-
* to free them (on error or after authentication is no longer needed)
|
|
25
|
-
* @param securityPackage {string} The name of the security package (NTLM or Negotiate)
|
|
26
|
-
* @param targetHost {string | undefind} The FQDN hostname of the target (optional)
|
|
27
|
-
* @param peerCert {PeerCertificate | undefined} The certificate of the target server (optional, for HTTPS channel binding)
|
|
28
|
-
*/
|
|
29
|
-
constructor(securityPackage, targetHost, peerCert) {
|
|
30
|
-
this.securityPackage = securityPackage;
|
|
31
|
-
let applicationData;
|
|
32
|
-
if (!targetHost) {
|
|
33
|
-
targetHost = '';
|
|
34
|
-
}
|
|
35
|
-
if (peerCert) {
|
|
36
|
-
applicationData = this.getChannelBindingsApplicationData(peerCert);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
applicationData = Buffer.alloc(0);
|
|
40
|
-
}
|
|
41
|
-
this.authContextId = winSsoAddon.createAuthContext(securityPackage, targetHost, applicationData);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Retrieves the username of the logged in user
|
|
45
|
-
* @returns {string} user name including domain
|
|
46
|
-
*/
|
|
47
|
-
static getLogonUserName() {
|
|
48
|
-
return winSsoAddon.getLogonUserName();
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Transforms target TLS certificate into a channel binding application data buffer
|
|
52
|
-
* @param peerCert {PeerCertificate} Target TLS certificate
|
|
53
|
-
*/
|
|
54
|
-
getChannelBindingsApplicationData(peerCert) {
|
|
55
|
-
let cert = peerCert;
|
|
56
|
-
let hash = cert.fingerprint256.replace(/:/g, '');
|
|
57
|
-
let hashBuf = Buffer.from(hash, 'hex');
|
|
58
|
-
let tlsServerEndPoint = 'tls-server-end-point:';
|
|
59
|
-
let applicationDataBuffer = Buffer.alloc(tlsServerEndPoint.length + hashBuf.length);
|
|
60
|
-
applicationDataBuffer.write(tlsServerEndPoint, 0, "ascii");
|
|
61
|
-
hashBuf.copy(applicationDataBuffer, tlsServerEndPoint.length);
|
|
62
|
-
return applicationDataBuffer;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Releases all allocated resources for the authorization context.
|
|
66
|
-
* Should be called when the context is no longer required, such as when the
|
|
67
|
-
* socket was closed.
|
|
68
|
-
*/
|
|
69
|
-
freeAuthContext() {
|
|
70
|
-
winSsoAddon.freeAuthContext(this.authContextId);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Creates an authentication request token
|
|
74
|
-
* @returns {Buffer} Raw token buffer
|
|
75
|
-
*/
|
|
76
|
-
createAuthRequest() {
|
|
77
|
-
let token = winSsoAddon.createAuthRequest(this.authContextId);
|
|
78
|
-
debug_logger_1.debug('Created ' + this.securityPackage + ' authentication request token', token.toString('base64'));
|
|
79
|
-
return token;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Creates an authentication request header
|
|
83
|
-
* @returns {string} The www-authenticate header
|
|
84
|
-
*/
|
|
85
|
-
createAuthRequestHeader() {
|
|
86
|
-
let header = this.securityPackage + ' ' + this.createAuthRequest().toString('base64');
|
|
87
|
-
return header;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Creates an authentication response token
|
|
91
|
-
* @param inTokenHeader {string} The www-authentication header received from the target in reponse to the authentication request
|
|
92
|
-
* @returns {Buffer} Raw token buffer. May be empty if Negotiate handshake is complete.
|
|
93
|
-
*/
|
|
94
|
-
createAuthResponse(inTokenHeader) {
|
|
95
|
-
debug_logger_1.debug('Received www-authentication response', inTokenHeader);
|
|
96
|
-
let packageMatch = new RegExp('^' + this.securityPackage + '\\s([^,\\s]+)').exec(inTokenHeader);
|
|
97
|
-
if (!packageMatch) {
|
|
98
|
-
throw new Error('Invalid input token, missing ' + this.securityPackage + ' prefix: ' + inTokenHeader);
|
|
99
|
-
}
|
|
100
|
-
let inToken = Buffer.from(packageMatch[1], 'base64');
|
|
101
|
-
try {
|
|
102
|
-
let token = winSsoAddon.createAuthResponse(this.authContextId, inToken);
|
|
103
|
-
if (token.length > 0) {
|
|
104
|
-
debug_logger_1.debug('Created ' + this.securityPackage + ' authentication response token', token.toString('base64'));
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
debug_logger_1.debug('No response token, authentication complete');
|
|
108
|
-
}
|
|
109
|
-
return token;
|
|
110
|
-
}
|
|
111
|
-
catch (err) {
|
|
112
|
-
if (err.message === 'Could not init security context. Result: -2146893054') {
|
|
113
|
-
// If incoming token is for NTLMv1, this error can occur when LMCompatibilityLevel prevents the client to send NTLMv1 messages
|
|
114
|
-
if (this.securityPackage === 'NTLM' && this.IsNtlmV1(inToken)) {
|
|
115
|
-
throw new Error('Could not create NTLM type 3 message. Incoming type 2 message uses NTLMv1, ' +
|
|
116
|
-
'it is likely that the client is prevented from sending such messages. ' +
|
|
117
|
-
'Update target host to use NTLMv2 (recommended) or adjust LMCompatibilityLevel on the client (insecure)');
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
throw err;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
IsNtlmV1(type2message) {
|
|
124
|
-
if (type2message.length >= 24) {
|
|
125
|
-
const inTokenFlags = type2message.readInt32BE(20);
|
|
126
|
-
if ((inTokenFlags & WinSso.NEGOTIATE_NTLM2_KEY) === 0) {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Creates an authentication response header
|
|
134
|
-
* @param inTokenHeader {string} The www-authentication header received from the target in reponse to the authentication request
|
|
135
|
-
* @returns {string} The www-authenticate header. May be an empty string if Negotiate handshake is complete.
|
|
136
|
-
*/
|
|
137
|
-
createAuthResponseHeader(inTokenHeader) {
|
|
138
|
-
const tokenBuffer = this.createAuthResponse(inTokenHeader);
|
|
139
|
-
if (tokenBuffer.length == 0) {
|
|
140
|
-
return '';
|
|
141
|
-
}
|
|
142
|
-
let header = this.securityPackage + ' ' + tokenBuffer.toString('base64');
|
|
143
|
-
return header;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
exports.WinSso = WinSso;
|
|
147
|
-
WinSso.NEGOTIATE_NTLM2_KEY = 1 << 19;
|
|
Binary file
|
|
Binary file
|