omniauth-aleph 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -12,5 +12,5 @@ platforms :rbx do
12
12
  end
13
13
 
14
14
  # XML parsing
15
- gem 'ox', '~> 2.0.0', platform: :ruby
15
+ gem 'ox', '~> 2.1.0', platform: :ruby
16
16
  gem 'nokogiri', '~> 1.6.1', platform: :jruby
data/README.md CHANGED
@@ -23,3 +23,151 @@ Use the Aleph strategy as a middleware in your application:
23
23
  use OmniAuth::Strategies::Aleph, title: 'My Library's Aleph',
24
24
  host: 'aleph.library.edu', port: 80, library: 'ADM50', sub_library: 'SUB'
25
25
 
26
+ ## Configuring
27
+ You can configure several options, which you pass in to the `provider` method via a `Hash`:
28
+
29
+ - `title`: title for the `request_phase` form; defaults to `Aleph Authentication`
30
+ - `scheme`: scheme for your Aleph X-Server as a String; defaults to `http`
31
+ - `host`: host name for your Aleph X-Server as a String; required
32
+ - `port`: port for your Aleph X-Server as an Integer; defaults to `80`
33
+ - `library`: Aleph administrative library for authentication; required
34
+ - `sub_library`: Aleph sub library for authentication; required
35
+
36
+ ## Auth Hash
37
+ Here's an example _Auth Hash_ available in `request.env['omniauth.auth']`:
38
+
39
+ {
40
+ :provider => 'aleph',
41
+ :uid => 'USERNAME',
42
+ :info => {
43
+ :name => "USERNAME, TEST-RECORD",
44
+ :nickname => "USERNAME",
45
+ :email => "username@library.edu",
46
+ :phone => nil
47
+ },
48
+ :credentials => {},
49
+ :extra => {
50
+ :raw_info => {
51
+ :bor_auth => {
52
+ :z303 => {
53
+ :z303_id => "USERNAME",
54
+ :z303_proxy_for_id => nil,
55
+ :z303_primary_id => nil,
56
+ :z303_name_key => "username test record USERNAME",
57
+ :z303_user_type => nil,
58
+ :z303_user_library => nil,
59
+ :z303_open_date => "09/30/2013",
60
+ :z303_update_date => "10/26/2013",
61
+ :z303_con_lng => "ENG",
62
+ :z303_alpha => "L",
63
+ :z303_name => "USERNAME, TEST-RECORD",
64
+ :z303_title => nil,
65
+ :z303_delinq_1 => "00",
66
+ :z303_delinq_n_1 => nil,
67
+ :z303_delinq_1_update_date => "00000000",
68
+ :z303_delinq_1_cat_name => nil,
69
+ :z303_delinq_2 => "00",
70
+ :z303_delinq_n_2 => nil,
71
+ :z303_delinq_2_update_date => "00000000",
72
+ :z303_delinq_2_cat_name => nil,
73
+ :z303_delinq_3 => "00",
74
+ :z303_delinq_n_3 => nil,
75
+ :z303_delinq_3_update_date => "00000000",
76
+ :z303_delinq_3_cat_name => nil,
77
+ :z303_budget => nil,
78
+ :z303_profile_id => nil,
79
+ :z303_ill_library => nil,
80
+ :z303_home_library => "Home Library",
81
+ :z303_field_1 => nil,
82
+ :z303_field_2 => nil,
83
+ :z303_field_3 => nil,
84
+ :z303_note_1 => nil,
85
+ :z303_note_2 => nil,
86
+ :z303_salutation => nil,
87
+ :z303_ill_total_limit => "0000",
88
+ :z303_ill_active_limit => "0000",
89
+ :z303_dispatch_library => nil,
90
+ :z303_birth_date => nil,
91
+ :z303_export_consent => "Y",
92
+ :z303_proxy_id_type => "00",
93
+ :z303_send_all_letters => "Y",
94
+ :z303_plain_html => "P",
95
+ :z303_want_sms => nil,
96
+ :z303_plif_modification => nil,
97
+ :z303_title_req_limit => "0000",
98
+ :z303_gender => nil,
99
+ :z303_birthplace => nil},
100
+ :z304 => {
101
+ :z304_id => "USERNAME",
102
+ :z304_sequence => "02",
103
+ :z304_address_0 => "USERNAME, TEST-RECORD",
104
+ :z304_address_1 => "100 Testing Lane",
105
+ :z304_address_2 => "Testing Town",
106
+ :z304_address_3 => "NY",
107
+ :z304_zip => "10012",
108
+ :z304_email_address => "username@library.edu",
109
+ :z304_telephone => nil,
110
+ :z304_date_from => "20100101",
111
+ :z304_date_to => "20201231",
112
+ :z304_address_type => "02",
113
+ :z304_telephone_2 => nil,
114
+ :z304_telephone_3 => nil,
115
+ :z304_telephone_4 => nil,
116
+ :z304_sms_number => nil,
117
+ :z304_update_date => "20131026",
118
+ :z304_cat_name => "BATCH"
119
+ },
120
+ :z305 => {
121
+ :z305_id => "USERNAME",
122
+ :z305_sub_library => "SUB",
123
+ :z305_open_date => "09/30/2013",
124
+ :z305_update_date => "10/26/2013",
125
+ :z305_bor_type => nil,
126
+ :z305_bor_status => "Adjunct Faculty",
127
+ :z305_registration_date => "00000000",
128
+ :z305_expiry_date => "12/31/2020",
129
+ :z305_note => nil,
130
+ :z305_loan_permission => "Y",
131
+ :z305_photo_permission => "N",
132
+ :z305_over_permission => "Y",
133
+ :z305_multi_hold => "N",
134
+ :z305_loan_check => "Y",
135
+ :z305_hold_permission => "Y",
136
+ :z305_renew_permission => "Y",
137
+ :z305_rr_permission => "N",
138
+ :z305_ignore_late_return => "N",
139
+ :z305_last_activity_date => nil,
140
+ :z305_photo_charge => "F",
141
+ :z305_no_loan => "0000",
142
+ :z305_no_hold => "0000",
143
+ :z305_no_photo => "0000",
144
+ :z305_no_cash => "0000",
145
+ :z305_cash_limit => "5.00",
146
+ :z305_credit_debit => nil,
147
+ :z305_sum => "0.00",
148
+ :z305_delinq_1 => "00",
149
+ :z305_delinq_n_1 => nil,
150
+ :z305_delinq_1_update_date => "00000000",
151
+ :z305_delinq_1_cat_name => nil,
152
+ :z305_delinq_2 => "00",
153
+ :z305_delinq_n_2 => nil,
154
+ :z305_delinq_2_update_date => "00000000",
155
+ :z305_delinq_2_cat_name => nil,
156
+ :z305_delinq_3 => "00",
157
+ :z305_delinq_n_3 => nil,
158
+ :z305_delinq_3_update_date => "00000000",
159
+ :z305_delinq_3_cat_name => nil,
160
+ :z305_field_1 => nil,
161
+ :z305_field_2 => nil,
162
+ :z305_field_3 => nil,
163
+ :z305_hold_on_shelf => "N",
164
+ :z305_end_block_date => nil,
165
+ :z305_booking_permission => "N",
166
+ :z305_booking_ignore_hours => "N",
167
+ :z305_rush_cat_request => "N"
168
+ },
169
+ :session_id => "B3S4C6Y7DLQCA41NAYH1BQHLU6F24AKJRRSPRTF99FXECEUMIS"
170
+ }
171
+ }
172
+ }
173
+ }
@@ -31,7 +31,7 @@ module OmniAuth
31
31
  url = bor_auth_url + "&bor_id=#{username}&verification=#{password}"
