shibbolite 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +108 -0
- data/Rakefile +21 -0
- data/app/concerns/shibbolite/filters.rb +44 -0
- data/app/concerns/shibbolite/helpers.rb +48 -0
- data/app/concerns/shibbolite/user.rb +21 -0
- data/app/controllers/shibbolite/shibboleth_controller.rb +53 -0
- data/app/views/layouts/shibbolite/shibboleth.html.erb +32 -0
- data/app/views/shibbolite/shibboleth/access_denied.html.erb +7 -0
- data/app/views/shibbolite/shibboleth/logout_message.html.erb +7 -0
- data/config/routes.rb +6 -0
- data/lib/generators/shibbolite/install_generator.rb +17 -0
- data/lib/generators/shibbolite/migration_generator.rb +14 -0
- data/lib/generators/templates/shibbolite_config.rb +51 -0
- data/lib/shibbolite/engine.rb +13 -0
- data/lib/shibbolite/version.rb +3 -0
- data/lib/shibbolite.rb +58 -0
- data/spec/controllers/filters_test_controller_spec.rb +146 -0
- data/spec/controllers/helpers_test_controller_spec.rb +146 -0
- data/spec/controllers/shibbolite/shibboleth_controller_spec.rb +114 -0
- data/spec/controllers/static_controller_spec.rb +5 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/filters_test_controller.rb +37 -0
- data/spec/dummy/app/controllers/helpers_test_controller.rb +44 -0
- data/spec/dummy/app/controllers/static_controller.rb +21 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/views/filters_test/dummy.html.erb +0 -0
- data/spec/dummy/app/views/helpers_test/dummy.html.erb +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/static/admin_resource.html.erb +3 -0
- data/spec/dummy/app/views/static/home.html.erb +35 -0
- data/spec/dummy/app/views/static/user_resource.html.erb +5 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +17 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/shibbolite_config.rb +51 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20140404162119_create_users.rb +9 -0
- data/spec/dummy/db/migrate/20140414172304_add_shibboleth_attributes_to_users.rb +12 -0
- data/spec/dummy/db/schema.rb +30 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +19082 -0
- data/spec/dummy/log/test.log +46778 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1be2f6345400afa38cfd6c919f2cf297 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/27c12eb9977c123bfb2ef83640964c02 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/35634bbec2c7419d3efa1a72c23db7e0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/368329c663775348c7db5500ff959f80 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/83de9c3d672e9a3420dd8a36aaaab517 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/factories/shibboleth_attributes.rb +28 -0
- data/spec/factories/users.rb +13 -0
- data/spec/models/user_spec.rb +46 -0
- data/spec/spec_helper.rb +32 -0
- metadata +320 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# The HelpersTest controller is a dummy used to test
|
4
|
+
# the Shibbolite::Helpers concern
|
5
|
+
describe HelpersTestController do
|
6
|
+
|
7
|
+
# helper methods
|
8
|
+
#
|
9
|
+
|
10
|
+
describe '#current_user' do
|
11
|
+
|
12
|
+
context 'when session is loaded' do
|
13
|
+
|
14
|
+
let(:user) { FactoryGirl.build_stubbed(:user) }
|
15
|
+
|
16
|
+
before do
|
17
|
+
session[Shibbolite.pid] = 'someone'
|
18
|
+
allow(Shibbolite.user_class).to receive(:find_user).and_return(user)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'fetches the user from the db' do
|
22
|
+
get :_current_user
|
23
|
+
expect(assigns(:current_user)).to eq(user)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when no session is loaded' do
|
28
|
+
it 'returns nil' do
|
29
|
+
get :_current_user
|
30
|
+
expect(assigns(:current_user)).to be_nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#logged_in?' do
|
36
|
+
|
37
|
+
context 'when session not loaded' do
|
38
|
+
it 'is false' do
|
39
|
+
session[Shibbolite.pid] = nil
|
40
|
+
get :_logged_in?
|
41
|
+
expect(assigns(:logged_in)).to be_false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'when session is loaded' do
|
46
|
+
it 'is true' do
|
47
|
+
session[Shibbolite.pid] = 'SSO authenticated'
|
48
|
+
get :_logged_in?
|
49
|
+
expect(assigns(:logged_in)).to be_true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#anonymous_user?' do
|
55
|
+
|
56
|
+
context 'when session is not loaded' do
|
57
|
+
it 'is true' do
|
58
|
+
session[Shibbolite.pid] = nil
|
59
|
+
get :_anonymous_user?
|
60
|
+
expect(assigns(:anonymous)).to be_true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context 'when a session is loaded' do
|
65
|
+
it 'is false' do
|
66
|
+
session[Shibbolite.pid] = 'SSO authenticated'
|
67
|
+
get :_anonymous_user?
|
68
|
+
expect(assigns(:anonymous)).to be_false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe '#guest_user?' do
|
74
|
+
|
75
|
+
context 'when a session is loaded and current_user is nil' do
|
76
|
+
it 'is true' do
|
77
|
+
session[Shibbolite.pid] = 'SSO authenticated'
|
78
|
+
allow(subject).to receive(:current_user).and_return(nil)
|
79
|
+
get :_guest_user?
|
80
|
+
expect(assigns(:guest)).to be_true
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'with any other background' do
|
85
|
+
it 'is false' do
|
86
|
+
session[Shibbolite.pid] = nil
|
87
|
+
allow(subject).to receive(:current_user).and_return(nil)
|
88
|
+
get :_guest_user?
|
89
|
+
expect(assigns(:guest)).to be_false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#registered_user?' do
|
95
|
+
|
96
|
+
context 'when the user exists in the database' do
|
97
|
+
it 'is true' do
|
98
|
+
allow(subject).to receive(:current_user).and_return('A valid user')
|
99
|
+
get :_registered_user?
|
100
|
+
expect(assigns(:registered)).to be_true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'when the user does not exist in the database' do
|
105
|
+
it 'is false' do
|
106
|
+
allow(subject).to receive(:current_user).and_return(nil)
|
107
|
+
get :_registered_user?
|
108
|
+
expect(assigns(:registered)).to be_false
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#user_in_group?' do
|
114
|
+
|
115
|
+
let(:user) { double(group: 'jedi') }
|
116
|
+
|
117
|
+
before { allow(subject).to receive(:current_user).and_return(user) }
|
118
|
+
|
119
|
+
it 'is true when user is in group' do
|
120
|
+
get :_user_in_group?, group: 'jedi'
|
121
|
+
expect(assigns(:result)).to be_true
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'is false when user is not in group' do
|
125
|
+
get :_user_in_group?, group: 'sith'
|
126
|
+
expect(assigns(:result)).to be_false
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '#user_id_match?' do
|
131
|
+
|
132
|
+
let(:user) { double(id: 17) }
|
133
|
+
|
134
|
+
before { allow(subject).to receive(:current_user).and_return(user) }
|
135
|
+
|
136
|
+
it 'is true when user has the id' do
|
137
|
+
get :_user_has_id?, id: '17'
|
138
|
+
expect(assigns(:result)).to be_true
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'is false when user does not have the id' do
|
142
|
+
get :_user_has_id?, id: '23'
|
143
|
+
expect(assigns(:result)).to be_false
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Shibbolite
|
4
|
+
describe ShibbolethController do
|
5
|
+
|
6
|
+
describe '#access_denied' do
|
7
|
+
before do
|
8
|
+
session[:requested_url] = '/Narnia'
|
9
|
+
get :access_denied
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'assigns the requested url' do
|
13
|
+
expect(assigns(:requested_url)).to eq('/Narnia')
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'renders' do
|
17
|
+
expect(response).to render_template :access_denied
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#login' do
|
22
|
+
context 'session loaded successfully' do
|
23
|
+
before do
|
24
|
+
allow(subject).to receive(:logged_in?).and_return true
|
25
|
+
session[:requested_url] = '/Hoth'
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'redirects back to original action' do
|
29
|
+
get :login
|
30
|
+
expect(response).to redirect_to '/Hoth'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'no shibboleth session' do
|
35
|
+
it 'redirects to the SP for authentication' do
|
36
|
+
get :login
|
37
|
+
expect(response).to redirect_to subject.send(:sp_login_url)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#logout' do
|
43
|
+
it 'deletes the session user id' do
|
44
|
+
session[Shibbolite.pid] = 'Han Solo'
|
45
|
+
get :logout
|
46
|
+
expect(session[Shibbolite.pid]).to be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'redirects to the SP for logout' do
|
50
|
+
get :logout
|
51
|
+
expect(response).to redirect_to subject.send(:sp_logout_url)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#logout_message' do
|
56
|
+
subject { get :logout_message }
|
57
|
+
it { should render_template :logout_message }
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'methods that require the environment hash' do
|
61
|
+
|
62
|
+
let!(:environment) { FactoryGirl.build(:environment_hash).with_indifferent_access }
|
63
|
+
let(:attributes) { FactoryGirl.build(:shibboleth_attributes).with_indifferent_access }
|
64
|
+
let!(:user) { FactoryGirl.build_stubbed(:user) }
|
65
|
+
|
66
|
+
before do
|
67
|
+
allow(request).to receive(:env).and_return(environment)
|
68
|
+
allow(Shibbolite.user_class).to receive(:find_user).and_return(user)
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#load_session' do
|
72
|
+
|
73
|
+
before { allow(user).to receive(:update) }
|
74
|
+
|
75
|
+
context 'when user authenticated with sso' do
|
76
|
+
|
77
|
+
before { subject.send(:load_session) }
|
78
|
+
|
79
|
+
it 'sets user\'s primary key (primary_user_id) in session' do
|
80
|
+
expect(session[Shibbolite.pid]).to eq(environment[Shibbolite.pid])
|
81
|
+
end
|
82
|
+
|
83
|
+
it "updates the user's shibboleth attributes" do
|
84
|
+
expect(user).to have_received(:update).with(attributes)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when user is not authenticated with sso' do
|
89
|
+
|
90
|
+
before do
|
91
|
+
environment[Shibbolite.pid] = nil
|
92
|
+
subject.send(:load_session)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'sets no session id' do
|
96
|
+
expect(session[Shibbolite.pid]).to be_nil
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'does not update user attributes' do
|
100
|
+
expect(user).not_to have_received(:update)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#get_attributes' do
|
106
|
+
|
107
|
+
it 'returns a hash of shibboleth attributes' do
|
108
|
+
attrs = subject.send(:get_attributes)
|
109
|
+
expect(attrs).to eq(attributes)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,56 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
div.field, div.actions {
|
20
|
+
margin-bottom: 10px;
|
21
|
+
}
|
22
|
+
|
23
|
+
#notice {
|
24
|
+
color: green;
|
25
|
+
}
|
26
|
+
|
27
|
+
.field_with_errors {
|
28
|
+
padding: 2px;
|
29
|
+
background-color: red;
|
30
|
+
display: table;
|
31
|
+
}
|
32
|
+
|
33
|
+
#error_explanation {
|
34
|
+
width: 450px;
|
35
|
+
border: 2px solid red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 0;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#error_explanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
margin-bottom: 0px;
|
49
|
+
background-color: #c00;
|
50
|
+
color: #fff;
|
51
|
+
}
|
52
|
+
|
53
|
+
#error_explanation ul li {
|
54
|
+
font-size: 12px;
|
55
|
+
list-style: square;
|
56
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# a dummy controller for testing the Shibbolite::Filters concern
|
2
|
+
|
3
|
+
class FiltersTestController < ApplicationController
|
4
|
+
|
5
|
+
include Shibbolite::Filters
|
6
|
+
|
7
|
+
before_action :require_login, only: :_require_login
|
8
|
+
before_action :require_registered, only: :_require_registered
|
9
|
+
before_action(only: :_require_group) { |c| c.require_group params[:groups] }
|
10
|
+
before_action(only: :_require_id) { |c| c.require_id params[:id].to_i }
|
11
|
+
before_action(only: :_require_group_or_id) { |c| c.require_group_or_id params[:groups], params[:id].to_i }
|
12
|
+
before_action :use_attributes_if_available, only: :_use_attributes_if_available
|
13
|
+
|
14
|
+
def _require_login
|
15
|
+
render :dummy
|
16
|
+
end
|
17
|
+
|
18
|
+
def _require_registered
|
19
|
+
render :dummy
|
20
|
+
end
|
21
|
+
|
22
|
+
def _require_group
|
23
|
+
render :dummy
|
24
|
+
end
|
25
|
+
|
26
|
+
def _require_id
|
27
|
+
render :dummy
|
28
|
+
end
|
29
|
+
|
30
|
+
def _require_group_or_id
|
31
|
+
render :dummy
|
32
|
+
end
|
33
|
+
|
34
|
+
def _use_attributes_if_available
|
35
|
+
render :dummy
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# a dummy controller for testing the Shibbolite::Helpers concern
|
2
|
+
# because real isolation testing was too much of a pain in the neck
|
3
|
+
|
4
|
+
class HelpersTestController < ApplicationController
|
5
|
+
|
6
|
+
include Shibbolite::Helpers
|
7
|
+
|
8
|
+
# helpers
|
9
|
+
|
10
|
+
def _current_user
|
11
|
+
current_user
|
12
|
+
render :dummy
|
13
|
+
end
|
14
|
+
|
15
|
+
def _logged_in?
|
16
|
+
@logged_in = logged_in?
|
17
|
+
render :dummy
|
18
|
+
end
|
19
|
+
|
20
|
+
def _anonymous_user?
|
21
|
+
@anonymous = anonymous_user?
|
22
|
+
render :dummy
|
23
|
+
end
|
24
|
+
|
25
|
+
def _guest_user?
|
26
|
+
@guest = guest_user?
|
27
|
+
render :dummy
|
28
|
+
end
|
29
|
+
|
30
|
+
def _registered_user?
|
31
|
+
@registered = registered_user?
|
32
|
+
render :dummy
|
33
|
+
end
|
34
|
+
|
35
|
+
def _user_in_group?
|
36
|
+
@result = user_in_group?(params[:group].to_sym)
|
37
|
+
render :dummy
|
38
|
+
end
|
39
|
+
|
40
|
+
def _user_has_id?
|
41
|
+
@result = user_has_id?(params[:id].to_i)
|
42
|
+
render :dummy
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class StaticController < ApplicationController
|
2
|
+
|
3
|
+
include Shibbolite::Filters
|
4
|
+
|
5
|
+
before_action :use_attributes_if_available, only: :home
|
6
|
+
before_action(only: :user_resource) { |c| c.require_group(:admin, :user) }
|
7
|
+
before_action(only: :admin_resource) { |c| c.require_group(:admin) }
|
8
|
+
|
9
|
+
def home
|
10
|
+
end
|
11
|
+
|
12
|
+
def user_resource
|
13
|
+
@user_data = 'Available to all users'
|
14
|
+
@admin_data = 'Available to admins' if user_in_group?(:admin)
|
15
|
+
end
|
16
|
+
|
17
|
+
def admin_resource
|
18
|
+
@admin_data = 'Available to admins'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<h1>Home</h1>
|
2
|
+
|
3
|
+
<h1>Testing helper methods</h1>
|
4
|
+
|
5
|
+
<% if logged_in? %>
|
6
|
+
<p>User is logged in</p>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% if anonymous_user? %>
|
10
|
+
<p>User is anonymous (not signed in to SSO)</p>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% if guest_user? %>
|
14
|
+
<p>User is a guest (signed in to SSO but not registered)</p>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<% if registered_user? %>
|
18
|
+
<p>User is registered with application</p>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% unless current_user.nil? %>
|
22
|
+
<p>User is in <%= current_user.group %> group</p>
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
<p>
|
26
|
+
<%= link_to 'Users only', controller: :static, action: :user_resource %>
|
27
|
+
<%= link_to 'Admins only', controller: :static, action: :admin_resource %>
|
28
|
+
</p>
|
29
|
+
|
30
|
+
<p>
|
31
|
+
<%= link_to 'Login', shibbolite.login_path %>
|
32
|
+
<%= link_to 'Logout', shibbolite.logout_path %>
|
33
|
+
</p>
|
34
|
+
|
35
|
+
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "sprockets/railtie"
|
8
|
+
|
9
|
+
Bundler.require(*Rails.groups)
|
10
|
+
require "shibbolite"
|
11
|
+
|
12
|
+
module Dummy
|
13
|
+
class Application < Rails::Application
|
14
|
+
I18n.config.enforce_available_locales = false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Dummy::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# In the development environment your application's code is reloaded on
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
7
|
+
config.cache_classes = false
|
8
|
+
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
|
+
|
12
|
+
# Show full error reports and disable caching.
|
13
|
+
config.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send.
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
18
|
+
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
|
+
config.active_support.deprecation = :log
|
21
|
+
|
22
|
+
# Raise an error on page load if there are pending migrations
|
23
|
+
config.active_record.migration_error = :page_load
|
24
|
+
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
27
|
+
# number of complex assets.
|
28
|
+
config.assets.debug = true
|
29
|
+
end
|