Skip to content

Commit 481cbff

Browse files
committed
Add support for skipping authentication
By setting `authMethods` to an empty array. Useful for peer-to-peer DBus when authentication is handled elsewhere.
1 parent c706b93 commit 481cbff

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/handshake.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ function hexlify (input) {
5858

5959
module.exports = function auth (stream, opts, cb) {
6060
// filter used to make a copy so we don't accidently change opts data
61-
let authMethods;
62-
if (opts.authMethods) {
63-
authMethods = opts.authMethods;
64-
} else {
61+
let authMethods = opts.authMethods;
62+
if (opts.authMethods === undefined) {
6563
authMethods = constants.defaultAuthMethods;
6664
}
65+
const skipAuthentication = authMethods.length === 0;
66+
if (skipAuthentication) {
67+
return process.nextTick(() => { cb(null, null); });
68+
}
6769
stream.write('\0');
6870
tryAuth(stream, authMethods.slice(), cb);
6971
};

0 commit comments

Comments
 (0)