32
32
  response = Faraday.get url
33
33
  # If we get a successful response AND we are looking at XML and we have a body
34
- if response.status == 200 && response.headers["content-type"] == 'text/xml' && response.body
34
+ if response.status == 200 && response.headers["content-type"].include?('text/xml') && response.body
35
35
  json = MultiXml.parse(response.body)
36
36
  if json["bor_auth"] && (error = json["bor_auth"]["error"]).nil?
37
37
  return json
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Aleph
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
- end
5
+ end
@@ -43,52 +43,50 @@ describe "OmniAuth::Strategies::Aleph" do
43
43
  end
44
44
 
45
45
  describe '#options' do
46
- it 'should not error' do
47
- expect{ strategy.options }.not_to raise_error
48
- end
49
-
50
46
  subject(:options) { strategy.options }
51
47
 
48
+ it { should_not raise_error }
49
+
52
50
  describe'#name' do
53
- it 'should equal "Aleph"' do
54
- expect(options.name).to eq("aleph")
55
- end
51
+ subject { options.name }
52
+ it { should_not be_nil }
53
+ it { should eq("aleph") }
56
54
  end
57
55
 
58
56
  describe '#title' do
59
- it 'should equal "Aleph Authentication"' do
60
- expect(options.title).to eq("Aleph Authentication")
61
- end
57
+ subject { options.title }
58
+ it { should_not be_nil }
59
+ it { should eq("Aleph Authentication") }
62
60
  end
