tidas 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5cc58b3207e47f086cc6b329923dfa6828076edc
4
- data.tar.gz: 16df291cedf64e1216b0b5d9a3dccce10885cb65
3
+ metadata.gz: b70ec3f1fa8b0266b1a1a53bf11671f4925a93df
4
+ data.tar.gz: 009410733727a658057c9f0852bddef46e5d67ee
5
5
  SHA512:
6
- metadata.gz: 1ba75c78c179a113be7f04144c85ae6434d2a635b7ead5bb5acfad18d9df47194888d2176517e3dc65db62504c7c7b752504ee004c335ff88adaada3c2ba5ee9
7
- data.tar.gz: efaad392817cb09f7782e50516cc2fd22ab9ca8450535a3bbe2a09d9409e1d0dcd3d64987720926a320d24d91dbfd19210fb655b6e7bce595631245858ed7b62
6
+ metadata.gz: ac8f4b54e75f92ea561b05b101ddf0ffe2edc84840d6132ad62e4ef3a199f03663944522c31240109343a75245688d281bfc24cfc7c04f2f2c7d9a21d8c4434a
7
+ data.tar.gz: eda07e911c5e64cb3e4c8e92ae7071d43d3281f37ca981a09b39705d9d9dca744f2a28e70a43103346eb3347e962ce22cd52a9e4b15f23e5086e9332487dec23
@@ -0,0 +1,15 @@
1
+ engines:
2
+ duplication:
3
+ enabled: true
4
+ config:
5
+ languages:
6
+ - ruby
7
+ rubocop:
8
+ enabled: true
9
+ bundler-audit:
10
+ enabled: true
11
+
12
+ ratings:
13
+ paths:
14
+ - Gemfile.lock
15
+ - "**.rb"
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update bundler
4
+ rvm:
5
+ - 2.2
data/Gemfile CHANGED
@@ -6,6 +6,7 @@ gem 'json'
6
6
 
7
7
  group :test do
8
8
  gem 'simplecov'
9
+ gem 'codeclimate-test-reporter', require: nil
9
10
  end
10
11
 
