castle-rb 1.0.7 → 1.1.0

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: 044f4df4fdec6a5c05cac418db767b783ade84bf
4
- data.tar.gz: 5ad7cc7f684515c57a497f5e7c672c09b81c99c7
3
+ metadata.gz: 14c88aa4187d1472edffa7a1328a531adfacb630
4
+ data.tar.gz: 6e0ff46033e273306871b309870eed825fdce994
5
5
  SHA512:
6
- metadata.gz: 1bb216d7e733031e7fe10fe9b9a367e7c40b7f2c2b1047c0a521d7d12cc2edaf717e104d8b29b9da9e71856446b58a6472c86b774ab386fe9d2208e6bc581948
7
- data.tar.gz: aa1f6b64f72947412abf27b952914052332279cdd9af7db70f3a6a261f905c3a246eb436dbe4edbed1b941fb23de318418481aa513cb62bacca289219b5e070b
6
+ metadata.gz: 26ef23b6a5d415c948280ccd7482d36036015a7baa1a51b3ca663311436de007cdcb8c41cb5eb90330a1fb8ca1bd4ad9586f24cc0c479813741d4e419052c863
7
+ data.tar.gz: 46c1e598df715fd40793efab6e17b96c343c059df01d35cb2a90d5f424052682baff95d14218d4b2a45df1c2b94cc63f91f861080d7e21efb916c2bb360f7bf2
data/README.md CHANGED
@@ -54,6 +54,9 @@ castle.track(
54
54
  - `$logout.succeeded`: Record when a user logs out.
55
55
  - `$registration.succeeded`: Capture account creation, both when a user signs up as well as when created manually by an administrator.
56
56
  - `$registration.failed`: Record when an account failed to be created.
57
+ - `$challenge.requested`: Record when a user is prompted with additional verification, such as two-factor authentication or a captcha.
58
+ - `$challenge.succeeded`: Record when additional verification was successful.
59
+ - `$challenge.failed`: Record when additional verification failed.
57
60
  - `$password_reset.requested`: An attempt was made to reset a user’s password.
58
61
  - `$password_reset.succeeded`: The user completed all of the steps in the password reset process and the password was successfully reset. Password resets **do not** required knowledge of the current password.
59
62
  - `$password_reset.failed`: Use to record when a user failed to reset their password.
@@ -82,6 +85,20 @@ _castle('setUser', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1...y4PCIXrz1Ejs');
82
85
 
83
86
  **Important:** Make sure you enable **Secure mode** in the [Castle dashboard](https://dashboard.castle.io/settings/general).
84
87
 
88
+ ## Exceptions
89
+
90
+ `Castle::Error` will be thrown if the Castle API returns a 400 or a 500 level HTTP response. You can also choose to catch a more [finegrained error](https://github.com/castle/castle-ruby/blob/master/lib/castle-rb/errors.rb).
91
+
92
+ ```ruby
93
+ begin
94
+ castle.track(
95
+ name: '$login.succeeded',
96
+ user_id: user.id)
97
+ rescue Castle::Error => e
98
+ puts e.message
99
+ end
100
+ ```
101
+
85
102
  ## Configuration
86
103
 
87
104
  ```ruby
@@ -33,7 +33,8 @@ module Castle
33
33
  @request_context = {
34
34
  ip: request.ip,
35
35
  user_agent: request.user_agent,
36
- cookie_id: cookies['__cid'] || ''
36
+ cookie_id: cookies['__cid'] || '',
37
+ headers: header_string(request)
37
38
  }
38
39
  end
39
40
 
@@ -137,5 +138,20 @@ module Castle
137
138
  end
138
139
 
139
140
  alias_method :recommend, :recommendation
141
+
142
+ private
143
+
144
+ def header_string(request)
145
+ scrub_headers = ['Cookie']
146
+
147
+ headers = request.env.keys.grep(/^HTTP_/).map do |header|
148
+ name = header.gsub(/^HTTP_/, '').split('_').map(&:capitalize).join('-')
149
+ unless scrub_headers.include?(name)
150
+ { name => request.env[header] }
151
+ end
152
+ end.compact.inject(:merge)
153
+
154
+ MultiJson.encode(headers)
155
+ end
140
156
  end
141
157
  end
@@ -1,3 +1,3 @@
1
1
  module Castle
2
- VERSION = "1.0.7"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: castle-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-07 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: her