63
61
 
64
62
  describe '#scheme' do
65
- it 'should equal "http"' do
66
- expect(options.scheme).to eq("http")
67
- end
63
+ subject { options.scheme }
64
+ it { should_not be_nil }
65
+ it { should eq("http") }
68
66
  end
69
67
 
70
68
  describe '#host' do
71
- it 'should be the aleph host' do
72
- expect(options.host).to eq(aleph_host)
73
- end
69
+ subject { options.host }
70
+ it { should_not be_nil }
71
+ it { should eq(aleph_host) }
74
72
  end
75
73
 
76
74
  describe '#port' do
77
- it 'should be 80' do
78
- expect(options.port).to be(80)
79
- end
75
+ subject { options.port }
76
+ it { should_not be_nil }
77
+ it { should be(80) }
80
78
  end
81
79
 
82
80
  describe '#library' do
83
- it 'should be the aleph library' do
84
- expect(options.library).to eq(aleph_library)
85
- end
81
+ subject { options.library }
82
+ it { should_not be_nil }
83
+ it { should eq(aleph_library) }
86
84
  end
87
85
 
88
86
  describe '#sub_library' do
89
- it 'should be the aleph sub_library' do
90
- expect(options.sub_library).to eq(aleph_sub_library)
91
- end
87
+ subject { options.sub_library }
88
+ it { should_not be_nil }
89
+ it { should eq(aleph_sub_library) }
92
90
  end
93
91
  end
94
92
 
@@ -239,6 +237,7 @@ describe "OmniAuth::Strategies::Aleph" do
239
237
  expect(auth_hash.info.nickname).to eq('USERNAME')
240
238
  expect(auth_hash.info.email).to eq('username@library.edu')
241
239
  expect(auth_hash.info.phone).to be_nil
240
+ expect(auth_hash.extra.raw_info.bor_auth.z303.z303_id).to eq('USERNAME')
242
241
  end
243
242
  end
244
243
  end
@@ -36,11 +36,10 @@ http_interactions:
36
36
  encoding: US-ASCII
37
37
  string: ! "<?xml version = \"1.0\" encoding = \"UTF-8\"?>\n<bor-auth>\n<z303>\n<z303-id>USERNAME</z303-id>\n<z303-proxy-for-id></z303-proxy-for-id>\n<z303-primary-id></z303-primary-id>\n<z303-name-key>username
38
38
  test record USERNAME</z303-name-key>\n<z303-user-type></z303-user-type>\n<z303-user-library></z303-user-library>\n<z303-open-date>09/30/2013</z303-open-date>\n<z303-update-date>10/26/2013</z303-update-date>\n<z303-con-lng>ENG</z303-con-lng>\n<z303-alpha>L</z303-alpha>\n<z303-name>USERNAME,
