authpds-nyu 0.1.4 → 0.2.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.
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2012 YOURNAME
1
+ Copyright 2012 Scot Dalton
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -1,23 +1,26 @@
1
1
  = AuthpdsNyu
2
+ {<img src="https://secure.travis-ci.org/scotdalton/authpds-nyu.png?branch=master" alt="Build Status" />}[https://travis-ci.org/scotdalton/authpds-nyu]
3
+ {<img src="https://gemnasium.com/scotdalton/authpds-nyu.png" alt="Dependency Status" />}[https://gemnasium.com/scotdalton/authpds-nyu]
4
+ {<img src="https://codeclimate.com/badge.png" alt="Code Climage" />}[https://codeclimate.com/github/scotdalton/authpds-nyu]
2
5
 
3
6
  This gem provides a mechanism for user authentication and authorization via NYU Libraries PDS system. It extends Authpds and provides NYU Libraries' specific configuration.
4
7
 
5
8
  == Basics
6
9
  === Generate User-like model
7
10
  $ rails generate model User username:string email:string firstname:string \
8
- lastname:string mobile_phone:string crypted_password:string password_salt:string \
9
- session_id:string persistence_token:string login_count:integer last_request_at:string \
10
- current_login_at:string last_login_at:string last_login_ip:string current_login_ip:string \
11
- user_attributes:text refreshed_at:datetime
11
+ lastname:string mobile_phone:string crypted_password:string password_salt:string \
12
+ session_id:string persistence_token:string login_count:integer last_request_at:string \
13
+ current_login_at:string last_login_at:string last_login_ip:string current_login_ip:string \
14
+ user_attributes:text refreshed_at:datetime
12
15
 
13
16
  === Configure User-like model
14
17
  class User < ActiveRecord::Base
15
- serialize :user_attributes
18
+ serialize :user_attributes
16
19
 
17
20
  acts_as_authentic do |c|
18
21
  c.validations_scope = :username
19
22
  c.validate_password_field = false
20
- c.require_password_confirmation = false
23
+ c.require_password_confirmation = false
21
24
  c.disable_perishable_token_maintenance = true
22
25
  end
23
26
  end
@@ -49,7 +52,6 @@ This gem provides a mechanism for user authentication and authorization via NYU
49
52
  include Authpds::Controllers::AuthpdsController
50
53
  end
51
54
 
52
-
53
55
  == Overview
54
56
  The module extends Authpds and should be compatible with Authpds configuation.
55
57
  It also provides hooks for custom functionality.
@@ -59,7 +61,4 @@ The documentation below describes NYU specific config methods available.
59
61
  :opensso_url:: Base OpenSSO url (https://login.nyu.edu:443/sso)
60
62
  :aleph_url:: Aleph url (http://aleph.library.nyu.edu)
61
63
  :aleph_default_adm:: Aleph default ADM (NYU50)
62
- :aleph_default_sublibrary:: Aleph default sublibrary (BOBST)
63
-
64
-
65
- == Build Status {<img src="https://secure.travis-ci.org/scotdalton/authpds-nyu.png"/>}[http://travis-ci.org/scotdalton/authpds-nyu]
64
+ :aleph_default_sublibrary:: Aleph default sublibrary (BOBST)
data/Rakefile CHANGED
@@ -20,9 +20,6 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
21
21
  end
22
22
 
23
-
24
-
25
-
26
23
  Bundler::GemHelper.install_tasks
27
24
 
28
25
  require 'rake/testtask'
@@ -34,5 +31,4 @@ Rake::TestTask.new(:test) do |t|
34
31
  t.verbose = false
35
32
  end
36
33
 
37
-
38
- task :default => :test
34
+ task :default => :test
@@ -1,16 +1,16 @@
1
1
  module AuthpdsNyu
2
2
  # == Overview
3
- # This gem provides a mechanism for user authentication and authorization via NYU Libraries PDS system.
3
+ # This gem provides a mechanism for user authentication and authorization via NYU Libraries PDS system.
4
4
  # The module extends Authpds and should be compatible with Authpds configuation.
5
5
  # It also provides hooks for custom functionality.
6
6
  # The documentation below describes NYU specific config methods available.
7
- #
7
+ #
8
8
  # == Config Options Available
9
9
  # :opensso_url:: Base OpenSSO url (https://login.nyu.edu:443/sso)
10
10
  # :aleph_url:: Aleph url (http://aleph.library.nyu.edu)
11
11
  # :aleph_default_adm:: Aleph default ADM (NYU50)
12
12
  # :aleph_default_sublibrary:: Aleph default sublibrary (BOBST)
13
- #
13
+ #
14
14
  module Session
15
15
  def self.included(klass)
16
16
  klass.class_eval do
@@ -61,11 +61,11 @@ module AuthpdsNyu
61
61
  return @valid_sso_session
62
62
  end
63
63
  end
64
-
64
+
65
65
  module InstanceMethods
66
66
  def self.included(klass)
67
67
  klass.class_eval do
68
- pds_attributes :firstname => "givenname", :lastname => "sn", :email => "email", :primary_institution => "institute"
68
+ pds_attributes :firstname => "givenname", :lastname => "sn", :email => "email", :primary_institution => "institute"
69
69
  remember_me true
70
70
  remember_me_for 300
71
71
  httponly true
@@ -73,7 +73,7 @@ module AuthpdsNyu
73
73
  login_inaccessible_url "http://library.nyu.edu/errors/login-library-nyu-edu/"
74
74
  end
75
75
  end
76
-
76
+
77
77
  # Overriden logout url for NYU.
78
78
  def logout_url(params={})
79
79
  return "#{self.class.pds_url}/logout?url=#{CGI::escape(controller.user_session_redirect_url(self.class.redirect_logout_url))}"
@@ -82,7 +82,7 @@ module AuthpdsNyu
82
82
  def aleph_bor_auth_permissions(bor_id=nil, verification=nil, adm=nil, sublibrary=nil)
83
83
  bor_auth = aleph_bor_auth(bor_id, verification, adm, sublibrary)
84
84
  return (bor_auth.nil? or bor_auth.error) ? {} : bor_auth.permissions
85
- end
85
+ end
86
86
 
87
87
  def aleph_bor_auth(bor_id=nil, verification=nil, adm=nil, sublibrary=nil)
88
88
  bor_id = pds_user.id if bor_id.nil? unless pds_user.nil?
@@ -93,7 +93,7 @@ module AuthpdsNyu
93
93
  adm = self.class.aleph_default_adm if adm.nil?
94
94
  sublibrary = self.class.aleph_default_sublibrary if sublibrary.nil?
95
95
  # Call X-Service
96
- bor_auth =
96
+ bor_auth =
97
97
  Exlibris::Aleph::BorAuth.
98
98
  new(aleph_url, adm, sublibrary, "N", bor_id, verification)
99
99
  controller.logger.error(
@@ -29,7 +29,7 @@ module AuthpdsNyu
29
29
  return @cookies[:nyulibrary_opensso_cookiename] unless @cookies[:nyulibrary_opensso_cookiename].nil?
30
30
  req = Net::HTTP::Get.new(@opensso_uri.path + '/identity/getCookieNameForToken')
31
31
  res = @http.request(req, '')
32
- raise RuntimeError.new(
32
+ raise RuntimeError.new(
33
33
  "Error in #{self.class}."+
34
34
  "Unrecognized response: #{res}") unless res.body.starts_with?("string=")
35
35
  cookie_name = res.body.split('=').at(1).chomp unless res.body.split('=').at(1).nil?
@@ -42,8 +42,8 @@ module AuthpdsNyu
42
42
  token_cookie = @cookies[token_cookie_name]
43
43
  token_cookie = @cookies[token_cookie_name.to_sym] if token_cookie.nil?
44
44
  token_cookie = CGI.unescape(token_cookie.to_s.gsub('+', '%2B'))
45
- token_cookie = (token_cookie != '') ?
46
- (token_cookie.start_with?(token_cookie_name)) ?
45
+ token_cookie = (token_cookie != '') ?
46
+ (token_cookie.start_with?(token_cookie_name)) ?
47
47
  token_cookie : "#{token_cookie_name}=#{token_cookie}; path=" : nil
48
48
  end
49
49
 
@@ -52,7 +52,7 @@ module AuthpdsNyu
52
52
  req = Net::HTTP::Get.new(@opensso_uri.path + '/identity/isTokenValid')
53
53
  req['Cookie'] = token_cookie
54
54
  res = @http.request(req, '')
55
- raise RuntimeError.new(
55
+ raise RuntimeError.new(
56
56
  "Error in #{self.class}."+
57
57
  "Unrecognized response: #{res}") unless res.body.starts_with?("boolean=")
58
58
  res.body.split('=').at(1).chomp == 'true'
@@ -1,3 +1,3 @@
1
1
  module AuthpdsNyu
2
- VERSION = "0.1.4"
3
- end
2
+ VERSION = "0.2.0"
3
+ end
data/lib/authpds-nyu.rb CHANGED
@@ -8,5 +8,4 @@ AUTHPDS_NYU_PATH = File.dirname(__FILE__) + "/authpds-nyu/"
8
8
  ].each do |library|
9
9
  require AUTHPDS_NYU_PATH + library
10
10
  end
11
- Authlogic::Session::Base.send(:include, AuthpdsNyu::Session)
12
-
11
+ Authlogic::Session::Base.send(:include, AuthpdsNyu::Session)
data/test/support/user.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  class User < ActiveRecord::Base
2
- serialize :user_attributes
2
+ serialize :user_attributes
3
3
 
4
- acts_as_authentic do |c|
5
- c.validations_scope = :username
6
- c.validate_password_field = false
7
- c.require_password_confirmation = false
8
- end
4
+ acts_as_authentic do |c|
5
+ c.validations_scope = :username
6
+ c.validate_password_field = false
7
+ c.require_password_confirmation = false
8
+ end
9
9
  end
data/test/test_helper.rb CHANGED
@@ -29,8 +29,8 @@ ActiveRecord::Schema.define(:version => 1) do
29
29
  t.datetime "last_request_at"
30
30
  t.datetime "current_login_at"
31
31
  t.datetime "last_login_at"
32
- t.string "last_login_ip"
33
- t.string "current_login_ip"
32
+ t.string "last_login_ip"
33
+ t.string "current_login_ip"
34
34
  t.text "user_attributes"
35
35
  t.datetime "refreshed_at"
36
36
  t.timestamps
@@ -42,9 +42,9 @@ require File.dirname(__FILE__) + '/../lib/authpds-nyu'
42
42
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
43
43
 
44
44
  class ActiveSupport::TestCase
45
- VALID_OPENSSO_FOR_NYU = 'AQIC5wM2LY4Sfcz_O7UA1U1KruO_dMKGYQQKYhZNqDgeEPI.*AAJTSQACMDIAAlNLAAstMTMwMzI0MzkzMwACUzEAAjAx*'
45
+ VALID_OPENSSO_FOR_NYU = 'AQIC5wM2LY4Sfcxc13Lmq865G281ghiEEXHBsnl6eVSC3hU.*AAJTSQACMDIAAlMxAAIwMQ..*'
46
46
  INVALID_OPENSSO = "Invalid"
47
- VALID_PDS_HANDLE_FOR_NEW_NYU = '293201211510129623735547952389'
47
+ VALID_PDS_HANDLE_FOR_NEW_NYU = '911201215342297526743181020780'
48
48
  VALID_PDS_HANDLE_FOR_EXISTING_NYU = '83201295456116368349190324314'
49
49
  VALID_PDS_HANDLE_FOR_NEWSCHOOL = '272201212284614806184193096120278'
50
50
  VALID_PDS_HANDLE_FOR_COOPER = '272201212284614806184193096120278'
@@ -65,11 +65,11 @@ class Authlogic::TestCase::MockController
65
65
  end
66
66
 
67
67
  include Authpds::Controllers::AuthpdsController
68
-
68
+
69
69
  def url_for(options={})
70
70
  return "#{root_url}/validate?return_url=#{options[:return_url]}"
71
71
  end
72
-
72
+
73
73
  def root_url
74
74
  return "http://railsapp.library.nyu.edu"
75
75
  end
@@ -77,11 +77,11 @@ class Authlogic::TestCase::MockController
77
77
  def validate_url(options={})
78
78
  return "#{root_url}/validate?return_url=#{options[:return_url]}"
79
79
  end
80
-
80
+
81
81
  def performed?
82
82
  false
83
83
  end
84
-
84
+
85
85
  def redirect_to(*args)
86
86
  # puts args.inspect
87
87
  end
@@ -1,12 +1,12 @@
1
1
  require 'test_helper'
2
2
  class UserSessionTest < ActiveSupport::TestCase
3
-
3
+
4
4
  def setup
5
5
  activate_authlogic
6
6
  controller.session[:session_id] = "FakeSessionID"
7
7
  controller.cookies[:iPlanetDirectoryPro] = { :value => VALID_OPENSSO_FOR_NYU }
8
8
  end
9
-
9
+
10
10
  test "valid_sso_session?" do
11
11
  user_session = UserSession.new
12
12
  assert(user_session.valid_sso_session?)
@@ -22,14 +22,14 @@ class UserSessionTest < ActiveSupport::TestCase
22
22
  assert_nil(user_session.record)
23
23
  user_session = UserSession.find
24
24
  end
25
-
25
+
26
26
  test "logout_url" do
27
27
  user_session = UserSession.new
28
28
  assert_equal(
29
- "https://logindev.library.nyu.edu/logout?url=http%3A%2F%2Fbobcatdev.library.nyu.edu",
29
+ "https://logindev.library.nyu.edu/logout?url=http%3A%2F%2Fbobcatdev.library.nyu.edu",
30
30
  user_session.logout_url)
31
31
  end
32
-
32
+
33
33
  test "aleph_bor_auth" do
34
34
  user_session = UserSession.new
35
35
  bor_auth = user_session.aleph_bor_auth("N12162279", "d4465aacaa645f2164908cd4184c09f0", "NYU50", "BOBST")
@@ -37,7 +37,7 @@ class UserSessionTest < ActiveSupport::TestCase
37
37
  assert_equal("CB", bor_auth.permissions[:bor_type])
38
38
  assert_equal("Y", bor_auth.permissions[:hold_on_shelf])
39
39
  end
40
-
40
+
41
41
  test "aleph_bor_auth_permissions" do
42
42
  user_session = UserSession.new
43
43
  permissions = user_session.aleph_bor_auth_permissions("N12162279", "d4465aacaa645f2164908cd4184c09f0", "NYU50", "BOBST")
@@ -45,14 +45,14 @@ class UserSessionTest < ActiveSupport::TestCase
45
45
  assert_equal("CB", permissions[:bor_type])
46
46
  assert_equal("Y", permissions[:hold_on_shelf])
47
47
  end
48
-
48
+
49
49
  # test "find_new_user" do
50
50
  # controller.cookies[:PDS_HANDLE] = { :value => VALID_PDS_HANDLE_FOR_NEW_NYU }
51
51
  # user_session = UserSession.find
52
52
  # # puts user_session.record.username
53
53
  # # puts user_session.record.id
54
54
  # end
55
- #
55
+ #
56
56
  # test "find_existing_user" do
57
57
  # controller.cookies[:PDS_HANDLE] = { :value => VALID_PDS_HANDLE_FOR_EXISTING_NYU }
58
58
  # user_session = UserSession.find
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authpds-nyu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-24 00:00:00.000000000 Z
12
+ date: 2012-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -32,33 +32,33 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 0.1.2
37
+ version: '0'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 0.1.2
45
+ version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: exlibris-aleph
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ~>
51
+ - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
- version: 0.1.0
53
+ version: '0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ~>
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.1.0
61
+ version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: sqlite3
64
64
  requirement: !ruby/object:Gem::Requirement
@@ -109,12 +109,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
109
  - - ! '>='
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
+ segments:
113
+ - 0
114
+ hash: 44708976452511195
112
115
  required_rubygems_version: !ruby/object:Gem::Requirement
113
116
  none: false
114
117
  requirements:
115
118
  - - ! '>='
116
119
  - !ruby/object:Gem::Version
117
120
  version: '0'
121
+ segments:
122
+ - 0
123
+ hash: 44708976452511195
118
124
  requirements: []
119
125
  rubyforge_project:
120
126
  rubygems_version: 1.8.24