casino 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- casino (0.0.2)
5
- casino_core (~> 1.0)
4
+ casino (0.0.3)
5
+ casino_core (~> 1.1.0)
6
6
  jquery-rails (~> 2.1)
7
7
  rails (~> 3.2.9)
8
8
 
@@ -39,16 +39,17 @@ GEM
39
39
  addressable (2.3.2)
40
40
  arel (3.0.2)
41
41
  builder (3.0.4)
42
- casino_core (1.0.12)
42
+ casino_core (1.1.0)
43
43
  activerecord (~> 3.2.9)
44
44
  addressable (~> 2.3)
45
+ terminal-table (~> 1.4)
45
46
  useragent (~> 0.4)
46
47
  diff-lcs (1.1.3)
47
48
  erubis (2.7.0)
48
49
  hike (1.2.1)
49
50
  i18n (0.6.1)
50
51
  journey (1.0.4)
51
- jquery-rails (2.1.4)
52
+ jquery-rails (2.2.0)
52
53
  railties (>= 3.0, < 5.0)
53
54
  thor (>= 0.14, < 2.0)
54
55
  json (1.7.6)
@@ -91,8 +92,8 @@ GEM
91
92
  rspec-core (2.12.2)
92
93
  rspec-expectations (2.12.1)
93
94
  diff-lcs (~> 1.1.3)
94
- rspec-mocks (2.12.1)
95
- rspec-rails (2.12.0)
95
+ rspec-mocks (2.12.2)
96
+ rspec-rails (2.12.2)
96
97
  actionpack (>= 3.0)
97
98
  activesupport (>= 3.0)
98
99
  railties (>= 3.0)
@@ -108,14 +109,15 @@ GEM
108
109
  multi_json (~> 1.0)
109
110
  rack (~> 1.0)
110
111
  tilt (~> 1.1, != 1.3.0)
111
- sqlite3 (1.3.6)
112
+ sqlite3 (1.3.7)
113
+ terminal-table (1.4.5)
112
114
  thor (0.17.0)
113
115
  tilt (1.3.3)
114
116
  treetop (1.4.12)
115
117
  polyglot
116
118
  polyglot (>= 0.3.1)
117
119
  tzinfo (0.3.35)
118
- useragent (0.4.15)
120
+ useragent (0.4.16)
119
121
 
120
122
  PLATFORMS
121
123
  ruby
@@ -36,6 +36,10 @@ class CASino::API::V1::TicketsController < CASino::ApplicationController
36
36
  error_response
37
37
  end
38
38
 
39
+ def service_not_allowed_via_api
40
+ error_response
41
+ end
42
+
39
43
  def user_logged_out_via_api
40
44
  render nothing: true, status: 200
41
45
  end
@@ -10,7 +10,7 @@ class CASino::SessionsController < CASino::ApplicationController
10
10
  end
11
11
 
12
12
  def create
13
- processor(:LoginCredentialAcceptor).process(params, cookies, request.user_agent)
13
+ processor(:LoginCredentialAcceptor).process(params, request.user_agent)
14
14
  end
15
15
 
16
16
  def destroy
@@ -0,0 +1,4 @@
1
+ <h1>Service not allowed</h1>
2
+ <p>
3
+ This SSO server is not configured to allow logins to "<%= @service %>". If you think this is an error, please contact your administrator.
4
+ </p>
data/casino.gemspec CHANGED
@@ -25,5 +25,5 @@ Gem::Specification.new do |s|
25
25
 
26
26
  s.add_runtime_dependency 'rails', '~> 3.2.9'
27
27
  s.add_runtime_dependency 'jquery-rails', '~> 2.1'
28
- s.add_runtime_dependency 'casino_core', '~> 1.0'
28
+ s.add_runtime_dependency 'casino_core', '~> 1.1.0'
29
29
  end
@@ -20,6 +20,11 @@ class CASino::Listener::LoginCredentialAcceptor < CASino::Listener
20
20
  rerender_login_page(login_ticket)
21
21
  end
22
22
 
23
+ def service_not_allowed(service)
24
+ assign(:service, service)
25
+ @controller.render 'service_not_allowed', status: 403
26
+ end
27
+
23
28
  private
24
29
  def rerender_login_page(login_ticket)
25
30
  assign(:login_ticket, login_ticket)