39
- TEST-RECORD</z303-name>\n<z303-title></z303-title>\n<z303-delinq-1>00</z303-delinq-1>\n<z303-delinq-n-1></z303-delinq-n-1>\n<z303-delinq-1-update-date>00000000</z303-delinq-1-update-date>\n<z303-delinq-1-cat-name></z303-delinq-1-cat-name>\n<z303-delinq-2>00</z303-delinq-2>\n<z303-delinq-n-2></z303-delinq-n-2>\n<z303-delinq-2-update-date>00000000</z303-delinq-2-update-date>\n<z303-delinq-2-cat-name></z303-delinq-2-cat-name>\n<z303-delinq-3>00</z303-delinq-3>\n<z303-delinq-n-3></z303-delinq-n-3>\n<z303-delinq-3-update-date>00000000</z303-delinq-3-update-date>\n<z303-delinq-3-cat-name></z303-delinq-3-cat-name>\n<z303-budget></z303-budget>\n<z303-profile-id></z303-profile-id>\n<z303-ill-library></z303-ill-library>\n<z303-home-library>NYU
40
- Bobst Library</z303-home-library>\n<z303-field-1></z303-field-1>\n<z303-field-2></z303-field-2>\n<z303-field-3></z303-field-3>\n<z303-note-1></z303-note-1>\n<z303-note-2></z303-note-2>\n<z303-salutation></z303-salutation>\n<z303-ill-total-limit>0000</z303-ill-total-limit>\n<z303-ill-active-limit>0000</z303-ill-active-limit>\n<z303-dispatch-library></z303-dispatch-library>\n<z303-birth-date></z303-birth-date>\n<z303-export-consent>Y</z303-export-consent>\n<z303-proxy-id-type>00</z303-proxy-id-type>\n<z303-send-all-letters>Y</z303-send-all-letters>\n<z303-plain-html>P</z303-plain-html>\n<z303-want-sms></z303-want-sms>\n<z303-plif-modification></z303-plif-modification>\n<z303-title-req-limit>0000</z303-title-req-limit>\n<z303-gender></z303-gender>\n<z303-birthplace>PLIF
41
- LOADED</z303-birthplace>\n</z303>\n<z304>\n<z304-id>USERNAME</z304-id>\n<z304-sequence>02</z304-sequence>\n<z304-address-0>USERNAME,
39
+ TEST-RECORD</z303-name>\n<z303-title></z303-title>\n<z303-delinq-1>00</z303-delinq-1>\n<z303-delinq-n-1></z303-delinq-n-1>\n<z303-delinq-1-update-date>00000000</z303-delinq-1-update-date>\n<z303-delinq-1-cat-name></z303-delinq-1-cat-name>\n<z303-delinq-2>00</z303-delinq-2>\n<z303-delinq-n-2></z303-delinq-n-2>\n<z303-delinq-2-update-date>00000000</z303-delinq-2-update-date>\n<z303-delinq-2-cat-name></z303-delinq-2-cat-name>\n<z303-delinq-3>00</z303-delinq-3>\n<z303-delinq-n-3></z303-delinq-n-3>\n<z303-delinq-3-update-date>00000000</z303-delinq-3-update-date>\n<z303-delinq-3-cat-name></z303-delinq-3-cat-name>\n<z303-budget></z303-budget>\n<z303-profile-id></z303-profile-id>\n<z303-ill-library></z303-ill-library>\n<z303-home-library>Home
40
+ Library</z303-home-library>\n<z303-field-1></z303-field-1>\n<z303-field-2></z303-field-2>\n<z303-field-3></z303-field-3>\n<z303-note-1></z303-note-1>\n<z303-note-2></z303-note-2>\n<z303-salutation></z303-salutation>\n<z303-ill-total-limit>0000</z303-ill-total-limit>\n<z303-ill-active-limit>0000</z303-ill-active-limit>\n<z303-dispatch-library></z303-dispatch-library>\n<z303-birth-date></z303-birth-date>\n<z303-export-consent>Y</z303-export-consent>\n<z303-proxy-id-type>00</z303-proxy-id-type>\n<z303-send-all-letters>Y</z303-send-all-letters>\n<z303-plain-html>P</z303-plain-html>\n<z303-want-sms></z303-want-sms>\n<z303-plif-modification></z303-plif-modification>\n<z303-title-req-limit>0000</z303-title-req-limit>\n<z303-gender></z303-gender>\n<z303-birthplace></z303-birthplace>\n</z303>\n<z304>\n<z304-id>USERNAME</z304-id>\n<z304-sequence>02</z304-sequence>\n<z304-address-0>USERNAME,
42
41
  TEST-RECORD</z304-address-0>\n<z304-address-1>100 Testing Lane</z304-address-1>\n<z304-address-2>Testing
