Class: Rack::Auth::NginxOmniauthAdapter
- Inherits:
-
Object
- Object
- Rack::Auth::NginxOmniauthAdapter
- Defined in:
- lib/rack/auth/nginx_omniauth_adapter.rb,
lib/rack/auth/nginx_omniauth_adapter/version.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, auth_host:, callback_path: '/_auth/callback') ⇒ NginxOmniauthAdapter
constructor
A new instance of NginxOmniauthAdapter.
Constructor Details
#initialize(app, auth_host:, callback_path: '/_auth/callback') ⇒ NginxOmniauthAdapter
Returns a new instance of NginxOmniauthAdapter.
51 52 53 |
# File 'lib/rack/auth/nginx_omniauth_adapter.rb', line 51 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
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rack/auth/nginx_omniauth_adapter.rb', line 55 def call(env) request = Rack::Auth::Request.new @app do |env| https = Net::HTTP.new(@auth_host, 443) https.use_ssl = true req = Net::HTTP::Get.new('/test') req['x-ngx-omniauth-original-uri'] = "https://#{env['HTTP_HOST']}#{env['REQUEST_URI']}" req['cookie'] = env['HTTP_COOKIE'] response = https.request(req) [ response.code.to_i, response.to_hash, [ response.body ] ] end initiate = Initiate.new(request, auth_host: @auth_host, callback_path: @callback_path) Callback.new(initiate, auth_host: @auth_host, callback_path: @callback_path) end |