Commit 77e176815acc582b644363fcd80bac2fc3f2162a
1 parent
bd2e41b9
Exists in
master
and in
2 other branches
Adding remote-user.log altering path callback
Showing
2 changed files
with
30 additions
and
6 deletions
Show diff stats
lib/omniauth/remote-user.rb
@@ -3,6 +3,6 @@ require 'json' | @@ -3,6 +3,6 @@ require 'json' | ||
3 | 3 | ||
4 | module OmniAuth | 4 | module OmniAuth |
5 | module Strategies | 5 | module Strategies |
6 | - autoload :RemoteUser, 'omniauth/strategies/remote_user' | 6 | + autoload :RemoteUser , 'omniauth/strategies/remote_user' |
7 | end | 7 | end |
8 | end | 8 | end |
lib/omniauth/strategies/remote_user.rb
@@ -8,8 +8,22 @@ module OmniAuth | @@ -8,8 +8,22 @@ module OmniAuth | ||
8 | option :cookie, '_gitlab_session' | 8 | option :cookie, '_gitlab_session' |
9 | option :internal_cookie, '_remote_user' | 9 | option :internal_cookie, '_remote_user' |
10 | 10 | ||
11 | + | ||
12 | + def __write_file message | ||
13 | + file = File.open("/home/git/gitlab/log/remote_user.log",'a') | ||
14 | + file.write message | ||
15 | + file.close | ||
16 | + end | ||
17 | + | ||
18 | + | ||
11 | def call(env) | 19 | def call(env) |
20 | + __write_file "Call \n" | ||
21 | + | ||
12 | remote_user = env['HTTP_REMOTE_USER'] | 22 | remote_user = env['HTTP_REMOTE_USER'] |
23 | + | ||
24 | + __write_file "#{remote_user}\n" | ||
25 | + | ||
26 | + | ||
13 | session_user = __current_user(env) | 27 | session_user = __current_user(env) |
14 | if remote_user | 28 | if remote_user |
15 | if session_user | 29 | if session_user |
@@ -28,14 +42,18 @@ module OmniAuth | @@ -28,14 +42,18 @@ module OmniAuth | ||
28 | super(env) | 42 | super(env) |
29 | end | 43 | end |
30 | end | 44 | end |
45 | + | ||
31 | end | 46 | end |
32 | 47 | ||
33 | def __current_user(env) | 48 | def __current_user(env) |
49 | + | ||
50 | + __write_file "__CURRENT_USER" | ||
34 | request = Rack::Request.new(env) | 51 | request = Rack::Request.new(env) |
35 | request.cookies.has_key?(options.internal_cookie) && request.cookies[options.internal_cookie] | 52 | request.cookies.has_key?(options.internal_cookie) && request.cookies[options.internal_cookie] |
36 | end | 53 | end |
37 | 54 | ||
38 | def __logout(env) | 55 | def __logout(env) |
56 | + __write_file "__LOGOUT" | ||
39 | request = Rack::Request.new(env) | 57 | request = Rack::Request.new(env) |
40 | response = redirect_if_not_logging_in(request, request.path) | 58 | response = redirect_if_not_logging_in(request, request.path) |
41 | if response | 59 | if response |
@@ -45,9 +63,10 @@ module OmniAuth | @@ -45,9 +63,10 @@ module OmniAuth | ||
45 | end | 63 | end |
46 | end | 64 | end |
47 | 65 | ||
48 | - def __login(env, uid) | 66 | + def __login(env, uid) |
67 | + __write_file "__LOGIN" | ||
49 | request = Rack::Request.new(env) | 68 | request = Rack::Request.new(env) |
50 | - response = redirect_if_not_logging_in(request, '/auth/remoteuser') | 69 | + response = redirect_if_not_logging_in(request, '/users/auth/RemoteUser') |
51 | if response | 70 | if response |
52 | response.set_cookie(options.internal_cookie, uid) | 71 | response.set_cookie(options.internal_cookie, uid) |
53 | response | 72 | response |
@@ -55,9 +74,11 @@ module OmniAuth | @@ -55,9 +74,11 @@ module OmniAuth | ||
55 | end | 74 | end |
56 | 75 | ||
57 | def redirect_if_not_logging_in(request, url) | 76 | def redirect_if_not_logging_in(request, url) |
77 | + puts "__redirect_if_not_loggin_in" | ||
78 | + | ||
58 | if ! [ | 79 | if ! [ |
59 | - '/auth/remoteuser', | ||
60 | - '/auth/remoteuser/callback' | 80 | + '/users/auth/RemoteUser', |
81 | + '/users/auth/RemoteUser/callback' | ||
61 | ].include?(request.path_info) | 82 | ].include?(request.path_info) |
62 | response = Rack::Response.new | 83 | response = Rack::Response.new |
63 | response.redirect url | 84 | response.redirect url |
@@ -71,6 +92,7 @@ module OmniAuth | @@ -71,6 +92,7 @@ module OmniAuth | ||
71 | 92 | ||
72 | info do | 93 | info do |
73 | user_data = request.env['HTTP_REMOTE_USER_DATA'] | 94 | user_data = request.env['HTTP_REMOTE_USER_DATA'] |
95 | + __write_file "#{user_data} \n" | ||
74 | if user_data | 96 | if user_data |
75 | data = JSON.parse(user_data) | 97 | data = JSON.parse(user_data) |
76 | data['nickname'] = data['name'] | 98 | data['nickname'] = data['name'] |
@@ -81,7 +103,9 @@ module OmniAuth | @@ -81,7 +103,9 @@ module OmniAuth | ||
81 | end | 103 | end |
82 | 104 | ||
83 | def request_phase | 105 | def request_phase |
84 | - form = OmniAuth::Form.new(:url => callback_path) | 106 | + __write_file "request phase\n" |
107 | + | ||
108 | + form = OmniAuth::Form.new(:url => "RemoteUser/callback") | ||
85 | form.html '<script type="text/javascript"> document.forms[0].submit(); </script>' | 109 | form.html '<script type="text/javascript"> document.forms[0].submit(); </script>' |
86 | form.to_response | 110 | form.to_response |
87 | end | 111 | end |