43
- Town</z304-address-2>\n<z304-address-3>NY</z304-address-3>\n<z304-zip>10012</z304-zip>\n<z304-email-address>username@library.edu</z304-email-address>\n<z304-telephone></z304-telephone>\n<z304-date-from>20100101</z304-date-from>\n<z304-date-to>20201231</z304-date-to>\n<z304-address-type>02</z304-address-type>\n<z304-telephone-2></z304-telephone-2>\n<z304-telephone-3></z304-telephone-3>\n<z304-telephone-4></z304-telephone-4>\n<z304-sms-number></z304-sms-number>\n<z304-update-date>20131026</z304-update-date>\n<z304-cat-name>BATCH</z304-cat-name>\n</z304>\n<z305>\n<z305-id>USERNAME</z305-id>\n<z305-sub-library>SUB</z305-sub-library>\n<z305-open-date>09/30/2013</z305-open-date>\n<z305-update-date>10/26/2013</z305-update-date>\n<z305-bor-type></z305-bor-type>\n<z305-bor-status>Palmer
42
+ Town</z304-address-2>\n<z304-address-3>NY</z304-address-3>\n<z304-zip>10012</z304-zip>\n<z304-email-address>username@library.edu</z304-email-address>\n<z304-telephone></z304-telephone>\n<z304-date-from>20100101</z304-date-from>\n<z304-date-to>20201231</z304-date-to>\n<z304-address-type>02</z304-address-type>\n<z304-telephone-2></z304-telephone-2>\n<z304-telephone-3></z304-telephone-3>\n<z304-telephone-4></z304-telephone-4>\n<z304-sms-number></z304-sms-number>\n<z304-update-date>20131026</z304-update-date>\n<z304-cat-name>BATCH</z304-cat-name>\n</z304>\n<z305>\n<z305-id>USERNAME</z305-id>\n<z305-sub-library>SUB</z305-sub-library>\n<z305-open-date>09/30/2013</z305-open-date>\n<z305-update-date>10/26/2013</z305-update-date>\n<z305-bor-type></z305-bor-type>\n<z305-bor-status>Adjunct
44
43
  Faculty</z305-bor-status>\n<z305-registration-date>00000000</z305-registration-date>\n<z305-expiry-date>12/31/2020</z305-expiry-date>\n<z305-note></z305-note>\n<z305-loan-permission>Y</z305-loan-permission>\n<z305-photo-permission>N</z305-photo-permission>\n<z305-over-permission>Y</z305-over-permission>\n<z305-multi-hold>N</z305-multi-hold>\n<z305-loan-check>Y</z305-loan-check>\n<z305-hold-permission>Y</z305-hold-permission>\n<z305-renew-permission>Y</z305-renew-permission>\n<z305-rr-permission>N</z305-rr-permission>\n<z305-ignore-late-return>N</z305-ignore-late-return>\n<z305-last-activity-date></z305-last-activity-date>\n<z305-photo-charge>F</z305-photo-charge>\n<z305-no-loan>0000</z305-no-loan>\n<z305-no-hold>0000</z305-no-hold>\n<z305-no-photo>0000</z305-no-photo>\n<z305-no-cash>0000</z305-no-cash>\n<z305-cash-limit>5.00</z305-cash-limit>\n<z305-credit-debit></z305-credit-debit>\n<z305-sum>0.00</z305-sum>\n<z305-delinq-1>00</z305-delinq-1>\n<z305-delinq-n-1></z305-delinq-n-1>\n<z305-delinq-1-update-date>00000000</z305-delinq-1-update-date>\n<z305-delinq-1-cat-name></z305-delinq-1-cat-name>\n<z305-delinq-2>00</z305-delinq-2>\n<z305-delinq-n-2></z305-delinq-n-2>\n<z305-delinq-2-update-date>00000000</z305-delinq-2-update-date>\n<z305-delinq-2-cat-name></z305-delinq-2-cat-name>\n<z305-delinq-3>00</z305-delinq-3>\n<z305-delinq-n-3></z305-delinq-n-3>\n<z305-delinq-3-update-date>00000000</z305-delinq-3-update-date>\n<z305-delinq-3-cat-name></z305-delinq-3-cat-name>\n<z305-field-1></z305-field-1>\n<z305-field-2></z305-field-2>\n<z305-field-3></z305-field-3>\n<z305-hold-on-shelf>N</z305-hold-on-shelf>\n<z305-end-block-date></z305-end-block-date>\n<z305-booking-permission>N</z305-booking-permission>\n<z305-booking-ignore-hours>N</z305-booking-ignore-hours>\n<z305-rush-cat-request>N</z305-rush-cat-request>\n</z305>\n<session-id>B3S4C6Y7DLQCA41NAYH1BQHLU6F24AKJRRSPRTF99FXECEUMIS</session-id>\n</bor-auth>\n "
45
44
  http_version:
46
45
  recorded_at: Wed, 22 Jan 2014 15:53:06 GMT
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-aleph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
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: 2014-01-23 00:00:00.000000000 Z
12
+ date: 2014-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
@@ -185,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  segments:
187
187
  - 0
188
- hash: 2081205909347291238
188
+ hash: 563932762752653555
189
189
  required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  none: false
191
191
  requirements:
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
194
  version: '0'
195
195
  segments:
196
196
  - 0
197
- hash: 2081205909347291238
197
+ hash: 563932762752653555
198
198
  requirements: []
199
199
  rubyforge_project:
200
200
  rubygems_version: 1.8.23