Commit a59e035b1481ab47d4d01cb11672582bf92eeae6
1 parent
d67c7d49
Exists in
master
and in
2 other branches
Add omniauth relative path for requests
Showing
1 changed file
with
14 additions
and
14 deletions
Show diff stats
lib/omniauth/strategies/remote_user.rb
@@ -4,6 +4,7 @@ module OmniAuth | @@ -4,6 +4,7 @@ module OmniAuth | ||
4 | 4 | ||
5 | include OmniAuth::Strategy | 5 | include OmniAuth::Strategy |
6 | 6 | ||
7 | + #option :cookie, 'rack.session' | ||
7 | option :cookie, '_gitlab_session' | 8 | option :cookie, '_gitlab_session' |
8 | option :internal_cookie, '_remote_user' | 9 | option :internal_cookie, '_remote_user' |
9 | 10 | ||
@@ -14,17 +15,17 @@ module OmniAuth | @@ -14,17 +15,17 @@ module OmniAuth | ||
14 | if ! is_in_logout? (env) | 15 | if ! is_in_logout? (env) |
15 | if remote_user | 16 | if remote_user |
16 | if session_user | 17 | if session_user |
17 | - if remote_user == session_user | 18 | + if remote_user == session_user |
18 | super(env) | 19 | super(env) |
19 | else | 20 | else |
20 | - __logout(env) | 21 | + __logout(env) || super(env) |
21 | end | 22 | end |
22 | else | 23 | else |
23 | - __login(env, remote_user) | 24 | + __login(env, remote_user) || super(env) |
24 | end | 25 | end |
25 | else | 26 | else |
26 | if session_user | 27 | if session_user |
27 | - __logout(env) | 28 | + __logout(env) || super(env) |
28 | else | 29 | else |
29 | super(env) | 30 | super(env) |
30 | end | 31 | end |
@@ -34,11 +35,6 @@ module OmniAuth | @@ -34,11 +35,6 @@ module OmniAuth | ||
34 | end | 35 | end |
35 | end | 36 | end |
36 | 37 | ||
37 | - def is_in_logout? (env) | ||
38 | - request = Rack::Request.new(env) | ||
39 | - request.path == '/users/sign_out' | ||
40 | - end | ||
41 | - | ||
42 | def __current_user(env) | 38 | def __current_user(env) |
43 | request = Rack::Request.new(env) | 39 | request = Rack::Request.new(env) |
44 | request.cookies.has_key?(options.internal_cookie) && request.cookies[options.internal_cookie] | 40 | request.cookies.has_key?(options.internal_cookie) && request.cookies[options.internal_cookie] |
@@ -57,18 +53,22 @@ module OmniAuth | @@ -57,18 +53,22 @@ module OmniAuth | ||
57 | 53 | ||
58 | def __login(env, uid) | 54 | def __login(env, uid) |
59 | request = Rack::Request.new(env) | 55 | request = Rack::Request.new(env) |
60 | - response = redirect_if_not_logging_in(request, '/users/auth/RemoteUser') | 56 | + response = redirect_if_not_logging_in(request, "#{OmniAuth.config.path_prefix}/#{name}/callback") |
61 | if response | 57 | if response |
62 | response.set_cookie(options.internal_cookie, uid) | 58 | response.set_cookie(options.internal_cookie, uid) |
63 | response | 59 | response |
64 | end | 60 | end |
65 | end | 61 | end |
66 | 62 | ||
67 | - def redirect_if_not_logging_in(request, url) | 63 | + def is_in_logout? (env) |
64 | + request = Rack::Request.new(env) | ||
65 | + request.path == '/users/sign_out' | ||
66 | + end | ||
68 | 67 | ||
68 | + def redirect_if_not_logging_in(request, url) | ||
69 | if ! [ | 69 | if ! [ |
70 | - '/users/auth/RemoteUser', | ||
71 | - '/users/auth/RemoteUser/callback' | 70 | + "#{OmniAuth.config.path_prefix}/#{name}/", |
71 | + "#{OmniAuth.config.path_prefix}/#{name}/callback" | ||
72 | ].include?(request.path_info) | 72 | ].include?(request.path_info) |
73 | response = Rack::Response.new | 73 | response = Rack::Response.new |
74 | response.redirect url | 74 | response.redirect url |
@@ -92,7 +92,7 @@ module OmniAuth | @@ -92,7 +92,7 @@ module OmniAuth | ||
92 | end | 92 | end |
93 | 93 | ||
94 | def request_phase | 94 | def request_phase |
95 | - redirect "/users/auth/RemoteUser/callback" | 95 | + "#{OmniAuth.config.path_prefix}/#{name}/callback" |
96 | end | 96 | end |
97 | end | 97 | end |
98 | end | 98 | end |