Skip to content

Commit

Permalink
Add support for skipping authentication
Browse files Browse the repository at this point in the history
By setting `authMethods` to an empty array.

Useful for peer-to-peer DBus when authentication is handled elsewhere.
  • Loading branch information
oleavr committed Oct 14, 2021
1 parent c706b93 commit 097917c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/handshake.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ function hexlify (input) {

module.exports = function auth (stream, opts, cb) {
// filter used to make a copy so we don't accidently change opts data
let authMethods;
if (opts.authMethods) {
authMethods = opts.authMethods;
} else {
let authMethods = opts.authMethods;
if (opts.authMethods === undefined) {
authMethods = constants.defaultAuthMethods;
}
const skipAuthentication = authMethods.length === 0;
if (skipAuthentication) {
stream.once('readable', () => { cb(null, null); });
return;
}
stream.write('\0');
tryAuth(stream, authMethods.slice(), cb);
};
Expand Down

0 comments on commit 097917c

Please sign in to comment.