class Rack::Auth::NginxOmniauthAdapter::Callback

Public Class Methods

new(app, auth_host:, callback_path: '/_auth/callback') click to toggle source
# 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

Public Instance Methods

call(env) click to toggle source
# 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