lexis_nexis_instant_authenticate 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b871dd55a1db8c597285f39ab56e409c19bcb314
4
+ data.tar.gz: 1ee8d0a1a721c95441c78adf1c91b1d7a28390b5
5
+ SHA512:
6
+ metadata.gz: d773310ab770467337a030369d6aaf54d26cc4e937adbe5251c63ffb96481db585c9de38b29a0c86378b4bc6a2637ee08b59d56352df3f40a273d7c8b88c3a64
7
+ data.tar.gz: d723ca536e5f4300634a496f1e446e19d4f9f26eb8a927088e256014abfd8c868a8d8295631f64d582b7677f94ab8961b51bb8332075734c6ead146506a03cd6
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in lexis_nexis_instant_authenticate.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # LexisNexisInstantAuthenticate
2
+
3
+ Generate & Score Instant Authenicate quizes using Lexis Nexis SOAP API.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'lexis_nexis_instant_authenticate'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install lexis_nexis_instant_authenticate
21
+
22
+ ## Usage
23
+
24
+ ###Create a client.
25
+ ```ruby
26
+ @client = LexisNexisInstantAuthenticate::Client.new(username: ENV['LEXIS_UN'], password: ENV['LEXIS_PW'], flow: "LEXIS_FLOW", transaction_id: SecureRandom.uuid)
27
+ ```
28
+
29
+ Options:
30
+ * `username:` Lexis Nexis supplied username. Typically, "#{account_id}/#{username}"
31
+ * `password:` Lexis Nexis supplied password.
32
+ * `flow:` Name of workflow.
33
+ * `transaction_id:` Optional GUID. This must be the same string between quiz creation & quiz scoring requests. If you do not pass one in on quiz creation, `SecureRandom.uuid` will be used and returned with the generated quiz. That same string must be sent when scoring quiz.
34
+
35
+ ###Generate a quiz.
36
+ ```ruby
37
+ response = @client.create_quiz({first_name: "Joe", middle_name: "L", last_name: "Smith", ssn: "123456789", dob: {day: "01", month: "01", year: "1950"}})
38
+ if response.success?
39
+ return response
40
+ else
41
+ return response.status
42
+ end
43
+ ```
44
+
45
+ Response will have:
46
+ * `response.questions`
47
+ * `response.id`
48
+ * `response.transaction_id`
49
+
50
+
51
+
52
+
53
+ ## Development
54
+
55
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
56
+
57
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
58
+
59
+ ## Contributing
60
+
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/RepPro/lexis_nexis_instant_authenticate.
62
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lexis_nexis_instant_authenticate"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'lexis_nexis_instant_authenticate/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lexis_nexis_instant_authenticate"
8
+ spec.version = LexisNexisInstantAuthenticate::VERSION
9
+ spec.authors = ["Christopher Ostrowski"]
10
+ spec.email = ["chris@reppro.co"]
11
+
12
+ spec.summary = %q{Ruby interface for using LexisNexis Instant Authenticate.}
13
+ spec.homepage = "https://github.com/reppro/lexis_nexis_instant_authenticate"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.11"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec", "~> 3.0"
23
+ spec.add_development_dependency "pry"
24
+ spec.add_dependency 'savon', '~> 2.0'
25
+ spec.add_dependency 'gyoku'
26
+ end
@@ -0,0 +1,27 @@
1
+ #The unholiest of all...
2
+ #This monkey patch exists because LN requires a cleartext password to be sent with digest auth.
3
+ require 'akami'
4
+ if Akami::VERSION == "1.3.1"
5
+ module Akami
6
+ class WSSE
7
+ def wsse_username_token
8
+ if digest?
9
+ token = security_hash :wsse, "UsernameToken",
10
+ "wsse:Username" => username,
11
+ "wsse:Nonce" => Base64.encode64(nonce).chomp,
12
+ "wsu:Created" => timestamp,
13
+ "wsse:Password" => password,
14
+ :attributes! => { "wsse:Password" => { "Type" => PASSWORD_TEXT_URI }, "wsse:Nonce" => { "EncodingType" => BASE64_URI } }
15
+ # clear the nonce after each use
16
+ @nonce = nil
17
+ else
18
+ token = security_hash :wsse, "UsernameToken",
19
+ "wsse:Username" => username,
20
+ "wsse:Password" => password,
21
+ :attributes! => { "wsse:Password" => { "Type" => PASSWORD_TEXT_URI } }
22
+ end
23
+ token
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,80 @@
1
+ require 'savon'
2
+ require_relative './akami_patch'
3
+ require_relative './requests/base'
4
+ require_relative './requests/create_quiz'
5
+ require_relative './requests/score_quiz'
6
+ require_relative './resources/base'
7
+ require_relative './resources/quiz'
8
+ require_relative './resources/score'
9
+
10
+ module LexisNexisInstantAuthenticate
11
+ class Client
12
+ def initialize(options = {})
13
+ @options = options
14
+ end
15
+
16
+ def savon
17
+ @savon ||= Savon.client(wsdl: wsdl_location) do |config|
18
+ config.endpoint endpoint_location
19
+ config.env_namespace :soapenv
20
+ config.raise_errors @options[:production]
21
+ config.log !@options[:production]
22
+ config.namespace_identifier "ws"
23
+
24
+ config.wsse_auth(@options[:username], @options[:password], :digest)
25
+ end
26
+ end
27
+
28
+ def transaction_id
29
+ if @options[:transaction_id]
30
+ @options[:transaction_id]
31
+ else
32
+ @options[:transaction_id] = SecureRandom.uuid
33
+ @options[:transaction_id]
34
+ end
35
+ end
36
+
37
+ def create_quiz(person = {})
38
+ response = call_service(Services::CreateQuiz.new(self, person).to_s)
39
+ Resources::Quiz.new(self, response)
40
+ end
41
+
42
+ def score_quiz(id, responses)
43
+ response = call_service(Services::ScoreQuiz.new(self, id, responses).to_s)
44
+ puts response.hash
45
+ Resources::Score.new(self, response)
46
+ end
47
+
48
+ def flow
49
+ @options[:flow]
50
+ end
51
+
52
+ private
53
+ def build_request
54
+ savon.build_request(:invoke_identity_service)
55
+ end
56
+
57
+ def call_service(request_body, locals = {})
58
+ request = build_request
59
+ request.body = request_body
60
+ response = Savon::Response.new(HTTPI.post(request), savon.globals, locals)
61
+ response
62
+ end
63
+
64
+ def wsdl_location
65
+ if @options[:production]
66
+ "https://identitymanagement.lexisnexis.com/identity-proofing/services/identityProofingServiceWS/v2?wsdl"
67
+ else
68
+ "https://staging.identitymanagement.lexisnexis.com/identity-proofing/services/identityProofingServiceWS/v2?wsdl"
69
+ end
70
+ end
71
+
72
+ def endpoint_location
73
+ if @options[:production]
74
+ else
75
+ "https://staging.identitymanagement.lexisnexis.com/identity-proofing/services/identityProofingServiceWS/v2"
76
+ end
77
+ end
78
+ end
79
+ end
80
+
@@ -0,0 +1,53 @@
1
+ require 'gyoku'
2
+
3
+ module LexisNexisInstantAuthenticate
4
+ module Services
5
+ class Base
6
+ NAMESPACE = "ns".freeze
7
+
8
+ def header
9
+ Savon::Header.new(@client.savon.globals, {})
10
+ end
11
+
12
+ def to_s
13
+ %{
14
+ <soapenv:Envelope
15
+ xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
16
+ xmlns:ws="http://ws.identityproofing.idm.risk.lexisnexis.com/"
17
+ xmlns:ns="http://ns.lexisnexis.com/identity-proofing/1.0"
18
+ xmlns:ns1="http://ns.lexisnexis.com/survey/1.0">
19
+ <soapenv:Header>
20
+ #{header}
21
+ </soapenv:Header>
22
+ <soapenv:Body>
23
+ <ws:invokeIdentityService>
24
+ <ns:identityProofingRequest ns:transactionID="#{@client.transaction_id}">
25
+ <ns:workFlow>#{@client.flow}</ns:workFlow>
26
+ #{to_xml}
27
+ </ns:identityProofingRequest>
28
+ </ws:invokeIdentityService>
29
+ </soapenv:Body>
30
+ </soapenv:Envelope>
31
+ }
32
+ end
33
+
34
+ def to_xml
35
+ Gyoku.xml(request_body, key_converter: -> key { [NAMESPACE, key.camelize(:lower)].join(':') })
36
+ end
37
+
38
+ def request_body
39
+ {}
40
+ end
41
+
42
+ def nil_to_string(object)
43
+ case object
44
+ when Hash then object.each {|k,v| object[k] = "" if v.nil?}
45
+ else object = "" if object.nil?
46
+ end
47
+ return object
48
+ end
49
+
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,60 @@
1
+ module LexisNexisInstantAuthenticate
2
+ module Services
3
+ class CreateQuiz < Base
4
+ def initialize(client, person)
5
+ @person = {dob: {}, address: {}}.merge(person)
6
+ @client = client
7
+ end
8
+
9
+ def request_body
10
+ {
11
+ input_subject: {
12
+ person: {
13
+ name: nil_to_string(name),
14
+ date_of_birth: nil_to_string(date_of_birth),
15
+ age: nil_to_string(age),
16
+ gender: nil_to_string(gender),
17
+ ssn: nil_to_string(ssn),
18
+ address: nil_to_string(address)
19
+ }
20
+ }
21
+ }
22
+ end
23
+
24
+ private
25
+ def name
26
+ {prefix: "", first: @person[:first_name], middle: @person[:middle_name], last: @person[:last_name], suffix: ""}
27
+ end
28
+
29
+ def date_of_birth
30
+ {year: @person[:dob][:year], month: @person[:dob][:month], day: @person[:dob][:day]}
31
+ end
32
+
33
+ def age
34
+ @person[:age]
35
+ end
36
+
37
+ def gender
38
+ return "" unless @person[:gender].present?
39
+ return @person[:gender].capitalize[0] if @person[:gender].length > 1
40
+ return @person[:gender]
41
+ end
42
+
43
+ def ssn
44
+ @person[:ssn].present? && @person[:ssn].gsub(/\D/, "")
45
+ end
46
+
47
+ def address
48
+ {
49
+ street_address_1: @person[:address][:line_1],
50
+ street_address_2: @person[:address][:line_2],
51
+ city: @person[:address][:city],
52
+ state: @person[:address][:state],
53
+ zip5: @person[:address][:zip_code]
54
+ }
55
+ end
56
+
57
+
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,32 @@
1
+ module LexisNexisInstantAuthenticate
2
+ module Services
3
+ class ScoreQuiz < Base
4
+
5
+ def initialize(client, id, quiz_responses)
6
+ @quiz_id = id
7
+ @quiz_responses = quiz_responses
8
+ @client = client
9
+ end
10
+
11
+ def responses_to_hash
12
+ @quiz_responses.map do |resp|
13
+ {
14
+ "#{NAMESPACE}:questionId" => resp[:question_id],
15
+ "#{NAMESPACE}:choiceId" => resp[:choice_id]
16
+ }
17
+ end
18
+ end
19
+
20
+ def request_body
21
+ {
22
+ score_request: {
23
+ quiz_id: @quiz_id,
24
+ answer: responses_to_hash
25
+ }
26
+ }
27
+ end
28
+
29
+
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ module LexisNexisInstantAuthenticate
2
+ module Resources
3
+ class Base
4
+ attr_reader :response
5
+ def initialize(client, response)
6
+ @client = client
7
+ @response = response
8
+ end
9
+
10
+ def transaction_id
11
+ @client.transaction_id
12
+ end
13
+
14
+ def proofing_response
15
+ @response.hash[:envelope][:body][:invoke_identity_service_response][:identity_proofing_response]
16
+ end
17
+
18
+ def success?
19
+ case status
20
+ when "IDENTITY_NOT_LOCATED", "UNABLE_TO_GENERATE" then false
21
+ else true
22
+ end
23
+ end
24
+
25
+ def status
26
+ proofing_response[:status]
27
+ end
28
+
29
+ def product_response
30
+ proofing_response[:product_response]
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,14 @@
1
+ module LexisNexisInstantAuthenticate
2
+ module Resources
3
+ class Quiz < Base
4
+ def questions
5
+ product_response[:questions][:question]
6
+ end
7
+
8
+ def id
9
+ product_response[:questions][:"@ns:quiz_id"]
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ module LexisNexisInstantAuthenticate
2
+ module Resources
3
+ class Score < Base
4
+ def pass?
5
+ status != "FAIL"
6
+ end
7
+
8
+ def score
9
+ product_response[:quiz_score]
10
+ end
11
+
12
+ def quiz_id
13
+ product_response[:quiz_score][:"@ns:quiz_id"]
14
+ end
15
+
16
+ def lex_id
17
+ product_response[:"@ns:lex_id"]
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module LexisNexisInstantAuthenticate
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "lexis_nexis_instant_authenticate/version"
2
+ require "lexis_nexis_instant_authenticate/client"
3
+
4
+ module LexisNexisInstantAuthenticate
5
+
6
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lexis_nexis_instant_authenticate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Ostrowski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: savon
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: gyoku
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - chris@reppro.co
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - README.md
109
+ - Rakefile
110
+ - bin/console
111
+ - bin/setup
112
+ - lexis_nexis_instant_authenticate.gemspec
113
+ - lib/lexis_nexis_instant_authenticate.rb
114
+ - lib/lexis_nexis_instant_authenticate/akami_patch.rb
115
+ - lib/lexis_nexis_instant_authenticate/client.rb
116
+ - lib/lexis_nexis_instant_authenticate/requests/base.rb
117
+ - lib/lexis_nexis_instant_authenticate/requests/create_quiz.rb
118
+ - lib/lexis_nexis_instant_authenticate/requests/score_quiz.rb
119
+ - lib/lexis_nexis_instant_authenticate/resources/base.rb
120
+ - lib/lexis_nexis_instant_authenticate/resources/quiz.rb
121
+ - lib/lexis_nexis_instant_authenticate/resources/score.rb
122
+ - lib/lexis_nexis_instant_authenticate/version.rb
123
+ homepage: https://github.com/reppro/lexis_nexis_instant_authenticate
124
+ licenses: []
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.4.8
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Ruby interface for using LexisNexis Instant Authenticate.
146
+ test_files: []