Commit 77e176815acc582b644363fcd80bac2fc3f2162a

Authored by Macartur Sousa
1 parent bd2e41b9

Adding remote-user.log altering path callback

lib/omniauth/remote-user.rb
... ... @@ -3,6 +3,6 @@ require 'json'
3 3  
4 4 module OmniAuth
5 5 module Strategies
6   - autoload :RemoteUser, 'omniauth/strategies/remote_user'
  6 + autoload :RemoteUser , 'omniauth/strategies/remote_user'
7 7 end
8 8 end
... ...
lib/omniauth/strategies/remote_user.rb
... ... @@ -8,8 +8,22 @@ module OmniAuth
8 8 option :cookie, '_gitlab_session'
9 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 19 def call(env)
  20 + __write_file "Call \n"
  21 +
12 22 remote_user = env['HTTP_REMOTE_USER']
  23 +
  24 + __write_file "#{remote_user}\n"
  25 +
  26 +
13 27 session_user = __current_user(env)
14 28 if remote_user
15 29 if session_user
... ... @@ -28,14 +42,18 @@ module OmniAuth
28 42 super(env)
29 43 end
30 44 end
  45 +
31 46 end
32 47  
33 48 def __current_user(env)
  49 +
  50 + __write_file "__CURRENT_USER"
34 51 request = Rack::Request.new(env)
35 52 request.cookies.has_key?(options.internal_cookie) && request.cookies[options.internal_cookie]
36 53 end
37 54  
38 55 def __logout(env)
  56 + __write_file "__LOGOUT"
39 57 request = Rack::Request.new(env)
40 58 response = redirect_if_not_logging_in(request, request.path)
41 59 if response
... ... @@ -45,9 +63,10 @@ module OmniAuth
45 63 end
46 64 end
47 65  
48   - def __login(env, uid)
  66 + def __login(env, uid)
  67 + __write_file "__LOGIN"
49 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 70 if response
52 71 response.set_cookie(options.internal_cookie, uid)
53 72 response
... ... @@ -55,9 +74,11 @@ module OmniAuth
55 74 end
56 75  
57 76 def redirect_if_not_logging_in(request, url)
  77 + puts "__redirect_if_not_loggin_in"
  78 +
58 79 if ! [
59   - '/auth/remoteuser',
60   - '/auth/remoteuser/callback'
  80 + '/users/auth/RemoteUser',
  81 + '/users/auth/RemoteUser/callback'
61 82 ].include?(request.path_info)
62 83 response = Rack::Response.new
63 84 response.redirect url
... ... @@ -71,6 +92,7 @@ module OmniAuth
71 92  
72 93 info do
73 94 user_data = request.env['HTTP_REMOTE_USER_DATA']
  95 + __write_file "#{user_data} \n"
74 96 if user_data
75 97 data = JSON.parse(user_data)
76 98 data['nickname'] = data['name']
... ... @@ -81,7 +103,9 @@ module OmniAuth
81 103 end
82 104  
83 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 109 form.html '<script type="text/javascript"> document.forms[0].submit(); </script>'
86 110 form.to_response
87 111 end
... ...