Class: Goliath::Rack::Auth::Krb::BasicAndNego

Inherits:
Object
  • Object
show all
Includes:
Goliath::Rack::AsyncMiddleware
Defined in:
lib/goliath/rack/auth/krb/basic_and_nego.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, realm, keytab, service = nil, paths_only = []) ⇒ BasicAndNego

Initialize BasicAndNego configuration

Parameters:

  • realm (String)

    Kerberos realm

  • keytab (String)

    Kerberos keytab

  • service (String) (defaults to: nil)

    Kerberos service (may be nil)

  • paths_only (String) (defaults to: [])

    Allows to request an authentication process only for specified paths



17
18
19
20
21
22
23
# File 'lib/goliath/rack/auth/krb/basic_and_nego.rb', line 17

def initialize(app, realm, keytab, service=nil, paths_only=[])
  @app = app
  @realm = realm
  @keytab = keytab
  @service = service
  @paths_only = paths_only
end

Instance Method Details

#call(env) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/goliath/rack/auth/krb/basic_and_nego.rb', line 25

def call(env)
  a = nil

  if @paths_only.empty? or @paths_only.include?(env["PATH_INFO"])
    a = ::BasicAndNego::Processor.new(env, env.logger, @realm, @keytab, @service)
    a.process_request
    return a.response if a.response
  end
  
  new_headers = (a.nil?) ? {} : a.headers

  super(env, new_headers)
end

#post_process(env, status, headers, body, additional_headers) ⇒ Object



39
40
41
# File 'lib/goliath/rack/auth/krb/basic_and_nego.rb', line 39

def post_process(env, status, headers, body, additional_headers)
  [status, headers.merge(additional_headers), body]
end