Class: Autumn::Authentication::Nick

Inherits:
Base
  • Object
show all
Defined in:
lib/autumn/authentication.rb

Overview

Authenticates by IRC nick. A list of allowed nicks is built on initialization, and anyone with that nick is allowed to use restricted commands.

This is the most obvious approach to authentication, but it is hardly secure. Anyone can change their nick to an admin’s nick once that admin logs out.

Instance Method Summary collapse

Methods inherited from Base

#unauthorized

Constructor Details

#initialize(options = {}) ⇒ Nick

Creates a new authenticator. Pass a single nick for the nick option or an array of allowed nicks for the nicks option. If neither option is set, an exception is raised.



104
105
106
107
108
109
# File 'lib/autumn/authentication.rb', line 104

def initialize(options={})
  @nicks = options[:nick]
  @nicks ||= options[:nicks]
  raise "You must give the nick of an administrator to use nick-based authentication." if @nicks.nil?
  @nicks = [ @nicks ] if @nicks.kind_of? String
end

Instance Method Details

#authenticate(stem, channel, sender, leaf) ⇒ Object

:nodoc:



111
112
113
# File 'lib/autumn/authentication.rb', line 111

def authenticate(stem, channel, sender, leaf) # :nodoc:
  @nicks.include? sender[:nick]
end