@@ -6,6 +6,11 @@ class CASino::Listener::LoginCredentialRequestor < CASino::Listener
6
6
  @controller.cookies.delete :tgt
7
7
  end
8
8
 
9
+ def service_not_allowed(service)
10
+ assign(:service, service)
11
+ @controller.render 'service_not_allowed', status: 403
12
+ end
13
+
9
14
  def user_logged_in(url)
10
15
  if url.nil?
11
16
  @controller.redirect_to sessions_path
@@ -1,3 +1,3 @@
1
1
  module CASino
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -31,6 +31,20 @@ describe CASino::API::V1::TicketsController do
31
31
  subject { response }
32
32
  its(:response_code) { should eq 400 }
33
33
  end
34
+
35
+ context "with a not allowed service" do
36
+
37
+ before do
38
+ CASinoCore::Processor::API::LoginCredentialAcceptor.any_instance.should_receive(:process) do
39
+ @controller.service_not_allowed_via_api
40
+ end
41
+
42
+ post :create, params: {username: 'example', password: 'example'}
43
+ end
44
+
45
+ subject { response }
46
+ its(:response_code) { should eq 400 }
47
+ end
34
48
  end
35
49
 
36
50
  describe "POST /cas/v1/tickets/{TGT id}" do
@@ -59,4 +59,22 @@ describe CASino::Listener::LoginCredentialAcceptor do
59
59
  end
60
60
  end
61
61
  end
62
+
63
+ context '#service_not_allowed' do
64
+ let(:service) { 'http://www.example.com/foo' }
65
+
66
+ before(:each) do
67
+ controller.stub(:render)
68
+ end
69
+
70
+ it 'tells the controller to render the service_not_allowed template' do
71
+ controller.should_receive(:render).with('service_not_allowed', status: 403)
72
+ listener.send(:service_not_allowed, service)
73
+ end
74
+
75
+ it 'assigns the not allowed service' do
76
+ listener.send(:service_not_allowed, service)
77
+ controller.instance_variable_get(:@service).should == service
78
+ end
79
+ end
62
80
  end
@@ -36,4 +36,22 @@ describe CASino::Listener::LoginCredentialRequestor do
36
36
  end
37
37
  end
38
38
  end
39
+
40
+ context '#service_not_allowed' do
41
+ let(:service) { 'http://www.example.com/foo' }
42
+
43
+ before(:each) do
44
+ controller.stub(:render)
45
+ end
46
+
47
+ it 'tells the controller to render the service_not_allowed template' do
48
+ controller.should_receive(:render).with('service_not_allowed', status: 403)
49
+ listener.send(:service_not_allowed, service)
50
+ end
51
+
52
+ it 'assigns the not allowed service' do
53
+ listener.send(:service_not_allowed, service)
54
+ controller.instance_variable_get(:@service).should == service
55
+ end
56
+ end
39
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: '1.0'
133
+ version: 1.1.0
134
134
  type: :runtime
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +138,7 @@ dependencies:
138
138
  requirements:
139
139
  - - ~>
140
140
  - !ruby/object:Gem::Version
141
- version: '1.0'
141
+ version: 1.1.0
142
142
  description: CASino is a simple CAS (Central Authentication Service) server using
143
143
  CASinoCore as its backend.
144
144
  email:
@@ -173,6 +173,7 @@ files:
173
173
  - app/views/casino/sessions/index.html.erb
174
174
  - app/views/casino/sessions/logout.html.erb
175
175
  - app/views/casino/sessions/new.html.erb
176
+ - app/views/casino/sessions/service_not_allowed.html.erb
176
177
  - app/views/layouts/application.html.erb
177
178
  - casino.gemspec
178
179
  - config/.gitignore
@@ -277,7 +278,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
277
278
  version: '0'
278
279
  segments:
279
280
  - 0
280
- hash: 2327405662776558118
281
+ hash: 2543265175021686612
281
282
  required_rubygems_version: !ruby/object:Gem::Requirement
282
283
  none: false
283
284
  requirements:
@@ -286,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
287
  version: '0'
287
288
  segments:
288
289
  - 0
289
- hash: 2327405662776558118
290
+ hash: 2543265175021686612
290
291
  requirements: []
291
292
  rubyforge_project:
292
293
  rubygems_version: 1.8.24