kdonovan-trufina 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +34 -1
- data/VERSION +1 -1
- data/lib/elements.rb +3 -3
- data/lib/requests.rb +4 -4
- data/lib/responses.rb +1 -5
- data/lib/trufina.rb +5 -4
- data/trufina.gemspec +2 -2
- metadata +4 -3
data/README.rdoc
CHANGED
@@ -125,12 +125,45 @@ which is exactly the format Trufina requires to indicate we want to receive the
|
|
125
125
|
|
126
126
|
(meaning you don't have to remember that Trufina randomly uses Surname, and breaks their convention by using MiddleName rather than simply Middle).
|
127
127
|
|
128
|
+
== Rails Integration
|
129
|
+
|
130
|
+
Personally, I set up a controller dedicated to handling Trufina's postbacks (Success, Failure, and Cancel) as well as their AccessNotification. If (as I'd suggest) you use the +current_user+'s ID as your PRT, then when a user wants to sign up with Trufina:
|
131
|
+
|
132
|
+
redirect_url = Trufina.login_url(current_user.id, :requested => REQUESTED_DATA, :seed => SEED_DATA)
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
The biggest gotcha is that Trufina only uses the PRT for the login_info_request / login_info_response messages -- after that they use their own identifier (the PUR) to indicate which user a given response refers to, so you'll need to store the PUR provided in the login_info_request somewhere and use that going forward. Your success action will end up looking something like this:
|
137
|
+
|
138
|
+
def success
|
139
|
+
info = Trufina.login_info_request( params[:tlid )
|
140
|
+
user = User.find(info.prt)
|
141
|
+
user.pur = info.pur
|
142
|
+
...
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
Also, note that an AccessNotification will be sent immediately upon a new user's registration with Trufina. You can just ignore any AccessNotification with an unknown PUR value, or it's also possible to use the Trufina.info_request in response to this first AccessNotification and avoid using the login_info_response altogether.
|
147
|
+
|
148
|
+
Once you've verified the user, you just need to handle any AccessNotifications you may receive:
|
149
|
+
|
150
|
+
def handle_access_notification
|
151
|
+
tnid = params[:trufina_access_notification][:tnid]
|
152
|
+
info = Trufina.info_request( tnid )
|
153
|
+
user = User.find_by_pur( info.pur )
|
154
|
+
|
155
|
+
# Now take appropriate actions to handle user either revoking or adding
|
156
|
+
# permissions for you to access certain subsets of their verified data.
|
157
|
+
...
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
|
128
162
|
|
129
163
|
== Unsupported functionality
|
130
164
|
|
131
165
|
* Does not handle requesting comparisons or other request attributes
|
132
166
|
* (Note that Trufina[http://www.trufina.com] itself doesn't support maxAge or timeframe yet)
|
133
|
-
* Setting ResidenceAddress seed data isn't yet supported
|
134
167
|
|
135
168
|
== API Version
|
136
169
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
data/lib/elements.rb
CHANGED
@@ -161,10 +161,10 @@ class Trufina
|
|
161
161
|
# element :birth_date, Date, :tag => 'DateOfBirth', :attributes => RESPONSE_XML_ATTRIBUTES
|
162
162
|
# element :birth_country, String, :tag => 'CountryOfBirth', :attributes => RESPONSE_XML_ATTRIBUTES
|
163
163
|
element :phone, String, :tag => 'Phone', :attributes => RESPONSE_XML_ATTRIBUTES
|
164
|
+
element :age, String, :tag => 'Age', :attributes => RESPONSE_XML_ATTRIBUTES
|
164
165
|
element :residence_address, ResidenceAddressResponse, :single => true
|
165
166
|
element :ssn, String, :tag => 'fullSSN', :attributes => RESPONSE_XML_ATTRIBUTES
|
166
167
|
element :last_4_ssn, String, :tag => 'Last4SSN', :attributes => RESPONSE_XML_ATTRIBUTES
|
167
|
-
element :age, String, :tag => 'Age', :attributes => RESPONSE_XML_ATTRIBUTES
|
168
168
|
end
|
169
169
|
|
170
170
|
# Encapsulates all data we can request from Trufina
|
@@ -177,10 +177,10 @@ class Trufina
|
|
177
177
|
element :birth_date, Date, :tag => 'DateOfBirth'
|
178
178
|
element :birth_country, String, :tag => 'CountryOfBirth'
|
179
179
|
element :phone, String, :tag => 'Phone' # If Trufina implemented it, could have timeframe and maxAge attributes
|
180
|
+
element :age, String, :tag => 'Age', :attributes => {:comparison => String}
|
180
181
|
element :residence_address, ResidenceAddressRequest, :single => true # If Trufina implemented it, could have timeframe and maxAge attributes
|
181
182
|
element :ssn, String, :tag => 'fullSSN'
|
182
183
|
element :last_4_ssn, String, :tag => 'Last4SSN'
|
183
|
-
element :age, String, :tag => 'Age', :attributes => {:comparison => String}
|
184
184
|
end
|
185
185
|
|
186
186
|
# Encapsulates all seed data Trufina accepts
|
@@ -193,10 +193,10 @@ class Trufina
|
|
193
193
|
element :birth_date, Date, :tag => 'DateOfBirth'
|
194
194
|
element :birth_country, String, :tag => 'CountryOfBirth'
|
195
195
|
element :phone, String, :tag => 'Phone'
|
196
|
+
element :age, String, :tag => 'Age'
|
196
197
|
element :residence_address, ResidenceAddressResponse, :single => true
|
197
198
|
element :ssn, String, :tag => 'fullSSN'
|
198
199
|
element :last_4_ssn, String, :tag => 'Last4SSN'
|
199
|
-
element :age, String, :tag => 'Age'
|
200
200
|
end
|
201
201
|
|
202
202
|
end
|
data/lib/requests.rb
CHANGED
@@ -46,8 +46,8 @@ class Trufina
|
|
46
46
|
# We have access to Trufina's XML schema, so we might as well validate against it before we hit their servers
|
47
47
|
# http://codeidol.com/other/rubyckbk/XML-and-HTML/Validating-an-XML-Document/
|
48
48
|
def validate_against_schema
|
49
|
-
|
50
|
-
|
49
|
+
lxml = XML::Document.string( self.to_xml )
|
50
|
+
lxml.validate(Trufina.schema)
|
51
51
|
end
|
52
52
|
|
53
53
|
end
|
@@ -131,9 +131,9 @@ class Trufina
|
|
131
131
|
super(args)
|
132
132
|
|
133
133
|
# Trufina is brilliant, and they fail if this isn't in the request (even though they don't actually read the value)
|
134
|
-
seed.residence_address.timeframe = 'current'
|
134
|
+
seed.residence_address.timeframe = 'current' if seed && seed.residence_address
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
138
|
end
|
139
|
-
end
|
139
|
+
end
|
data/lib/responses.rb
CHANGED
@@ -10,11 +10,7 @@ class Trufina
|
|
10
10
|
def self.parse(raw_xml)
|
11
11
|
xml = LibXML::XML::Parser.string(raw_xml).parse
|
12
12
|
|
13
|
-
if Trufina::Config.debug?
|
14
|
-
puts "Received XML:\n\n"
|
15
|
-
puts xml
|
16
|
-
puts "\n\n"
|
17
|
-
end
|
13
|
+
puts "Received XML:\n\n#{xml}\n\n" if Trufina::Config.debug?
|
18
14
|
|
19
15
|
# Try to find an appropriate local happymapper class
|
20
16
|
begin
|
data/lib/trufina.rb
CHANGED
@@ -78,6 +78,11 @@ class Trufina
|
|
78
78
|
sendToTrufina(xml)
|
79
79
|
end
|
80
80
|
|
81
|
+
# Retreive Trufina's XSD Schema
|
82
|
+
def schema
|
83
|
+
@@schema ||= XML::Schema.from_string(open("http://www.trufina.com/api/truapi.xsd").read)
|
84
|
+
end
|
85
|
+
|
81
86
|
|
82
87
|
protected
|
83
88
|
|
@@ -89,10 +94,6 @@ class Trufina
|
|
89
94
|
'/WebServices/API/'
|
90
95
|
end
|
91
96
|
|
92
|
-
def schema
|
93
|
-
@@schema ||= XML::Schema.from_string(open("http://www.trufina.com/api/truapi.xsd").read)
|
94
|
-
end
|
95
|
-
|
96
97
|
# Send the specified XML to Trufina's servers
|
97
98
|
def sendToTrufina(xml)
|
98
99
|
puts "Sending XML to #{domain}#{endpoint}:\n\n#{xml}\n\n" if Trufina::Config.debug?
|
data/trufina.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{trufina}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kali Donovan"]
|
12
|
-
s.date = %q{2009-09-
|
12
|
+
s.date = %q{2009-09-17}
|
13
13
|
s.description = %q{Provides a DSL to easily interact with the XML API offered by Trufina.com, an identity verification company.}
|
14
14
|
s.email = %q{kali.donovan@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kdonovan-trufina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kali Donovan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- trufina.yml.template
|
65
65
|
has_rdoc: false
|
66
66
|
homepage: http://github.com/kdonovan/trufina
|
67
|
+
licenses:
|
67
68
|
post_install_message:
|
68
69
|
rdoc_options:
|
69
70
|
- --charset=UTF-8
|
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
85
|
requirements: []
|
85
86
|
|
86
87
|
rubyforge_project:
|
87
|
-
rubygems_version: 1.
|
88
|
+
rubygems_version: 1.3.5
|
88
89
|
signing_key:
|
89
90
|
specification_version: 3
|
90
91
|
summary: DSL to easily interact with Trufina's verification API
|