11
12
  group :development do
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # tidas-ruby
2
- middleware for tidas integrations
3
-
2
+ [![Build Status](https://travis-ci.org/tidas/tidas-middleware-ruby.svg?branch=master)](https://travis-ci.org/tidas/tidas-middleware-ruby)
4
3
  [![Code Climate](https://codeclimate.com/github/tidas/tidas-middleware-ruby/badges/gpa.svg)](https://codeclimate.com/github/tidas/tidas-middleware-ruby)
5
4
  [![Test Coverage](https://codeclimate.com/github/tidas/tidas-middleware-ruby/badges/coverage.svg)](https://codeclimate.com/github/tidas/tidas-middleware-ruby/coverage)
6
5
 
6
+ Middleware for tidas integrations
7
+
7
8
  ## Configuration
8
9
 
9
10
  Tidas is configured either with preset ENVs, or with a configuration method explained in the API below
@@ -15,8 +16,6 @@ Configuration Params:
15
16
  * **application**: `<Tidas::Configuration.application>` The application identifier you use to silo your users within our database
16
17
  * **timeout**: `<Tidas::Configuration.timeout>` If our default of 20s is too long a timeout for you, optionally set a shorter one for your implementation
17
18
 
18
- ***
19
-
20
19
  ## API v0.1
21
20
 
22
21
  #### Check Tidas availability ####
@@ -35,8 +34,6 @@ Returns:
35
34
  * **Timeout**: `<Tidas::TimeoutError>` Timeout Error Object
36
35
  * **50x**: `<Tidas::ServerError>` Server Error Object
37
36
 
38
- ***
39
-
40
37
  #### Configure Tidas ####
41
38
 
42
39
  This section is used to set needed ENVs for Tidas to operate.
@@ -65,8 +62,6 @@ Example:
65
62
  )
66
63
  ```
67
64
 
68
- ***
69
-
70
65
  #### Enroll Identity ####
71
66
 
72
67
  This call is used to store a public key in our database. You can optionally supply a `tidas_id` if you want identity lookups to use your id conventions. Additionally, you can send an `overwrite` option to update an existing ID with a new identity object.
@@ -98,8 +93,6 @@ Tidas::Identity.enroll(
98
93
  )
99
94
  ```
100
95
 
101
- ***
102
-
103
96
  #### Validate Data####
104
97
 
105
98
  This call is used to validate data using a provided hash, signature, and a stored public key from our database. The call works by looking up a user with the provided tidas_id, then validating that the data provided was signed with that users' public key. Upon successful validation, the data is made available in the `SuccessfulResult` object.
@@ -120,8 +113,6 @@ Examples:
120
113
 
121
114
  `Tidas::Identity.validate(data:<Tidas::ValidationData>, tidas_id:"e_23423")`
122
115
 
123
- ***
124
-
125
116
  #### Deactivate User####
126
117
 
127
118
  This call is used to deactivate users which you no longer wish to validate data from. Users are not deleted, but made inactive in case they decide to use the application again
@@ -141,8 +132,6 @@ Examples:
141
132
 
142
133
  `Tidas::Identity.deactivate(tidas_id:'24jdpoifj24')`
143
134
 
144
- ***
145
-
146
135
  #### Activate User####
147
136
 
148
137
  This call is used to activate users which you previously deactivated, and want to begin validating data from again.
@@ -162,8 +151,6 @@ Examples:
162
151
 
163
152
  `Tidas::Identity.activate(tidas_id:'24jdpoifj24')`
164
153
 
165
- ***
166
-
167
154
  #### List Users####
168
155
 
169
156
  This call is used to list users of your application, both active and deactivated. public keys are trimmed for brevity, but the accompanying `get(<tidas_id>)` method will return this info if you ask for a specific user's information
@@ -183,8 +170,6 @@ Examples:
183
170
 
184
171
  `Tidas::Identity.index`
185
172
 
186
- ***
187
-
188
173
  #### Get User Info####
189
174
 
190
175
  This call is used to retrieve information about a specific user, including their public_key
@@ -206,8 +191,6 @@ Examples:
206
191
  `Tidas::Identity.get('24jdpoifj24')`
207
192
 
208
193
 
209
- ***
210
-
211
194
  ## Tidas Error Types
212
195
 
213
196
  List of Errors which may be encountered when using the tidas
@@ -57,8 +57,8 @@ module Tidas
57
57
  end
58
58
 
59
59
  def self.timeout
60
- if timeout = @timeout
61
- timeout.to_i
60
+ if @timeout
61
+ @timeout.to_i
62
62
  else
63
63
  20
64
64
  end
@@ -1,4 +1,5 @@
1
1
  require 'base64'
2
+ require 'digest'
2
3
 
3
4
  module Tidas
4
5
  module Utilities
@@ -80,11 +81,37 @@ module Tidas
80
81
  type_byte + len_bytes + data_to_sign
81
82
  end
82
83
 
84
+ def timestamp_hex
85
+ begin
86
+ epoch_time = @parsed_data[:timestamp].to_i
87
+ return [epoch_time].pack('q<')
88
+ rescue
89
+ return []
90
+ end
91
+ end
92
+
93
+ def computed_hash_bytes
94
+ Digest::SHA1.digest(@parsed_data[:data_to_sign]+timestamp_hex).bytes
95
+ end
96
+
97
+ def provided_hash_bytes
98
+ @parsed_data[:data_hash].bytes
99
+ end
100
+
101
+ def data_matches_hash?
102
+ begin
103
+ return computed_hash_bytes == provided_hash_bytes
104
+ rescue
105
+ return false
106
+ end
107
+ end
108
+
83
109
  def valid?
84
110
  return false if @parsed_data[:platform] == nil
85
111
  return false if @parsed_data[:timestamp] == nil
86
112
  return false if @parsed_data[:data_hash] == nil
87
113
  return false if @parsed_data[:signature] == nil
114
+ return false unless data_matches_hash?
88
115
  true
89
116
  end
90
117
 
@@ -1,4 +1,4 @@
1
1
  module Tidas
2
2
  # tidas version
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
@@ -1,3 +1,8 @@
1
+ if ENV['CODECLIMATE_REPO_TOKEN']
2
+ require "codeclimate-test-reporter"
3
+ CodeClimate::TestReporter.start
4
+ end
5
+
1
6
  require 'rspec'
2
7
  require 'tidas/version'
3
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tidas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Esposito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -100,9 +100,11 @@ executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
+ - ".codeclimate.yml"
103
104
  - ".document"
104
105
  - ".gitignore"
105
106
  - ".rspec"
107
+ - ".travis.yml"
106
108
  - ".yardopts"
107
109
  - ChangeLog.md
108
110
  - Gemfile