Commit d17d76a075f711394273b1e579548354c19203f3

Authored by Macartur Sousa
1 parent a157fa3f

Fixed hardcode auth_path

Showing 1 changed file with 20 additions and 9 deletions   Show diff stats
lib/omniauth/strategies/remote_user.rb
1 module OmniAuth 1 module OmniAuth
2 module Strategies 2 module Strategies
3 class RemoteUser 3 class RemoteUser
4 -  
5 include OmniAuth::Strategy 4 include OmniAuth::Strategy
6 -  
7 - #option :cookie, 'rack.session' 5 +
8 option :cookie, '_gitlab_session' 6 option :cookie, '_gitlab_session'
9 option :internal_cookie, '_remote_user' 7 option :internal_cookie, '_remote_user'
10 8
@@ -46,14 +44,14 @@ module OmniAuth @@ -46,14 +44,14 @@ module OmniAuth
46 if response 44 if response
47 response.delete_cookie(options.cookie) 45 response.delete_cookie(options.cookie)
48 response.delete_cookie(options.internal_cookie) 46 response.delete_cookie(options.internal_cookie)
49 - response.redirect "/users/sign_out" 47 + response.redirect sign_out_path
50 response 48 response
51 end 49 end
52 end 50 end
53 51
54 def __login(env, uid) 52 def __login(env, uid)
55 request = Rack::Request.new(env) 53 request = Rack::Request.new(env)
56 - response = redirect_if_not_logging_in(request, "#{OmniAuth.config.path_prefix}/#{name}/callback") 54 + response = redirect_if_not_logging_in(request, auth_path )
57 if response 55 if response
58 response.set_cookie(options.internal_cookie, uid) 56 response.set_cookie(options.internal_cookie, uid)
59 response 57 response
@@ -62,13 +60,13 @@ module OmniAuth @@ -62,13 +60,13 @@ module OmniAuth
62 60
63 def is_in_logout? (env) 61 def is_in_logout? (env)
64 request = Rack::Request.new(env) 62 request = Rack::Request.new(env)
65 - request.path == '/users/sign_out' 63 + request.path == sign_out_path
66 end 64 end
67 65
68 def redirect_if_not_logging_in(request, url) 66 def redirect_if_not_logging_in(request, url)
69 if ! [ 67 if ! [
70 - "#{OmniAuth.config.path_prefix}/#{name}/",  
71 - "#{OmniAuth.config.path_prefix}/#{name}/callback" 68 + auth_path,
  69 + callback_path
72 ].include?(request.path_info) 70 ].include?(request.path_info)
73 response = Rack::Response.new 71 response = Rack::Response.new
74 response.redirect url 72 response.redirect url
@@ -92,8 +90,21 @@ module OmniAuth @@ -92,8 +90,21 @@ module OmniAuth
92 end 90 end
93 91
94 def request_phase 92 def request_phase
95 - "#{OmniAuth.config.path_prefix}/#{name}/callback" 93 + redirect callback_path
  94 + end
  95 +
  96 + def callback_path
  97 + "#{auth_path}/callback"
  98 + end
  99 +
  100 + def auth_path
  101 + "#{path_prefix}/RemoteUser"
  102 + end
  103 +
  104 + def sign_out_path
  105 + '/users/sign_out'
96 end 106 end
  107 +
97 end 108 end
98 end 109 end
99 end 110 end