Class: Rack::Auth::NginxOmniauthAdapter::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/auth/nginx_omniauth_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, auth_host:, callback_path: '/_auth/callback') ⇒ Callback

Returns a new instance of Callback.



9
10
11
# File 'lib/rack/auth/nginx_omniauth_adapter.rb', line 9

def initialize(app, auth_host:, callback_path: '/_auth/callback')
  @app, @auth_host, @callback_path = app, auth_host, callback_path
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rack/auth/nginx_omniauth_adapter.rb', line 13

def call(env)
  if env['REQUEST_URI'].split(??, 2)[0] == @callback_path
    https = Net::HTTP.new(@auth_host, 443)
    https.use_ssl = true
    req = Net::HTTP::Get.new("/callback?#{env['QUERY_STRING']}")

    response = https.request(req)
    return [ response.code.to_i, response.to_hash, [ response.body ] ]
  end

  @app.call(env)
end