class OmniAuth::Strategies::Proxy
Constants
- PROXY_PATH
Public Class Methods
new(app, _options={})
click to toggle source
# File lib/omniauth/strategies/proxy.rb, line 6 def initialize(app, _options={}) @app = app end
Public Instance Methods
call(env)
click to toggle source
# File lib/omniauth/strategies/proxy.rb, line 10 def call(env) status, headers, body = @app.call(env) if ENV["OMNIAUTH_PROXY_ENABLED"].present? && status == 302 location = headers["Location"] if is_google?(location) || is_github?(location) || is_auth0?(location) headers["Location"] = proxy_uri(location) end end [status, headers, body] end
is_auth0?(location)
click to toggle source
# File lib/omniauth/strategies/proxy.rb, line 32 def is_auth0?(location) location.match?("auth0.com/authorize") end
is_github?(location)
click to toggle source
# File lib/omniauth/strategies/proxy.rb, line 28 def is_github?(location) location.match?("https://github.com/login/oauth/authorize") end
is_google?(location)
click to toggle source
# File lib/omniauth/strategies/proxy.rb, line 24 def is_google?(location) location.match?("https://accounts.google.com/o/oauth2/auth") end
proxy_uri(location)
click to toggle source
# File lib/omniauth/strategies/proxy.rb, line 36 def proxy_uri(location) encoded_uri = Base64.urlsafe_encode64(location) PROXY_PATH + "?uri=" + encoded_uri end