Class: Rlyeh::DeepOnes::Auth::Base
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Logger
crash, format_exception
#dispatch, included, #trigger
Constructor Details
#initialize(app, &block) ⇒ Base
Returns a new instance of Base.
13
14
15
16
17
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 13
def initialize(app, &block)
@app = app
@authenticated = false
instance_eval &block if block
end
|
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
11
12
13
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 11
def host
@host
end
|
#nick ⇒ Object
Returns the value of attribute nick.
11
12
13
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 11
def nick
@nick
end
|
#pass ⇒ Object
Returns the value of attribute pass.
11
12
13
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 11
def pass
@pass
end
|
#real ⇒ Object
Returns the value of attribute real.
11
12
13
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 11
def real
@real
end
|
#user ⇒ Object
Returns the value of attribute user.
11
12
13
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 11
def user
@user
end
|
Instance Method Details
#authenticated? ⇒ Boolean
28
29
30
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 28
def authenticated?
@authenticated
end
|
#call(env) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 19
def call(env)
dispatch env
if authenticated?
env.auth = self
@app.call env if @app
end
end
|
#failed(env) ⇒ Object
47
48
49
50
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 47
def failed(env)
env.connection.send_numeric_reply :passwdmismatch, @host, ':Password incorrect'
debug "Authentication failed #{env.connection.host}:#{env.connection.port}"
end
|
#session_id ⇒ Object
36
37
38
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 36
def session_id
@nick
end
|
#succeeded(env) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 40
def succeeded(env)
@authorized = true
session = env.server.load_session session_id
session.attach env.connection
debug "Authentication succeeded #{env.connection.host}:#{env.connection.port}"
end
|
#try(env) ⇒ Object
32
33
34
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 32
def try(env)
raise NotImplementedError
end
|
#welcome(env) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/rlyeh/deep_ones/auth/base.rb', line 52
def welcome(env)
name = env.settings.server_name
version = env.settings.server_version
user_modes = env.settings.available_user_modes
channel_modes = env.settings.available_channel_modes
messages = {
:welcome => "Welcome to the Internet Relay Network #{@nick}!#{@user}@#{@host}",
:yourhost => "Your host is #{name}, running version #{version}",
:created => "This server was created #{Time.now}",
:myinfo => "#{name} #{version} #{user_modes} #{channel_modes}"
}
messages.each do |type, message|
env.connection.send_numeric_reply type, @nick, ":#{message}", :prefix => {:servername => name}
end
end
|