omniauth-polaris 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -2
- data/.rubocop.yml +25 -0
- data/.rubocop_todo.yml +300 -0
- data/Gemfile +9 -33
- data/Rakefile +19 -5
- data/bin/console +9 -0
- data/lib/omniauth/polaris/adaptor.rb +108 -0
- data/lib/omniauth/polaris/version.rb +7 -0
- data/lib/omniauth/polaris.rb +24 -0
- data/lib/omniauth/strategies/polaris.rb +55 -90
- data/lib/omniauth-polaris.rb +3 -3
- data/omniauth-polaris.gemspec +26 -21
- data/spec/omniauth/polaris/adaptor_spec.rb +17 -0
- data/spec/omniauth/strategies/polaris_spec.rb +71 -48
- data/spec/spec_helper.rb +24 -5
- metadata +68 -49
- data/lib/omniauth-polaris/adaptor.rb +0 -100
- data/lib/omniauth-polaris/version.rb +0 -5
- data/spec/omniauth-ldap/adaptor_spec.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cdc6774680ba017d52076ea0e48f91c64c639398d68a6efc378e15f176cf7c41
|
4
|
+
data.tar.gz: ac1c47675fb06db77a9e889aaa905fe8dbc5b8ff493b95e7a2ce58fbe3c2b471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90668f491c693ed44cba53bb920e36f05b394d96e103b1f54dd1a55ef1dff87d090af930c01910a78d705083777613190e64542800c1f4a942290b4933b3d1e7
|
7
|
+
data.tar.gz: 02a9cf3dc5b6ab29db564ed28c63ac616b93572ea2ba4df72c388b5b9937bf535d1aebfe6d169154d563ac917121efb8cae87594bd89a7ed04a285a1e69b5540
|
data/.gitignore
CHANGED
@@ -42,6 +42,7 @@ role_map_test.yml
|
|
42
42
|
|
43
43
|
# Specific Files to ignore #
|
44
44
|
############################
|
45
|
+
Gemfile.lock
|
45
46
|
Thumbs.db
|
46
47
|
Icon?
|
47
48
|
.DS_Store?
|
@@ -49,14 +50,14 @@ Icon?
|
|
49
50
|
ehthumbs.db
|
50
51
|
.idea # Rubymine config files
|
51
52
|
/.idea/*
|
52
|
-
|
53
|
+
.ruby-version
|
53
54
|
# Directories to ignore #
|
54
55
|
#########################
|
55
56
|
/public/data/*
|
56
57
|
/jetty/*
|
57
58
|
/solr_conf/*
|
58
59
|
/fedora_conf/*
|
59
|
-
|
60
|
+
scratch.rb
|
60
61
|
# Ignore edited Linux files #
|
61
62
|
#############################
|
62
63
|
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
4
|
+
# configuration file. It makes it possible to enable/disable
|
5
|
+
# certain cops (checks) and to alter their behavior if they accept
|
6
|
+
# any parameters. The file can be placed either in your home
|
7
|
+
# directory or in some project directory.
|
8
|
+
#
|
9
|
+
# RuboCop will start looking for the configuration file in the directory
|
10
|
+
# where the inspected file is and continue its way up to the root directory.
|
11
|
+
#
|
12
|
+
# See https://docs.rubocop.org/rubocop/configuration
|
13
|
+
|
14
|
+
AllCops:
|
15
|
+
TargetRubyVersion: 2.7
|
16
|
+
NewCops: enable
|
17
|
+
Exclude:
|
18
|
+
- 'scratch.rb'
|
19
|
+
|
20
|
+
Gemspec/RequireMFA:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
RSpec/MultipleExpectations:
|
24
|
+
Enabled: true
|
25
|
+
Max: 5
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,300 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2023-01-11 17:46:34 UTC using RuboCop version 1.32.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
# This cop supports safe autocorrection (--autocorrect).
|
11
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
|
12
|
+
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
13
|
+
Bundler/OrderedGems:
|
14
|
+
Enabled: true
|
15
|
+
|
16
|
+
# Offense count: 2
|
17
|
+
# This cop supports safe autocorrection (--autocorrect).
|
18
|
+
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
|
19
|
+
# Include: **/*.gemspec
|
20
|
+
Gemspec/OrderedDependencies:
|
21
|
+
Enabled: true
|
22
|
+
|
23
|
+
# Offense count: 1
|
24
|
+
# Configuration parameters: Include.
|
25
|
+
# Include: **/*.gemspec
|
26
|
+
Gemspec/RequiredRubyVersion:
|
27
|
+
Exclude:
|
28
|
+
- 'omniauth-polaris.gemspec'
|
29
|
+
|
30
|
+
# Offense count: 2
|
31
|
+
# This cop supports safe autocorrection (--autocorrect).
|
32
|
+
Layout/EmptyLines:
|
33
|
+
Enabled: true
|
34
|
+
# Offense count: 1
|
35
|
+
# This cop supports safe autocorrection (--autocorrect).
|
36
|
+
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
|
37
|
+
Layout/ExtraSpacing:
|
38
|
+
Enabled: true
|
39
|
+
# Offense count: 2
|
40
|
+
# This cop supports safe autocorrection (--autocorrect).
|
41
|
+
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
42
|
+
# SupportedStyles: special_inside_parentheses, consistent, align_braces
|
43
|
+
Layout/FirstHashElementIndentation:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
# Offense count: 1
|
47
|
+
# This cop supports safe autocorrection (--autocorrect).
|
48
|
+
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
|
49
|
+
# SupportedHashRocketStyles: key, separator, table
|
50
|
+
# SupportedColonStyles: key, separator, table
|
51
|
+
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
|
52
|
+
Layout/HashAlignment:
|
53
|
+
Enabled: true
|
54
|
+
|
55
|
+
# Offense count: 3
|
56
|
+
# This cop supports safe autocorrection (--autocorrect).
|
57
|
+
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
|
58
|
+
Layout/LeadingCommentSpace:
|
59
|
+
Enabled: true
|
60
|
+
|
61
|
+
# Offense count: 1
|
62
|
+
# This cop supports safe autocorrection (--autocorrect).
|
63
|
+
Layout/LeadingEmptyLines:
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
# Offense count: 1
|
67
|
+
# This cop supports safe autocorrection (--autocorrect).
|
68
|
+
Layout/SpaceAfterComma:
|
69
|
+
Enabled: true
|
70
|
+
|
71
|
+
# Offense count: 2
|
72
|
+
# This cop supports safe autocorrection (--autocorrect).
|
73
|
+
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
74
|
+
# SupportedStylesForExponentOperator: space, no_space
|
75
|
+
Layout/SpaceAroundOperators:
|
76
|
+
Enabled: true
|
77
|
+
|
78
|
+
# Offense count: 3
|
79
|
+
# This cop supports safe autocorrection (--autocorrect).
|
80
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
81
|
+
# SupportedStyles: space, no_space
|
82
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
83
|
+
Layout/SpaceBeforeBlockBraces:
|
84
|
+
Enabled: true
|
85
|
+
|
86
|
+
# Offense count: 1
|
87
|
+
# This cop supports safe autocorrection (--autocorrect).
|
88
|
+
Layout/SpaceBeforeComma:
|
89
|
+
Enabled: true
|
90
|
+
|
91
|
+
# Offense count: 4
|
92
|
+
# This cop supports safe autocorrection (--autocorrect).
|
93
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
|
94
|
+
# SupportedStyles: space, no_space
|
95
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
96
|
+
Layout/SpaceInsideBlockBraces:
|
97
|
+
Enabled: true
|
98
|
+
|
99
|
+
# Offense count: 6
|
100
|
+
# This cop supports safe autocorrection (--autocorrect).
|
101
|
+
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
|
102
|
+
# SupportedStyles: space, no_space, compact
|
103
|
+
# SupportedStylesForEmptyBraces: space, no_space
|
104
|
+
Layout/SpaceInsideHashLiteralBraces:
|
105
|
+
Enabled: true
|
106
|
+
|
107
|
+
# Offense count: 1
|
108
|
+
# This cop supports safe autocorrection (--autocorrect).
|
109
|
+
# Configuration parameters: EnforcedStyle.
|
110
|
+
# SupportedStyles: space, compact, no_space
|
111
|
+
Layout/SpaceInsideParens:
|
112
|
+
Enabled: true
|
113
|
+
|
114
|
+
# Offense count: 1
|
115
|
+
Lint/RescueException:
|
116
|
+
Enabled: true
|
117
|
+
|
118
|
+
# Offense count: 1
|
119
|
+
# This cop supports safe autocorrection (--autocorrect).
|
120
|
+
Lint/ScriptPermission:
|
121
|
+
Enabled: true
|
122
|
+
|
123
|
+
# Offense count: 1
|
124
|
+
# This cop supports safe autocorrection (--autocorrect).
|
125
|
+
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
|
126
|
+
Lint/UselessAccessModifier:
|
127
|
+
Enabled: true
|
128
|
+
|
129
|
+
# Offense count: 2
|
130
|
+
Lint/UselessAssignment:
|
131
|
+
Enabled: true
|
132
|
+
|
133
|
+
# Offense count: 3
|
134
|
+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
135
|
+
Metrics/AbcSize:
|
136
|
+
Max: 39
|
137
|
+
|
138
|
+
# Offense count: 2
|
139
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
140
|
+
# IgnoredMethods: refine
|
141
|
+
Metrics/BlockLength:
|
142
|
+
Max: 63
|
143
|
+
|
144
|
+
# Offense count: 1
|
145
|
+
# Configuration parameters: IgnoredMethods.
|
146
|
+
Metrics/CyclomaticComplexity:
|
147
|
+
Max: 15
|
148
|
+
|
149
|
+
# Offense count: 3
|
150
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
151
|
+
Metrics/MethodLength:
|
152
|
+
Max: 20
|
153
|
+
|
154
|
+
# Offense count: 1
|
155
|
+
# Configuration parameters: IgnoredMethods.
|
156
|
+
Metrics/PerceivedComplexity:
|
157
|
+
Max: 13
|
158
|
+
|
159
|
+
# Offense count: 1
|
160
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
161
|
+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
162
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
163
|
+
Naming/FileName:
|
164
|
+
Exclude:
|
165
|
+
- 'lib/omniauth-polaris.rb'
|
166
|
+
|
167
|
+
# Offense count: 2
|
168
|
+
# Configuration parameters: AllowedConstants.
|
169
|
+
Style/Documentation:
|
170
|
+
Exclude:
|
171
|
+
- 'spec/**/*'
|
172
|
+
- 'test/**/*'
|
173
|
+
- 'lib/omniauth/polaris/adaptor.rb'
|
174
|
+
- 'lib/omniauth/strategies/polaris.rb'
|
175
|
+
|
176
|
+
# Offense count: 2
|
177
|
+
# This cop supports safe autocorrection (--autocorrect).
|
178
|
+
# Configuration parameters: EnforcedStyle.
|
179
|
+
# SupportedStyles: compact, expanded
|
180
|
+
Style/EmptyMethod:
|
181
|
+
Enabled: true
|
182
|
+
# Offense count: 1
|
183
|
+
# This cop supports safe autocorrection (--autocorrect).
|
184
|
+
Style/Encoding:
|
185
|
+
Enabled: true
|
186
|
+
|
187
|
+
# Offense count: 3
|
188
|
+
# This cop supports safe autocorrection (--autocorrect).
|
189
|
+
Style/ExpandPathArguments:
|
190
|
+
Enabled: true
|
191
|
+
|
192
|
+
# Offense count: 1
|
193
|
+
# This cop supports safe autocorrection (--autocorrect).
|
194
|
+
# Configuration parameters: EnforcedStyle.
|
195
|
+
# SupportedStyles: format, sprintf, percent
|
196
|
+
Style/FormatString:
|
197
|
+
Enabled: true
|
198
|
+
|
199
|
+
# Offense count: 1
|
200
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
201
|
+
# Configuration parameters: EnforcedStyle.
|
202
|
+
# SupportedStyles: always, always_true, never
|
203
|
+
Style/FrozenStringLiteralComment:
|
204
|
+
Enabled: true
|
205
|
+
|
206
|
+
# Offense count: 23
|
207
|
+
# This cop supports safe autocorrection (--autocorrect).
|
208
|
+
# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
|
209
|
+
# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
|
210
|
+
# SupportedShorthandSyntax: always, never, either
|
211
|
+
Style/HashSyntax:
|
212
|
+
Enabled: true
|
213
|
+
|
214
|
+
# Offense count: 1
|
215
|
+
# This cop supports safe autocorrection (--autocorrect).
|
216
|
+
# Configuration parameters: EnforcedStyle.
|
217
|
+
# SupportedStyles: both, prefix, postfix
|
218
|
+
Style/NegatedIf:
|
219
|
+
Enabled: true
|
220
|
+
|
221
|
+
# Offense count: 3
|
222
|
+
# This cop supports safe autocorrection (--autocorrect).
|
223
|
+
# Configuration parameters: PreferredDelimiters.
|
224
|
+
Style/PercentLiteralDelimiters:
|
225
|
+
Enabled: true
|
226
|
+
|
227
|
+
# Offense count: 2
|
228
|
+
# This cop supports safe autocorrection (--autocorrect).
|
229
|
+
# Configuration parameters: EnforcedStyle, AllowedCompactTypes.
|
230
|
+
# SupportedStyles: compact, exploded
|
231
|
+
Style/RaiseArgs:
|
232
|
+
Enabled: true
|
233
|
+
|
234
|
+
# Offense count: 2
|
235
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
236
|
+
Style/RedundantInterpolation:
|
237
|
+
Enabled: true
|
238
|
+
|
239
|
+
# Offense count: 2
|
240
|
+
# This cop supports safe autocorrection (--autocorrect).
|
241
|
+
Style/RedundantPercentQ:
|
242
|
+
Enabled: true
|
243
|
+
|
244
|
+
# Offense count: 1
|
245
|
+
# This cop supports safe autocorrection (--autocorrect).
|
246
|
+
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
247
|
+
# SupportedStyles: slashes, percent_r, mixed
|
248
|
+
Style/RegexpLiteral:
|
249
|
+
Enabled: true
|
250
|
+
# Offense count: 5
|
251
|
+
# This cop supports safe autocorrection (--autocorrect).
|
252
|
+
# Configuration parameters: AllowAsExpressionSeparator.
|
253
|
+
Style/Semicolon:
|
254
|
+
Enabled: true
|
255
|
+
|
256
|
+
# Offense count: 3
|
257
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
258
|
+
# Configuration parameters: RequireEnglish.
|
259
|
+
# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
|
260
|
+
Style/SpecialGlobalVars:
|
261
|
+
EnforcedStyle: use_perl_names
|
262
|
+
|
263
|
+
# Offense count: 1
|
264
|
+
# This cop supports safe autocorrection (--autocorrect).
|
265
|
+
Style/StderrPuts:
|
266
|
+
Enabled: true
|
267
|
+
|
268
|
+
# Offense count: 1
|
269
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
270
|
+
# Configuration parameters: Mode.
|
271
|
+
Style/StringConcatenation:
|
272
|
+
Enabled: true
|
273
|
+
|
274
|
+
# Offense count: 7
|
275
|
+
# This cop supports safe autocorrection (--autocorrect).
|
276
|
+
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
|
277
|
+
# SupportedStyles: single_quotes, double_quotes
|
278
|
+
Style/StringLiterals:
|
279
|
+
Enabled: true
|
280
|
+
# Offense count: 1
|
281
|
+
# This cop supports safe autocorrection (--autocorrect).
|
282
|
+
# Configuration parameters: .
|
283
|
+
# SupportedStyles: percent, brackets
|
284
|
+
Style/SymbolArray:
|
285
|
+
EnforcedStyle: percent
|
286
|
+
MinSize: 3
|
287
|
+
|
288
|
+
# Offense count: 1
|
289
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
290
|
+
# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods, AllowComments.
|
291
|
+
# IgnoredMethods: respond_to, define_method
|
292
|
+
Style/SymbolProc:
|
293
|
+
Enabled: true
|
294
|
+
|
295
|
+
# Offense count: 16
|
296
|
+
# This cop supports safe autocorrection (--autocorrect).
|
297
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
|
298
|
+
# URISchemes: http, https
|
299
|
+
Layout/LineLength:
|
300
|
+
Max: 256
|
data/Gemfile
CHANGED
@@ -1,38 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
gem 'rails', '3.2.9'
|
4
|
-
|
5
|
-
# Bundle edge Rails instead:
|
6
|
-
# gem 'rails', :git => 'git://github.com/rails/rails.git'
|
7
|
-
|
8
|
-
gem 'sqlite3'
|
1
|
+
# frozen_string_literal: true
|
9
2
|
|
3
|
+
source 'https://rubygems.org'
|
10
4
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
gem 'sass-rails', '~> 3.2.3'
|
15
|
-
gem 'coffee-rails', '~> 3.2.1'
|
5
|
+
gem 'rubocop', '~> 1.31', require: false
|
6
|
+
gem 'rubocop-performance', '~> 1.15', require: false
|
7
|
+
gem 'rubocop-rspec', '~> 2.12', require: false
|
16
8
|
|
17
|
-
|
18
|
-
# gem 'therubyracer', :platforms => :ruby
|
9
|
+
gemspec
|
19
10
|
|
20
|
-
|
11
|
+
group :test do
|
12
|
+
gem 'rack-test'
|
13
|
+
gem 'simplecov', require: false
|
21
14
|
end
|
22
|
-
|
23
|
-
gem 'jquery-rails'
|
24
|
-
|
25
|
-
# To use ActiveModel has_secure_password
|
26
|
-
# gem 'bcrypt-ruby', '~> 3.0.0'
|
27
|
-
|
28
|
-
# To use Jbuilder templates for JSON
|
29
|
-
# gem 'jbuilder'
|
30
|
-
|
31
|
-
# Use unicorn as the app server
|
32
|
-
# gem 'unicorn'
|
33
|
-
|
34
|
-
# Deploy with Capistrano
|
35
|
-
# gem 'capistrano'
|
36
|
-
|
37
|
-
# To use debugger
|
38
|
-
# gem 'debugger'
|
data/Rakefile
CHANGED
@@ -1,7 +1,21 @@
|
|
1
|
-
|
2
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
1
|
+
# frozen_string_literal: true
|
4
2
|
|
5
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
6
5
|
|
7
|
-
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'rubocop/rake_task'
|
10
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
11
|
+
task.requires << 'rubocop-rspec'
|
12
|
+
task.requires << 'rubocop-performance'
|
13
|
+
task.fail_on_error = true
|
14
|
+
end
|
15
|
+
rescue LoadError
|
16
|
+
task :rubocop do
|
17
|
+
warn 'Rubocop is disabled'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
task default: [:rubocop, :spec]
|
data/bin/console
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Polaris
|
5
|
+
class Adaptor
|
6
|
+
REQUIRED_ADAPTER_CONFIG_KEYS = %i[access_id access_key method http_uri].freeze
|
7
|
+
BASIC_USER_DATA_KEYS = %w[NameFirst NameLast NameMiddle PhoneNumber EmailAddress].freeze
|
8
|
+
METHOD = { POST: :GET }.freeze
|
9
|
+
|
10
|
+
attr_reader :config
|
11
|
+
|
12
|
+
def self.validate!(configuration = {})
|
13
|
+
message = REQUIRED_ADAPTER_CONFIG_KEYS.each_with_object([]) do |name, msg|
|
14
|
+
next msg if configuration[name].present?
|
15
|
+
|
16
|
+
msg << name
|
17
|
+
end
|
18
|
+
|
19
|
+
raise Polaris::ConfigurationError, "#{message.join(' ,')} MUST be provided" unless message.blank?
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(configuration = {})
|
23
|
+
self.class.validate!(configuration)
|
24
|
+
|
25
|
+
@configuration = configuration.dup
|
26
|
+
|
27
|
+
@logger = @configuration.delete(:logger)
|
28
|
+
|
29
|
+
REQUIRED_ADAPTER_CONFIG_KEYS.each do |name|
|
30
|
+
instance_variable_set("@#{name}", @configuration[name])
|
31
|
+
end
|
32
|
+
|
33
|
+
@config = {
|
34
|
+
http_uri: @http_uri,
|
35
|
+
method: @method,
|
36
|
+
access_key: @access_key,
|
37
|
+
access_id: @access_id
|
38
|
+
}
|
39
|
+
|
40
|
+
ensure_method!(@method)
|
41
|
+
@polaris_method = METHOD[@method]
|
42
|
+
end
|
43
|
+
|
44
|
+
def authenticate_patron(pin:, barcode:)
|
45
|
+
# According to the polaris api docs "Date must be within +/- 30 minutes of current time or request will fail"
|
46
|
+
http_date = 15.minutes.from_now.in_time_zone('GMT').strftime('%a, %d %b %Y %H:%M:%S %Z')
|
47
|
+
|
48
|
+
# Authorization hash component
|
49
|
+
authorization_hash = authorization_response(pin, barcode, http_date)
|
50
|
+
|
51
|
+
return if authorization_hash.blank?
|
52
|
+
|
53
|
+
# Details hash component
|
54
|
+
details_hash = details_response(pin, barcode, http_date)
|
55
|
+
|
56
|
+
return if details_hash.blank? || details_hash.dig('PatronBasicDataGetResult', 'PatronBasicData').blank?
|
57
|
+
|
58
|
+
patron_user_hash = authorization_hash['PatronValidateResult'].dup
|
59
|
+
|
60
|
+
patron_user_hash.merge(details_hash.dig('PatronBasicDataGetResult', 'PatronBasicData').slice(*BASIC_USER_DATA_KEYS))
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
def authorization_response(pin, barcode, request_date)
|
66
|
+
patron_validate_uri = "#{@http_uri}/patron/#{barcode}"
|
67
|
+
validation_concated_string = "#{@polaris_method}#{patron_validate_uri}#{request_date}#{pin}"
|
68
|
+
polaris_get_xml_response(patron_validate_uri, request_date, validation_concated_string)
|
69
|
+
end
|
70
|
+
|
71
|
+
def details_response(pin, barcode, request_date)
|
72
|
+
patron_basic_data_uri = "#{@http_uri}#{barcode}/basicdata"
|
73
|
+
details_concated_string = "#{@polaris_method}#{http_basic_data_uri}#{request_date}#{pin}"
|
74
|
+
polaris_get_xml_response(patron_basic_data_uri, request_date, details_concated_string)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def polaris_request_headers(request_date, concated_string)
|
80
|
+
{ 'Date' => request_date, 'Authorization' => "PWS #{@access_id}:#{sha1_sig(concated_string)}" }
|
81
|
+
end
|
82
|
+
|
83
|
+
def polaris_get_xml_response(uri, request_date, concated_string)
|
84
|
+
xml_response = HTTP.get(uri, headers: polaris_request_headers(request_date, concated_string))
|
85
|
+
|
86
|
+
return {} unless xml_response.status.success?
|
87
|
+
|
88
|
+
Hash.from_xml(xml_response.body.to_s)
|
89
|
+
rescue HTTP::Error, OpenSSL::SSL::SSLError => e
|
90
|
+
raise Polaris::ConnectionError, "Could not connect to polaris due to the following error\n #{e.class.name}: #{e.message}"
|
91
|
+
end
|
92
|
+
|
93
|
+
def sha1_sig(concated_string)
|
94
|
+
Base64.strict_encode64(OpenSSL::HMAC.digest('sha1', @access_key, concated_string).to_s)
|
95
|
+
end
|
96
|
+
|
97
|
+
def ensure_method!(method = 'post')
|
98
|
+
normalized_method = method.to_s.upcase.to_sym
|
99
|
+
|
100
|
+
return normalized_method if METHOD.key?(normalized_method)
|
101
|
+
|
102
|
+
available_methods = METHOD.keys.collect(&:inspect).join(', ')
|
103
|
+
|
104
|
+
raise Polaris::ConfigurationError, "#{method} is not one of the available connect methods: #{available_methods}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext/object/blank'
|
5
|
+
require 'active_support/core_ext/time'
|
6
|
+
require 'active_support/core_ext/integer/time'
|
7
|
+
require 'active_support/core_ext/hash/conversions'
|
8
|
+
require 'base64'
|
9
|
+
require 'cgi'
|
10
|
+
require 'openssl'
|
11
|
+
require 'http'
|
12
|
+
require 'omniauth'
|
13
|
+
require 'omniauth/strategies/polaris'
|
14
|
+
|
15
|
+
module OmniAuth
|
16
|
+
module Polaris
|
17
|
+
class PolarisError < StandardError; end
|
18
|
+
class ConfigurationError < StandardError; end
|
19
|
+
class AuthenticationError < StandardError; end
|
20
|
+
class ConnectionError < StandardError; end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'omniauth/polaris/adaptor'
|