Class: Hooks::OneuserAutocreateHook

Inherits:
Object
  • Object
show all
Defined in:
lib/hooks/oneuser_autocreate_hook.rb

Constant Summary collapse

ALLOWED_AUTH_STRATEGIES =
['voms'].freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, options) ⇒ OneuserAutocreateHook

Instantiates the hook with some pre-processing done on provided options.

Parameters:

  • app (Object)

    application object

  • options (Hashie::Mash)

    options in a hash-like structure


11
12
13
14
15
16
17
18
19
# File 'lib/hooks/oneuser_autocreate_hook.rb', line 11

def initialize(app, options)
  @app = app
  @options = options
  @vo_names = @options.vo_names.kind_of?(Array) ? @options.vo_names : @options.vo_names.split(' ')

  Rails.logger.debug "[Hooks] [OneuserAutocreateHook] Enabling autocreate for " \
                     "authentication strategies #{ALLOWED_AUTH_STRATEGIES.inspect} " \
                     "with VOs #{@vo_names.inspect}"
end

Instance Method Details

#call(env) ⇒ Object

Trigger hook execution for a specific incoming request represented by env. After the hook has been executed the control is passed back to the application.

Parameters:

  • env (Object)

    request environment


26
27
28
29
30
31
32
33
# File 'lib/hooks/oneuser_autocreate_hook.rb', line 26

def call(env)
  # get the request and explore it
  request = ::ActionDispatch::Request.new(env)
  start_autocreate(request) unless @vo_names.blank?

  # pass control back to the application
  @app.call(env)
end