Merge Request #1
-
Signed-off-by: Macartur Sousa <macartur.sc@gmail.com>
- 8 of 18 commits displayed. Click here to show all
1 | source "http://rubygems.org" | 1 | source "http://rubygems.org" |
2 | 2 | ||
3 | -group :development, :test do | ||
4 | - gem 'guard' | ||
5 | - gem 'guard-rspec' | ||
6 | - gem 'guard-bundler' | ||
7 | - gem 'rb-fsevent' | ||
8 | - gem 'simplecov' | ||
9 | - gem 'rspec' | ||
10 | - gem 'rake' | ||
11 | - gem 'coveralls' | ||
12 | - gem 'rack-test' | 3 | +gemspec |
4 | + | ||
5 | +group :development do | ||
6 | + gem 'guard' | ||
7 | + gem 'guard-bundler' | ||
8 | + gem 'guard-rspec' | ||
9 | + gem 'rake' | ||
10 | + gem 'bundler' | ||
11 | + gem 'sinatra' | ||
13 | end | 12 | end |
14 | 13 | ||
15 | -gemspec | 14 | +group :test do |
15 | + gem 'coveralls' | ||
16 | + gem 'rack-test' | ||
17 | + gem 'simplecov' | ||
18 | + gem 'rspec' | ||
19 | +end |
1 | # Omniath Remote User | 1 | # Omniath Remote User |
2 | 2 | ||
3 | The Omniauth Remote User gem provides a way for application to utilize a authentication with remote user HTTP header. | 3 | The Omniauth Remote User gem provides a way for application to utilize a authentication with remote user HTTP header. |
4 | + | ||
5 | +# Instalation | ||
6 | + | ||
7 | +Include in your Gemfile | ||
8 | + | ||
9 | +```ruby | ||
10 | +gem "omniauth-remote-user" | ||
11 | +``` | ||
12 | +Then run `bundle install` from the command line: | ||
13 | + | ||
14 | + bundle install |
@@ -0,0 +1,43 @@ | @@ -0,0 +1,43 @@ | ||
1 | +require 'sinatra' | ||
2 | +require 'omniauth' | ||
3 | +require 'json' | ||
4 | + | ||
5 | +class MyApplication < Sinatra::Base | ||
6 | + use Rack::Session::Cookie, secret: '123' | ||
7 | + | ||
1 |
|
||
8 | + STRATEGY = 'RemoteUser' | ||
9 | + #use OmniAuth::Strategies::RemoteUser | ||
10 | + #STRATEGY = 'developer' | ||
11 | + use OmniAuth::Strategies::Developer | ||
12 | + | ||
13 | + | ||
14 | + get '/login' do | ||
15 | + redirect '/gitlab/auth/%s' % STRATEGY | ||
16 | + end | ||
17 | + | ||
18 | + get '/logout' do | ||
19 | + session[:current_user] = nil | ||
20 | + redirect '/' | ||
21 | + end | ||
22 | + | ||
23 | + post '/auth/:provider/callback' do | ||
24 | + session[:current_user] = request.env['omniauth.auth']['uid'] | ||
25 | + session[:current_user_email] = request.env['omniauth.auth']['info']['email'] | ||
26 | + session[:current_user_nickname] = request.env['omniauth.auth']['info']['nickname'] | ||
27 | + | ||
28 | + redirect '/' | ||
29 | + end | ||
30 | + | ||
31 | + get '/' do | ||
32 | + user = session[:current_user] | ||
33 | + if user | ||
34 | + info = "(%s → %s)" % [session[:current_user_email], session[:current_user_nickname]] | ||
35 | + user + info + ' <a href="/logout">logout</a>' | ||
36 | + else | ||
37 | + 'NOT AUTHENTICATED <a href="/login">login</a>' | ||
38 | + end | ||
39 | + end | ||
40 | +end | ||
41 | + | ||
42 | +run MyApplication | ||
43 | + |
@@ -2,7 +2,7 @@ require 'omniauth' | @@ -2,7 +2,7 @@ require 'omniauth' | ||
2 | require 'json' | 2 | require 'json' |
3 | 3 | ||
4 | module OmniAuth | 4 | module OmniAuth |
5 | - module Strategies | ||
6 | - autoload :RemoteUser, 'omniauth/strategies/remote_user' | ||
7 | - end | 5 | + module Strategies |
6 | + autoload :RemoteUser, 'omniauth/strategies/remote_user' | ||
7 | + end | ||
8 | end | 8 | end |
1 | module OmniAuth | 1 | module OmniAuth |
2 | module Strategies | 2 | module Strategies |
3 | class RemoteUser | 3 | class RemoteUser |
4 | - | ||
5 | include OmniAuth::Strategy | 4 | include OmniAuth::Strategy |
6 | 5 | ||
7 | - #option :cookie, 'rack.session' | ||
8 | - option :cookie, '_gitlab_session' | ||
9 | option :internal_cookie, '_remote_user' | 6 | option :internal_cookie, '_remote_user' |
10 | 7 | ||
11 | def call(env) | 8 | def call(env) |
9 | + | ||
12 | remote_user = env['HTTP_REMOTE_USER'] | 10 | remote_user = env['HTTP_REMOTE_USER'] |
13 | session_user = __current_user(env) | 11 | session_user = __current_user(env) |
12 | + | ||
14 | if remote_user | 13 | if remote_user |
15 | if session_user | 14 | if session_user |
16 | if remote_user == session_user | 15 | if remote_user == session_user |
17 | super(env) | 16 | super(env) |
18 | else | 17 | else |
19 | - __login(env, remote_user) || super(env) | 18 | + __logout(env) |
20 | end | 19 | end |
21 | else | 20 | else |
22 | - __login(env, remote_user) || super(env) | 21 | + __login(env, remote_user) |
23 | end | 22 | end |
24 | else | 23 | else |
25 | if session_user | 24 | if session_user |
26 | - __logout(env) || super(env) | 25 | + __logout(env) |
27 | else | 26 | else |
28 | super(env) | 27 | super(env) |
29 | end | 28 | end |
@@ -37,34 +36,35 @@ module OmniAuth | @@ -37,34 +36,35 @@ module OmniAuth | ||
37 | 36 | ||
38 | def __logout(env) | 37 | def __logout(env) |
39 | request = Rack::Request.new(env) | 38 | request = Rack::Request.new(env) |
40 | - response = redirect_if_not_logging_in(request, request.path) | 39 | + request.session.clear |
40 | + response = redirect_if_not_logging_in(request, request.path ) | ||
41 | if response | 41 | if response |
42 | - response.delete_cookie(options.cookie) | ||
43 | - response.delete_cookie(options.internal_cookie) | ||
44 | - response | 42 | + response.delete_cookie(options.internal_cookie , path: "#{request.script_name}" ) |
3 |
|
||
43 | + response.finish | ||
45 | end | 44 | end |
46 | end | 45 | end |
47 | 46 | ||
48 | def __login(env, uid) | 47 | def __login(env, uid) |
49 | request = Rack::Request.new(env) | 48 | request = Rack::Request.new(env) |
50 | - response = redirect_if_not_logging_in(request, '/auth/remoteuser') | 49 | + response = redirect_if_not_logging_in(request,_auth_path(request) ) |
51 | if response | 50 | if response |
52 | - response.set_cookie(options.internal_cookie, uid) | ||
53 | - response | 51 | + response.set_cookie(options.internal_cookie, {value: uid , path: "#{request.script_name}"}) |
52 | + response.finish | ||
54 | end | 53 | end |
55 | end | 54 | end |
56 | 55 | ||
57 | def redirect_if_not_logging_in(request, url) | 56 | def redirect_if_not_logging_in(request, url) |
58 | if ! [ | 57 | if ! [ |
59 | - '/auth/remoteuser', | ||
60 | - '/auth/remoteuser/callback' | ||
61 | - ].include?(request.path_info) | 58 | + _auth_path(request), |
59 | + _callback_path(request) | ||
60 | + ].include?(request.path_info) | ||
62 | response = Rack::Response.new | 61 | response = Rack::Response.new |
63 | response.redirect url | 62 | response.redirect url |
64 | response | 63 | response |
65 | end | 64 | end |
66 | end | 65 | end |
67 | 66 | ||
67 | + | ||
68 | uid do | 68 | uid do |
69 | request.env['HTTP_REMOTE_USER'] | 69 | request.env['HTTP_REMOTE_USER'] |
70 | end | 70 | end |
@@ -73,7 +73,9 @@ module OmniAuth | @@ -73,7 +73,9 @@ module OmniAuth | ||
73 | user_data = request.env['HTTP_REMOTE_USER_DATA'] | 73 | user_data = request.env['HTTP_REMOTE_USER_DATA'] |
74 | if user_data | 74 | if user_data |
75 | data = JSON.parse(user_data) | 75 | data = JSON.parse(user_data) |
76 | - data['nickname'] = data['name'] | 76 | + data['nickname'] = uid |
6 |
|
||
77 | + data['firstname'] = data['name'].split()[0] | ||
78 | + data['lastname'] = data['name'].split()[1] | ||
77 | data | 79 | data |
78 | else | 80 | else |
79 | {} | 81 | {} |
@@ -81,11 +83,17 @@ module OmniAuth | @@ -81,11 +83,17 @@ module OmniAuth | ||
81 | end | 83 | end |
82 | 84 | ||
83 | def request_phase | 85 | def request_phase |
84 | - form = OmniAuth::Form.new(:url => callback_path) | ||
85 | - form.html '<script type="text/javascript"> document.forms[0].submit(); </script>' | ||
86 | - form.to_response | 86 | + redirect _callback_path(request) |
87 | end | 87 | end |
88 | + | ||
89 | + def _callback_path(request) | ||
90 | + "#{_auth_path(request)}/callback" | ||
91 | + end | ||
92 | + | ||
93 | + def _auth_path(request) | ||
94 | + "#{request.script_name}#{path_prefix}/RemoteUser" | ||
95 | + end | ||
96 | + | ||
88 | end | 97 | end |
89 | end | 98 | end |
90 | end | 99 | end |
91 | - |
1 | require File.dirname(__FILE__) + '/lib/omniauth-remote-user/version' | 1 | require File.dirname(__FILE__) + '/lib/omniauth-remote-user/version' |
2 | 2 | ||
3 | Gem::Specification.new do |gem| | 3 | Gem::Specification.new do |gem| |
4 | - gem.add_runtime_dependency 'omniauth' | ||
5 | - | ||
6 | - gem.add_runtime_dependency 'simplecov' | ||
7 | - gem.add_runtime_dependency 'bundler' | ||
8 | - gem.add_runtime_dependency 'rake' | ||
9 | - gem.add_runtime_dependency 'rspec' | ||
10 | - gem.add_runtime_dependency 'rack-test' | ||
11 | - gem.add_runtime_dependency 'activerecord' | ||
12 | - | 4 | + gem.add_runtime_dependency 'omniauth', '~> 1.0' |
13 | gem.name = 'omniauth-remote-user' | 5 | gem.name = 'omniauth-remote-user' |
14 | gem.version = Omniauth::RemoteUser::VERSION | 6 | gem.version = Omniauth::RemoteUser::VERSION |
15 | - gem.description = %q{Authentication with Remote-User HTTP header for Omniauth.} | ||
16 | - gem.summary = gem.description | ||
17 | - gem.email = ['kanashiro.duarte@gmail.com', 'thiagitosouza@gmail.com', 'rodrigosiqueiramelo@gmail.com'] | 7 | + gem.description = 'Authentication with Remote-User HTTP header for Omniauth.' |
8 | + gem.summary = 'Authentication with HTTP Remote User' | ||
9 | + gem.email = ['kanashiro.duarte@gmail.com', 'thiagitosouza@gmail.com', 'rodrigosiqueiramelo@gmail.com','macartur.sc@gmail.com','terceiro@softwarelivre.org'] | ||
2 |
|
||
18 | gem.homepage = 'http://beta.softwarepublico.gov.br/gitlab/softwarepublico/omiauth-remote-user' | 10 | gem.homepage = 'http://beta.softwarepublico.gov.br/gitlab/softwarepublico/omiauth-remote-user' |
19 | - gem.authors = ['Lucas Kanashiro', 'Thiago Ribeiro', 'Rodrigo Siqueira'] | 11 | + gem.authors = ['Lucas Kanashiro', 'Thiago Ribeiro', 'Rodrigo Siqueira','Macartur Sousa', 'Antonio Terceiro'] |
20 | gem.require_paths = %w(lib) | 12 | gem.require_paths = %w(lib) |
21 | gem.files = `git ls-files -z`.split("\x0").reject {|f| f.start_with?('spec/')} | 13 | gem.files = `git ls-files -z`.split("\x0").reject {|f| f.start_with?('spec/')} |
22 | gem.test_files = `git ls-files -- {test,spec,feature}/*`.split("\n") | 14 | gem.test_files = `git ls-files -- {test,spec,feature}/*`.split("\n") |
1 | require 'spec_helper' | 1 | require 'spec_helper' |
2 | 2 | ||
3 | describe 'Test Strategy Remote_User' do | 3 | describe 'Test Strategy Remote_User' do |
4 | - let(:app) do | ||
5 | - Rack::Builder.new do |b| | ||
6 | - b.use Rack::Session::Cookie, :secret => 'abc123' | ||
7 | - b.use OmniAuth::Strategies::RemoteUser | ||
8 | - b.run lambda { |_env| [200, {}, ['My body']] } | ||
9 | - end.to_app | ||
10 | - end | ||
11 | - | ||
12 | - context 'Without REMOTE_USER and not logged in' do | ||
13 | - before(:each){ | ||
14 | - get '/', {}, {} | ||
15 | - } | ||
16 | - | ||
17 | - it 'Do nothing' do | ||
18 | - expect(last_response.status).to eq(200) | ||
19 | - expect(last_request.cookies['_remote_user']).to eq(nil) | ||
20 | - expect(last_request.cookies['_gitlab_session']).to eq(nil) | ||
21 | - end | ||
22 | - end | ||
23 | - | ||
24 | - context 'Without REMOTE_USER and logged in' do | ||
25 | - before(:each){ | ||
26 | - clear_cookies | ||
27 | - set_cookie "_gitlab_session=test" | ||
28 | - set_cookie "_remote_user=test" | ||
29 | - get '/', {}, {} | ||
30 | - } | ||
31 | - | ||
32 | - it 'Logout curreent user' do | ||
33 | - cookie_session_str = "_gitlab_session=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000" << | ||
34 | - "\n_remote_user=; max-age=0; expires=Thu, 01 Jan 1970 00:00:00 -0000" | ||
35 | - expect(last_request.cookies['_gitlab_session']).to eq('test') | ||
36 | - expect(last_request.cookies['_remote_user']).to eq('test') | ||
37 | - expect(last_response.status).to eq(302) | ||
38 | - expect(last_response['Set-Cookie']).to eq(cookie_session_str) | ||
39 | - end | ||
40 | - end | ||
41 | - | ||
42 | - context 'With REMOTE_USER and not logged in' do | ||
43 | - before(:each){ | ||
44 | - get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' } | ||
45 | - } | ||
46 | - | ||
47 | - it 'logs REMOTE_USER in' do | ||
48 | - expect(last_response.status).to eq(302) | ||
49 | - expect(last_response['Set-Cookie']).to eq('_remote_user=foobar') | ||
50 | - end | ||
51 | - end | ||
52 | - | ||
53 | - context 'With REMOTE_USER, logged in and current user equals REMOTE_USER' do | ||
54 | - before(:each){ | ||
55 | - clear_cookies | ||
56 | - set_cookie "_gitlab_session=foobar" | ||
57 | - set_cookie "_remote_user=foobar" | ||
58 | - get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' } | ||
59 | - } | ||
60 | - | ||
61 | - it 'Do nothing' do | ||
62 | - cookie_session_str = "_gitlab_session=foobar\n_remote_user=foobar" | ||
63 | - expect(last_request.cookies['_gitlab_session']).to eq('foobar') | ||
64 | - expect(last_request.cookies['_remote_user']).to eq('foobar') | ||
65 | - expect(last_response.status).to eq(200) | ||
66 | - expect(last_response['Set-Cookie']).to eq(nil) | ||
67 | - end | ||
68 | - end | ||
69 | - | ||
70 | - context 'With REMOTE_USER, logged in and current user not equals REMOTE_USER' do | ||
71 | - before(:each){ | ||
72 | - clear_cookies | ||
73 | - set_cookie "_gitlab_session=foobar" | ||
74 | - set_cookie "_remote_user=foobar" | ||
75 | - get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar2' } | ||
76 | - } | ||
77 | - | ||
78 | - it 'Logout current user and login REMOTE_USER' do | ||
79 | - expect(last_request.cookies['_gitlab_session']).to eq('foobar') | ||
80 | - expect(last_request.cookies['_remote_user']).to eq('foobar') | ||
81 | - expect(last_response.status).to eq(302) | ||
82 | - expect(last_response['Set-Cookie']).to eq('_remote_user=foobar2') | ||
83 | - end | ||
84 | - end | ||
85 | - | ||
86 | - context 'Verify omniauth hash with REMOTE_USER_DATA' do | ||
87 | - before(:each){ | ||
88 | - clear_cookies | ||
89 | - post '/auth/remoteuser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar', | ||
90 | - 'HTTP_REMOTE_USER_DATA' => JSON.dump({'name' => 'foobar', 'email' => 'foobar@test.com'})} | ||
91 | - } | ||
92 | - | ||
93 | - it 'Verify uid' do | ||
94 | - expect(last_request.env['omniauth.auth']['uid']).to eq('foobar') | ||
95 | - end | ||
96 | - | ||
97 | - it 'Verify info' do | ||
98 | - expect(last_request.env['omniauth.auth']['info']['nickname']).to eq('foobar') | ||
99 | - expect(last_request.env['omniauth.auth']['info']['email']).to eq('foobar@test.com') | ||
100 | - end | ||
101 | - end | ||
102 | - | ||
103 | - context 'Verify omniauth.auth info without REMOTE_USER_DATA' do | ||
104 | - before(:each){ | ||
105 | - clear_cookies | ||
106 | - post '/auth/remoteuser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar' } | ||
107 | - } | ||
108 | - | ||
109 | - it 'Verify uid' do | ||
110 | - expect(last_request.env['omniauth.auth']['uid']).to eq('foobar') | ||
111 | - end | ||
112 | - | ||
113 | - it 'Verify info' do | ||
114 | - expect(last_request.env['omniauth.auth']['info']).to eq({}) | ||
115 | - end | ||
116 | - end | ||
117 | -end | 4 | + let(:app) do |
5 | + Rack::Builder.new do |b| | ||
6 | + b.use Rack::Session::Cookie, :secret => 'abc123' | ||
7 | + b.use OmniAuth::Strategies::RemoteUser | ||
8 | + b.run lambda { |_env| [200, {}, ['My body']] } | ||
9 | + end.to_app | ||
10 | + end | ||
11 | + | ||
12 | + context 'Without HTTP_REMOTE_USER and not logged in' do | ||
13 | + before(:each){ | ||
14 | + get '/', {}, {} | ||
15 | + } | ||
16 | + | ||
17 | + it 'Do nothing' do | ||
18 | + expect(last_response.status).to eq(200) | ||
19 | + expect(last_request.cookies['_remote_user']).to eq(nil) | ||
20 | + end | ||
21 | + end | ||
22 | + | ||
23 | + context 'Without HTTP_REMOTE_USER and logged in' do | ||
24 | + before(:each){ | ||
25 | + clear_cookies | ||
26 | + set_cookie "_remote_user=test" | ||
27 | + get '/', {}, {} | ||
28 | + } | ||
29 | + | ||
30 | + it 'Logout curreent user' do | ||
31 | + expect(last_request.cookies['_remote_user']).to eq('test') | ||
32 | + expect(last_response.status).to eq(302) | ||
33 | + expect(last_response['Set-Cookie']).to include("_remote_user=") | ||
34 | + expect(last_response['Set-Cookie']).to include("path=") | ||
35 | + end | ||
36 | + end | ||
37 | + | ||
38 | + context 'With HTTP_REMOTE_USER and not logged in' do | ||
39 | + before(:each){ | ||
40 | + get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' } | ||
41 | + } | ||
42 | + | ||
43 | + it 'logs HTTP_REMOTE_USER in' do | ||
44 | + expect(last_response.status).to eq(302) | ||
45 | + expect(last_response['Set-Cookie']).to include('_remote_user=foobar') | ||
46 | + expect(last_response['Set-Cookie']).to include('path=') | ||
47 | + end | ||
48 | + end | ||
49 | + | ||
50 | + context 'With HTTP_REMOTE_USER, logged in and current user equals HTTP_REMOTE_USER' do | ||
51 | + before(:each){ | ||
52 | + clear_cookies | ||
53 | + set_cookie "_remote_user=foobar" | ||
54 | + get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar' } | ||
55 | + } | ||
56 | + | ||
57 | + it 'Do nothing' do | ||
58 | + expect(last_request.cookies['_remote_user']).to eq('foobar') | ||
59 | + expect(last_response.status).to eq(200) | ||
60 | + expect(last_response['Set-Cookie']).to eq(nil) | ||
61 | + end | ||
62 | + end | ||
63 | + | ||
64 | + context 'With HTTP_REMOTE_USER, logged in and current user not equals HTTP_REMOTE_USER' do | ||
65 | + before(:each){ | ||
66 | + clear_cookies | ||
67 | + set_cookie "_remote_user=foobar" | ||
68 | + get '/', {}, { 'HTTP_REMOTE_USER' => 'foobar2' } | ||
69 | + } | ||
70 | + | ||
71 | + it 'Logout current user and login HTTP_REMOTE_USER' do | ||
72 | + expect(last_request.cookies['_remote_user']).to eq('foobar') | ||
73 | + expect(last_response.status).to eq(302) | ||
74 | + end | ||
75 | + end | ||
76 | + | ||
77 | + context 'Verify omniauth hash with HTTP_REMOTE_USER_DATA' do | ||
78 | + before(:each){ | ||
79 | + clear_cookies | ||
80 | + set_cookie "_remote_user=foobar" | ||
81 | + post '/auth/RemoteUser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar', | ||
82 | + 'HTTP_REMOTE_USER_DATA' => JSON.dump({'name' => 'foobar barfoo', 'email' => 'foobar@test.com'})} | ||
83 | + } | ||
84 | + | ||
85 | + it 'Verify uid' do | ||
86 | + expect(last_request.env['omniauth.auth']['uid']).to eq('foobar') | ||
87 | + end | ||
88 | + | ||
89 | + it 'Verify info' do | ||
90 | + expect(last_request.env['omniauth.auth']['info']['nickname']).to eq('foobar') | ||
91 | + expect(last_request.env['omniauth.auth']['info']['email']).to eq('foobar@test.com') | ||
92 | + expect(last_request.env['omniauth.auth']['info']['lastname']).to eq('barfoo') | ||
93 | + expect(last_request.env['omniauth.auth']['info']['firstname']).to eq('foobar') | ||
94 | + end | ||
95 | + end | ||
96 | + | ||
97 | + context 'Verify omniauth.auth info without HTTP_REMOTE_USER_DATA' do | ||
98 | + before(:each){ | ||
99 | + clear_cookies | ||
100 | + set_cookie "_remote_user=foobar" | ||
101 | + post '/auth/RemoteUser/callback', {}, { 'HTTP_REMOTE_USER' => 'foobar' } | ||
102 | + } | ||
103 | + | ||
104 | + it 'Verify uid' do | ||
105 | + expect(last_request.env['omniauth.auth']['uid']).to eq('foobar') | ||
106 | + end | ||
107 | + | ||
108 | + it 'Verify info' do | ||
109 | + expect(last_request.env['omniauth.auth']['info']).to eq({}) | ||
110 | + end | ||
111 | + end | ||
112 | + | ||
113 | + context 'With HTTP_REMOTE_USER and ' do | ||
114 | + before(:each){ | ||
115 | + set_cookie "_remote_user=foobar" | ||
116 | + get "auth/RemoteUser", {}, { 'HTTP_REMOTE_USER' => 'foobar' } | ||
117 | + } | ||
118 | + | ||
119 | + it 'redirect for callback' do | ||
120 | + expect(last_response.status).to eq(302) | ||
121 | + expect(last_response.location).to eq("/auth/RemoteUser/callback") | ||
122 | + end | ||
123 | + end | ||
118 | 124 | ||
125 | +end |
@@ -18,7 +18,7 @@ require 'omniauth/test' | @@ -18,7 +18,7 @@ require 'omniauth/test' | ||
18 | Bundler.setup :default, :development, :test | 18 | Bundler.setup :default, :development, :test |
19 | 19 | ||
20 | require 'rack/test' | 20 | require 'rack/test' |
21 | -require 'omniauth/remote_user' | 21 | +require 'omniauth/remote-user' |
22 | 22 | ||
23 | RSpec.configure do |config| | 23 | RSpec.configure do |config| |
24 | config.include Rack::Test::Methods | 24 | config.include Rack::Test::Methods |
-
I don't see the login cookie being deleted ... will this even work?
-
The login cookie from rails is deleted when the request.session.clear is called.
-
ah, ok
37 | 36 | |
38 | 37 | def __logout(env) |
39 | 38 | request = Rack::Request.new(env) |
40 | - response = redirect_if_not_logging_in(request, request.path) | |
39 | + request.session.clear | |
40 | + response = redirect_if_not_logging_in(request, request.path ) | |
41 | 41 | if response |
42 | - response.delete_cookie(options.cookie) | |
43 | - response.delete_cookie(options.internal_cookie) | |
44 | - response | |
42 | + response.delete_cookie(options.internal_cookie , path: "#{request.script_name}" ) | |
3 |
|