forked from martynsmith/node-irc
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add SASL EXTERNAL authentication and example #48
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env node | ||
|
||
var irc = require('../'); | ||
var fs = require('fs'); | ||
|
||
// example of authenticating through external sasl on freenode | ||
// set up your cert as instructed here https://freenode.net/kb/answer/certfp | ||
// change these to your cert | ||
var options = { | ||
key: fs.readFileSync('/path/to/.weechat/certs/freenode.pem'), | ||
cert: fs.readFileSync('/path/to/.weechat/certs/freenode.pem') | ||
}; | ||
|
||
var bot = new irc.Client('chat.freenode.net', 'nodebot', { | ||
port: 6697, | ||
sasl: true, | ||
saslType: 'EXTERNAL', | ||
debug: true, | ||
secure: options, | ||
channels: ['#botwar'] | ||
}); | ||
|
||
bot.addListener('error', function(message) { | ||
console.error('ERROR: %s: %s', message.command, message.args.join(' ')); | ||
}); | ||
|
||
bot.addListener('message#blah', function(from, message) { | ||
console.log('<%s> %s', from, message); | ||
}); | ||
|
||
bot.addListener('message', function(from, to, message) { | ||
console.log('%s => %s: %s', from, to, message); | ||
|
||
if (to.match(/^[#&]/)) { | ||
// channel message | ||
if (message.match(/hello/i)) { | ||
bot.say(to, 'Hello there ' + from); | ||
} | ||
if (message.match(/dance/)) { | ||
setTimeout(function() { bot.say(to, '\u0001ACTION dances: :D\\-<\u0001'); }, 1000); | ||
setTimeout(function() { bot.say(to, '\u0001ACTION dances: :D|-<\u0001'); }, 2000); | ||
setTimeout(function() { bot.say(to, '\u0001ACTION dances: :D/-<\u0001'); }, 3000); | ||
setTimeout(function() { bot.say(to, '\u0001ACTION dances: :D|-<\u0001'); }, 4000); | ||
} | ||
} | ||
else { | ||
// private message | ||
console.log('private message'); | ||
} | ||
}); | ||
bot.addListener('pm', function(nick, message) { | ||
console.log('Got private message from %s: %s', nick, message); | ||
}); | ||
bot.addListener('join', function(channel, who) { | ||
console.log('%s has joined %s', who, channel); | ||
}); | ||
bot.addListener('part', function(channel, who, reason) { | ||
console.log('%s has left %s: %s', who, channel, reason); | ||
}); | ||
bot.addListener('kick', function(channel, who, by, reason) { | ||
console.log('%s was kicked from %s by %s: %s', who, channel, by, reason); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear, this is just the client saying that it doesn't need to provide a set of authentication credentials because the cert provided does that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep that should be it. the rfc says
The mechanism is capable of transferring an authorization identity string. If empty, the client is requesting to act as the identity the server has associated with the client's credentials.
I implemented this looking at how weechat and other clients do it.