Commit 4fa137d0b778e86a85c4be3adfbc34a165a9ae6d
1 parent
f32f899f
Exists in
master
and in
2 other branches
Upgrade strategy to use call method
Showing
1 changed file
with
18 additions
and
8 deletions
Show diff stats
lib/omniauth/strategies/remote_user.rb
... | ... | @@ -3,17 +3,21 @@ module OmniAuth |
3 | 3 | class RemoteUser |
4 | 4 | include OmniAuth::Strategy |
5 | 5 | |
6 | - def validate_remote_user | |
7 | - if !env['HTTP_REMOTE_USER'].blank? | |
8 | - env['HTTP_REMOTE_USER'] | |
9 | - else | |
10 | - env['HTTP_X_FORWARDED_USER'] | |
6 | + def call(env) | |
7 | + request = Rack::Request.new env | |
8 | + cookies = request.cookies | |
9 | + response = Rack::Response.new | |
10 | + | |
11 | + if cookies['gitlab_session'] != nil and !env['HTTP_REMOTE_USER'].blank? | |
12 | + response.redirect "#{OmniAuth.config.path_prefix}/users/auth/env/" | |
11 | 13 | end |
14 | + | |
15 | + super(env) | |
12 | 16 | end |
13 | 17 | |
14 | 18 | def request_phase |
15 | 19 | @user_data = {} |
16 | - @uid = validate_remote_user | |
20 | + @uid = env | |
17 | 21 | return fail!(:no_remote_user) unless @uid |
18 | 22 | |
19 | 23 | @user_data[:name] = @uid['NAME'] |
... | ... | @@ -26,9 +30,15 @@ module OmniAuth |
26 | 30 | call_app! |
27 | 31 | end |
28 | 32 | |
29 | - uid { @uid['EMAIL'] } | |
33 | + uid { @uid['NAME'] } | |
30 | 34 | info{ @user_data } |
31 | 35 | |
32 | - end | |
36 | + def callback_phase | |
37 | + fail(:invalid_request) | |
38 | + end | |
39 | + | |
40 | + def auth_hash | |
41 | + Omniauth::Utils.deep_merge(super, {'uid' => @uid}) | |
42 | + end | |
33 | 43 | end |
34 | 44 | end | ... | ... |