Class: Autumn::Authentication::Op

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

Overview

Authenticates users by their privilege level in the channel they ran the command in.

This is a quick, configuration-free way of protecting your leaf, so long as you trust the ops in your channel.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Op

Creates a new authenticator. Pass a list of allowed privileges (as symbols) for the privileges option. By default this class accepts ops, admins, and channel owners/founders as authorized.



75
76
77
78
# File 'lib/autumn/authentication.rb', line 75

def initialize(options={})
  @privileges = options[:privileges]
  @privileges ||= [ :operator, :oper, :op, :admin, :founder, :channel_owner ]
end

Instance Method Details

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

:nodoc:



80
81
82
83
# File 'lib/autumn/authentication.rb', line 80

def authenticate(stem, channel, sender, leaf) # :nodoc:
  # Returns true if the sender has any of the privileges listed below
  not (@privileges & [ stem.privilege(channel, sender) ].flatten).empty?
end

#unauthorizedObject

:nodoc:



85
86
87
# File 'lib/autumn/authentication.rb', line 85

def unauthorized # :nodoc:
  "You must be an op to do that."
end