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 1 module OmniAuth
2 2 module Strategies
3 3 class RemoteUser
4   -
5 4 include OmniAuth::Strategy
6   -
7   - #option :cookie, 'rack.session'
  5 +
8 6 option :cookie, '_gitlab_session'
9 7 option :internal_cookie, '_remote_user'
10 8  
... ... @@ -46,14 +44,14 @@ module OmniAuth
46 44 if response
47 45 response.delete_cookie(options.cookie)
48 46 response.delete_cookie(options.internal_cookie)
49   - response.redirect "/users/sign_out"
  47 + response.redirect sign_out_path
50 48 response
51 49 end
52 50 end
53 51  
54 52 def __login(env, uid)
55 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 55 if response
58 56 response.set_cookie(options.internal_cookie, uid)
59 57 response
... ... @@ -62,13 +60,13 @@ module OmniAuth
62 60  
63 61 def is_in_logout? (env)
64 62 request = Rack::Request.new(env)
65   - request.path == '/users/sign_out'
  63 + request.path == sign_out_path
66 64 end
67 65  
68 66 def redirect_if_not_logging_in(request, url)
69 67 if ! [
70   - "#{OmniAuth.config.path_prefix}/#{name}/",
71   - "#{OmniAuth.config.path_prefix}/#{name}/callback"
  68 + auth_path,
  69 + callback_path
72 70 ].include?(request.path_info)
73 71 response = Rack::Response.new
74 72 response.redirect url
... ... @@ -92,8 +90,21 @@ module OmniAuth
92 90 end
93 91  
94 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 106 end
  107 +
97 108 end
98 109 end
99 110 end
... ...