Skip to content

Commit

Permalink
fallback to forwarded headers if the scheme is lying to us
Browse files Browse the repository at this point in the history
fixes up heroku cedar issues where redirect url doesn't infer https
  • Loading branch information
atmos committed May 25, 2012
1 parent 345062f commit 60dd327
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/warden-github/strategy.rb
Expand Up @@ -48,16 +48,16 @@ def oauth_proxy
end

def callback_url
absolute_url(request, env['warden'].config[:github_callback_url])
absolute_url(request, env['warden'].config[:github_callback_url], env['HTTP_X_FORWARDED_PROTO'])
end

def absolute_url(request, suffix = nil)
def absolute_url(request, suffix = nil, proto = "http")
port_part = case request.scheme
when "http"
request.port == 80 ? "" : ":#{request.port}"
when "https"
request.port == 443 ? "" : ":#{request.port}"
end
"#{request.scheme}://#{request.host}#{port_part}#{suffix}"
"#{proto}://#{request.host}#{port_part}#{suffix}"
end
end

0 comments on commit 60dd327

Please sign in to comment.