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 | 4 | |
| 5 | 5 | include OmniAuth::Strategy |
| 6 | 6 | |
| 7 | + #option :cookie, 'rack.session' | |
| 7 | 8 | option :cookie, '_gitlab_session' |
| 8 | 9 | option :internal_cookie, '_remote_user' |
| 9 | 10 | |
| ... | ... | @@ -14,17 +15,17 @@ module OmniAuth |
| 14 | 15 | if ! is_in_logout? (env) |
| 15 | 16 | if remote_user |
| 16 | 17 | if session_user |
| 17 | - if remote_user == session_user | |
| 18 | + if remote_user == session_user | |
| 18 | 19 | super(env) |
| 19 | 20 | else |
| 20 | - __logout(env) | |
| 21 | + __logout(env) || super(env) | |
| 21 | 22 | end |
| 22 | 23 | else |
| 23 | - __login(env, remote_user) | |
| 24 | + __login(env, remote_user) || super(env) | |
| 24 | 25 | end |
| 25 | 26 | else |
| 26 | 27 | if session_user |
| 27 | - __logout(env) | |
| 28 | + __logout(env) || super(env) | |
| 28 | 29 | else |
| 29 | 30 | super(env) |
| 30 | 31 | end |
| ... | ... | @@ -34,11 +35,6 @@ module OmniAuth |
| 34 | 35 | end |
| 35 | 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 | 38 | def __current_user(env) |
| 43 | 39 | request = Rack::Request.new(env) |
| 44 | 40 | request.cookies.has_key?(options.internal_cookie) && request.cookies[options.internal_cookie] |
| ... | ... | @@ -57,18 +53,22 @@ module OmniAuth |
| 57 | 53 | |
| 58 | 54 | def __login(env, uid) |
| 59 | 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 | 57 | if response |
| 62 | 58 | response.set_cookie(options.internal_cookie, uid) |
| 63 | 59 | response |
| 64 | 60 | end |
| 65 | 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 | 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 | 72 | ].include?(request.path_info) |
| 73 | 73 | response = Rack::Response.new |
| 74 | 74 | response.redirect url |
| ... | ... | @@ -92,7 +92,7 @@ module OmniAuth |
| 92 | 92 | end |
| 93 | 93 | |
| 94 | 94 | def request_phase |
| 95 | - redirect "/users/auth/RemoteUser/callback" | |
| 95 | + "#{OmniAuth.config.path_prefix}/#{name}/callback" | |
| 96 | 96 | end |
| 97 | 97 | end |
| 98 | 98 | end | ... | ... |