ddr-models 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d6dc7a5d5bb5df96bd40adf20c437fbb22e7a96
4
- data.tar.gz: 7a630a51f88806880c2d0ced9e7efa6c91f26719
3
+ metadata.gz: 47da234ecb43f36fb0eb336d31519cddf290a207
4
+ data.tar.gz: ff7d195e23915f0e127161c01f24d2044dc879d2
5
5
  SHA512:
6
- metadata.gz: 9b6b2554e5dbea6205588dab1849c83e0f1f1878da663b8b4e3993d65fa547a57f85fb3db6e8ce723e7012f253ce4d2b542316c1b3053dd1ece270dbf2bbf1de
7
- data.tar.gz: 8dcad69b15fe3dea3ba36393f8c5c374730bdcd9686c2acdf16c519d2f22843198b9fad41edef34c96642bd7f2e09fb42927e24674b0ac3478f64f0f9d266e28
6
+ metadata.gz: 3c435826a74310c1e70f2b8edf46569727edd0939a5863519bbe858a44313b1fb01dfdfd8cecb63d86399fc23e16205b80c634f73e4177c50d7ba1034fbdb2b4
7
+ data.tar.gz: dfce4af10755852dea51a93ebbed93b31aeef6f3b3b5672bfe5171a0cdd88c6b3b836752efaecee5e6b7c2a5419f9c82a9e8b4a37e0c6d0616cea18442fb92f0
@@ -2,10 +2,14 @@ require "devise/omniauth_callbacks_controller"
2
2
 
3
3
  class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
4
4
 
5
- # Shibboleth callback
6
5
  def shibboleth
7
- @user = resource_class.from_omniauth(request.env["omniauth.auth"])
8
- sign_in_and_redirect @user
6
+ user = resource_class.from_omniauth(request.env["omniauth.auth"])
7
+ set_flash_message :notice, :success, kind: "Duke NetID"
8
+ sign_in_and_redirect user
9
+ end
10
+
11
+ def after_sign_in_path_for(resource)
12
+ request.env["omniauth.origin"] || super
9
13
  end
10
14
 
11
15
  end
@@ -1,7 +1,17 @@
1
1
  class Users::SessionsController < Devise::SessionsController
2
2
 
3
+ def new
4
+ if Ddr::Auth.require_shib_user_authn
5
+ redirect_to user_omniauth_authorize_path(:shibboleth, origin: request.referrer)
6
+ else
7
+ store_location_for(:user, request.referrer)
8
+ super
9
+ end
10
+ end
11
+
3
12
  def after_sign_out_path_for(scope)
4
- user_signed_out_path
13
+ return Ddr::Auth.sso_logout_url if Ddr::Auth.require_shib_user_authn
14
+ super
5
15
  end
6
16
 
7
17
  end
@@ -0,0 +1,22 @@
1
+ <h2>Login</h2>
2
+
3
+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4
+ <div class="form-group">
5
+ <%= f.label :username %>
6
+ <%= f.text_field :username %>
7
+ </div>
8
+ <div class="form-group">
9
+ <%= f.label :password %>
10
+ <%= f.password_field :password %>
11
+ </div>
12
+ <% if devise_mapping.rememberable? -%>
13
+ <div class="form-group">
14
+ <%= f.check_box :remember_me %> <%= f.label :remember_me %>
15
+ </div>
16
+ <% end -%>
17
+ <div>
18
+ <%= f.submit "Login" %>
19
+ </div>
20
+ <% end %>
21
+
22
+ <%= render "devise/shared/links" %>
@@ -0,0 +1,9 @@
1
+ <%- if controller_name != 'sessions' %>
2
+ <%= link_to "Login", new_session_path(resource_name) %><br />
3
+ <% end -%>
4
+
5
+ <%- if devise_mapping.omniauthable? %>
6
+ <%- resource_class.omniauth_providers.each do |provider| %>
7
+ <%= link_to "Login with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
8
+ <% end -%>
9
+ <% end -%>
@@ -238,7 +238,6 @@ Devise.setup do |config|
238
238
  # end
239
239
 
240
240
  config.warden do |manager|
241
- manager.failure_app = Ddr::Auth::FailureApp
242
241
  # :superuser scope
243
242
  manager.serialize_into_session(:superuser) { |superuser| superuser.id }
244
243
  manager.serialize_from_session(:superuser) { |id| Devise.mappings[:user].to.find(id) }
@@ -1,6 +1,3 @@
1
1
  Rails.application.routes.draw do
2
2
  devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks", sessions: "users/sessions" }
3
- devise_scope :user do
4
- get "/users/signed_out", to: redirect("/"), as: "user_signed_out"
5
- end
6
3
  end
@@ -8,7 +8,6 @@ module Ddr
8
8
  autoload :GroupService
9
9
  autoload :GrouperService
10
10
  autoload :RemoteGroupService
11
- autoload :FailureApp
12
11
 
13
12
  # Group authorized to act as superuser
14
13
  mattr_accessor :superuser_group
@@ -52,5 +51,9 @@ module Ddr
52
51
  false
53
52
  end
54
53
 
54
+ mattr_accessor :sso_logout_url do
55
+ "/Shibboleth.sso/Logout?return=https://shib.oit.duke.edu/cgi-bin/logout.pl"
56
+ end
57
+
55
58
  end
56
59
  end
@@ -1,5 +1,5 @@
1
1
  module Ddr
2
2
  module Models
