Class: ASF::Auth::MembersAndOfficers

Inherits:
Rack::Auth::Basic
  • Object
show all
Defined in:
lib/whimsy/asf/rack.rb

Overview

‘use’ the following class in config.ru to limit access to the application to ASF members and officers and the accounting group.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ MembersAndOfficers

Returns a new instance of MembersAndOfficers.



62
63
64
# File 'lib/whimsy/asf/rack.rb', line 62

def initialize(app)
  super(app, "ASF Members and Officers", &proc {})
end

Instance Method Details

#call(env) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/whimsy/asf/rack.rb', line 66

def call(env)
  authorized = ( ENV['RACK_ENV'] == 'test' )

  person = ASF::Auth.decode(env)

  authorized ||= DIRECTORS[env.user]
  authorized ||= person.asf_member?
  authorized ||= ASF.pmc_chairs.include? person

  if not authorized
    accounting = ASF::Authorization.new('pit').
      find {|group, list| group=='accounting'}
    authorized = (accounting and accounting.last.include? env.user)
  end

  if authorized
    @app.call(env)
  else
    unauthorized
  end
end