3
- VERSION = "1.10.0"
3
+ VERSION = "1.11.0"
4
4
  end
5
5
  end
@@ -0,0 +1,25 @@
1
+ RSpec.describe Users::SessionsController, type: :controller do
2
+
3
+ before { request.env["devise.mapping"] = Devise.mappings[:user] }
4
+
5
+ describe "#new" do
6
+ before { request.env["HTTP_REFERER"] = "/foo/bar" }
7
+ describe "when shibboleth user authentication is required" do
8
+ before { allow(Ddr::Auth).to receive(:require_shib_user_authn) { true } }
9
+ it "should redirect to the shib authn path, setting the origin to the previous page" do
10
+ get :new
11
+ expect(response).to redirect_to(user_omniauth_authorize_path(:shibboleth, origin: "/foo/bar"))
12
+ end
13
+ end
14
+
15
+ describe "when shibboleth user authentication is NOT required" do
16
+ before { allow(Ddr::Auth).to receive(:require_shib_user_authn) { false } }
17
+ it "should store the location of the previous page and render the 'new' template" do
18
+ expect(subject).to receive(:store_location_for).with(:user, "/foo/bar")
19
+ get :new
20
+ expect(response).to render_template(:new)
21
+ end
22
+ end
23
+ end
24
+
25
+ end
@@ -17,10 +17,4 @@ RSpec.describe "users router", type: :routing do
17
17
  it "should have a shibboleth authentication path helper" do
18
18
  expect(get: user_omniauth_authorize_path(:shibboleth)).to route_to(controller: 'users/omniauth_callbacks', action: 'passthru', provider: 'shibboleth')
19
19
  end
20
- describe "redirects", type: :request do
21
- it "should have a signed out path" do
22
- get '/users/signed_out'
23
- expect(response).to redirect_to('/')
24
- end
25
- end
26
20
  end
@@ -15,6 +15,8 @@ require "resque"
15
15
 
16
16
  Resque.inline = true
17
17
 
18
+ OmniAuth.config.test_mode = true
19
+
18
20
  Dir[File.join(File.dirname(__FILE__), "support", "*.rb")].each { |f| require f }
19
21
 
20
22
  DatabaseCleaner.strategy = :truncation
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-06 00:00:00.000000000 Z
12
+ date: 2015-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -294,6 +294,8 @@ files:
294
294
  - app/models/component.rb
295
295
  - app/models/item.rb
296
296
  - app/models/target.rb
297
+ - app/views/devise/sessions/new.html.erb
298
+ - app/views/devise/shared/_links.erb
297
299
  - config/initializers/active_fedora_base.rb
298
300
  - config/initializers/active_fedora_datastream.rb
299
301
  - config/initializers/devise.rb
@@ -314,7 +316,6 @@ files:
314
316
  - lib/ddr/actions/fixity_check.rb
315
317
  - lib/ddr/auth.rb
316
318
  - lib/ddr/auth/ability.rb
317
- - lib/ddr/auth/failure_app.rb
318
319
  - lib/ddr/auth/group_service.rb
319
320
  - lib/ddr/auth/grouper_service.rb
320
321
  - lib/ddr/auth/remote_group_service.rb
@@ -377,7 +378,7 @@ files:
377
378
  - lib/ddr/vocab.rb
378
379
  - lib/ddr/vocab/asset.rb
379
380
  - lib/ddr/vocab/roles.rb
380
- - spec/controllers/application_controller_spec.rb
381
+ - spec/controllers/users/sessions_controller_spec.rb
381
382
  - spec/dummy/README.rdoc
382
383
  - spec/dummy/Rakefile
383
384
  - spec/dummy/app/assets/javascripts/application.js
@@ -488,7 +489,7 @@ signing_key:
488
489
  specification_version: 4
489
490
  summary: Models used in the Duke Digital Repository
490
491
  test_files:
491
- - spec/controllers/application_controller_spec.rb
492
+ - spec/controllers/users/sessions_controller_spec.rb
492
493
  - spec/dummy/app/assets/javascripts/application.js
493
494
  - spec/dummy/app/assets/stylesheets/application.css
494
495
  - spec/dummy/app/controllers/application_controller.rb
@@ -1,16 +0,0 @@
1
- module Ddr
2
- module Auth
3
- class FailureApp < Devise::FailureApp
4
-
5
- def respond
6
- if scope == :user && Ddr::Auth.require_shib_user_authn
7
- store_location!
8
- redirect_to user_omniauth_authorize_path(:shibboleth)
9
- else
10
- super
11
- end
12
- end
13
-
14
- end
15
- end
16
- end
@@ -1,22 +0,0 @@
1
- RSpec.describe ApplicationController, type: :controller do
2
- controller do
3
- before_action :authenticate_user!
4
- def index; end
5
- end
6
- describe "authentication failure handling" do
7
- describe "when shibboleth user authentication is required" do
8
- before { allow(Ddr::Auth).to receive(:require_shib_user_authn) { true } }
9
- it "should redirect to the shib authn path" do
10
- get :index
11
- expect(response).to redirect_to(user_omniauth_authorize_path(:shibboleth))
12
- end
13
- end
14
- describe "when shibboleth user authentication is not required" do
15
- before { allow(Ddr::Auth).to receive(:require_shib_user_authn) { false } }
16
- it "should redirect to the new user session path" do
17
- get :index
18
- expect(response).to redirect_to(new_user_session_path)
19
- end
20
- end
21
- end
22
- end