cased-rails 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +155 -19
- data/lib/cased/rails/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ac8f2d72b0bd9acb03474b7903c2d7d061c6a95d99beb5ea46d8b18dfa2fe37
|
4
|
+
data.tar.gz: 17c1ea4d0eaa1c44a365d51b1a88b04a3c5a3c479f6318ab33bdd03c5163ea02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00c9c0d383329eb6e53432458a578db0c795107822bafcdcb8249bcc5432541ac3b5c7609b288110c8e6b9d531c6ac211399a4b43aeb1988115a28ad03b1bab6
|
7
|
+
data.tar.gz: b9d292a6ea549455cd9f595fe4d764910abfaa9e0f5331595359fb2a3520deec48479c5bf6591606df1e74e40958825b34d3c2b98af8cd7c2a4ec37a3544258b
|
data/README.md
CHANGED
@@ -7,15 +7,19 @@ A Cased client for Ruby on Rails applications in your organization to control an
|
|
7
7
|
- [Installation](#installation)
|
8
8
|
- [Configuration](#configuration)
|
9
9
|
- [Usage](#usage)
|
10
|
-
- [
|
11
|
-
|
12
|
-
|
13
|
-
- [
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
- [Cased CLI](#cased-cli)
|
11
|
+
- [Recording console sessions](#recording-console-sessions)
|
12
|
+
- [Approval workflows for sensitive operations](#approval-workflows-for-sensitive-operations)
|
13
|
+
- [Audit trails](#audit-trails)
|
14
|
+
- [Publishing events to Cased](#publishing-events-to-cased)
|
15
|
+
- [Publishing audit events for all record creation, updates, and deletions automatically](#publishing-audit-events-for-all-record-creation-updates-and-deletions-automatically)
|
16
|
+
- [Retrieving events from a Cased audit trail](#retrieving-events-from-a-cased-audit-trail)
|
17
|
+
- [Retrieving events from multiple Cased audit trails](#retrieving-events-from-multiple-cased-audit-trails)
|
18
|
+
- [Exporting events](#exporting-events)
|
19
|
+
- [Masking & filtering sensitive information](#masking-and-filtering-sensitive-information)
|
20
|
+
- [Disable publishing events](#disable-publishing-events)
|
21
|
+
- [Context](#context)
|
22
|
+
- [Testing](#testing)
|
19
23
|
- [Customizing cased-rails](#customizing-cased-rails)
|
20
24
|
- [Contributing](#contributing)
|
21
25
|
|
@@ -41,6 +45,26 @@ All configuration options available in cased-rails are available to be configure
|
|
41
45
|
|
42
46
|
```ruby
|
43
47
|
Cased.configure do |config|
|
48
|
+
# GUARD_APPLICATION_KEY=guard_application_1ntKX0P4vUbKoc0lMWGiSbrBHcH
|
49
|
+
config.guard_application_key = 'guard_application_1ntKX0P4vUbKoc0lMWGiSbrBHcH'
|
50
|
+
|
51
|
+
# GUARD_USER_TOKEN=user_1oFqlROLNRGVLOXJSsHkJiVmylr
|
52
|
+
config.guard_user_token = 'user_1oFqlROLNRGVLOXJSsHkJiVmylr'
|
53
|
+
|
54
|
+
# DENY_IF_UNREACHABLE=1
|
55
|
+
config.guard_deny_if_unreachable = true
|
56
|
+
|
57
|
+
# Attach metadata to all CLI requests. This metadata will appear in Cased and
|
58
|
+
# any notification source such as email or Slack.
|
59
|
+
#
|
60
|
+
# You are limited to 20 properties and cannot be a nested dictionary. Metadata
|
61
|
+
# specified in the CLI request overrides any configured globally.
|
62
|
+
config.cli.metadata = {
|
63
|
+
rails_env: ENV['RAILS_ENV'],
|
64
|
+
heroku_application: ENV['HEROKU_APP_NAME'],
|
65
|
+
git_commit: ENV['GIT_COMMIT'],
|
66
|
+
}
|
67
|
+
|
44
68
|
# CASED_POLICY_KEY=policy_live_1dQpY5JliYgHSkEntAbMVzuOROh
|
45
69
|
config.policy_key = 'policy_live_1dQpY5JliYgHSkEntAbMVzuOROh'
|
46
70
|
|
@@ -76,7 +100,119 @@ end
|
|
76
100
|
|
77
101
|
## Usage
|
78
102
|
|
79
|
-
###
|
103
|
+
### Cased CLI
|
104
|
+
|
105
|
+
#### Playback console sessions
|
106
|
+
|
107
|
+
Having visibility into production terminal sessions is essential to providing
|
108
|
+
access to sensitive data and critical systems. `cased-rails` can provide complete
|
109
|
+
command line session recordings with minimal configuration.
|
110
|
+
|
111
|
+
First, enable the "Record output" option in your application's settings page on Cased.
|
112
|
+
|
113
|
+
Next grab the application's key from the same settings page and configure
|
114
|
+
`cased-rails` with it either by using an environment variable or manually.
|
115
|
+
|
116
|
+
**Environment variable**
|
117
|
+
|
118
|
+
```
|
119
|
+
GUARD_APPLICATION_KEY=guard_application_1rBCh8o3YMaI1eAKxbrNvnLki3x rails console
|
120
|
+
```
|
121
|
+
|
122
|
+
**Manually**
|
123
|
+
|
124
|
+
```ruby
|
125
|
+
Cased.configure do |config|
|
126
|
+
config.guard_application_key = 'guard_application_1rBCh8o3YMaI1eAKxbrNvnLki3x'
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
By default playback will be saved only when a Rails console is started outside
|
131
|
+
of development and test. When the playback is being saved, by default all
|
132
|
+
parameters other than `id`, `action`, and `controller` will be filtered out.
|
133
|
+
For example:
|
134
|
+
|
135
|
+
```
|
136
|
+
#<User id: "user_1qwkKB8IGxQFlu3C4lI53tCIyZI", organization: "Enterprise">
|
137
|
+
```
|
138
|
+
|
139
|
+
Would become:
|
140
|
+
|
141
|
+
```
|
142
|
+
#<User id: "user_1qwkKB8IGxQFlu3C4lI53tCIyZI", organization: [FILTERED]>
|
143
|
+
```
|
144
|
+
|
145
|
+
If you'd like to configure if filtering is enabled or specify which attributes
|
146
|
+
are not filtered you can do so with:
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
Cased.configure do |config|
|
150
|
+
config.unfiltered_parameters = ['id', 'action', 'controller']
|
151
|
+
config.filter_parameters = Rails.env.production?
|
152
|
+
end
|
153
|
+
```
|
154
|
+
|
155
|
+
#### Approval workflows for sensitive operations
|
156
|
+
|
157
|
+
Adding approval workflows to your controllers is a two step process in your
|
158
|
+
Rails applications.
|
159
|
+
|
160
|
+
First, mount the Rails engine in your routes. The included Rails engine in
|
161
|
+
cased-rails is necessary for the approval workflow to know whether or not it has
|
162
|
+
been requested, approved, denied, canceled or timed out.
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
Rails.application.routes.draw do
|
166
|
+
mount Cased::Rails::Engine => '/cased'
|
167
|
+
|
168
|
+
root to: 'home#show'
|
169
|
+
end
|
170
|
+
```
|
171
|
+
|
172
|
+
To control the requirements for an approval workflow, that must be configured
|
173
|
+
within your CLI application settings on Cased. Some controls include restricting
|
174
|
+
which users or groups can approve the request, if a reason is required, how long
|
175
|
+
until the request times out, and more.
|
176
|
+
|
177
|
+
To start an your approval workflow all that is needed is to call the `guard`
|
178
|
+
method before a request using `before_action`.
|
179
|
+
|
180
|
+
```ruby
|
181
|
+
class AccountsController < ApplicationController
|
182
|
+
before_action :guard, only: %i[update destroy]
|
183
|
+
|
184
|
+
def update
|
185
|
+
if current_account.update(account_params)
|
186
|
+
redirect_to current_account
|
187
|
+
else
|
188
|
+
render :edit
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def destroy
|
193
|
+
if current_account.destroy
|
194
|
+
redirect_to accounts_path
|
195
|
+
else
|
196
|
+
redirect_to current_account
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
private
|
201
|
+
|
202
|
+
def account_params
|
203
|
+
params.require(:account).permit(:name, :description, :email)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
```
|
207
|
+
|
208
|
+
Approval workflows are best started just before data is about to be created,
|
209
|
+
updated, or destroyed. Approval workflows are not intended to control permission
|
210
|
+
to view resources. The actions we recommend guarding are `create`, `update`, and
|
211
|
+
`destroy` based on your needs.
|
212
|
+
|
213
|
+
### Audit trails
|
214
|
+
|
215
|
+
#### Publishing events to Cased
|
80
216
|
|
81
217
|
Once Cased is setup there are two ways to publish your first audit trail event.
|
82
218
|
The first is using the `cased` helper method included in all ActiveRecord models.
|
@@ -151,7 +287,7 @@ end
|
|
151
287
|
|
152
288
|
By publishing the `team.create` audit event within the controller directly as shown you risk not having a complete and comprehensive audit trail for each team created in your application as it may happen in your API, model callbacks, and more.
|
153
289
|
|
154
|
-
|
290
|
+
#### Publishing audit events for all record creation, updates, and deletions automatically
|
155
291
|
|
156
292
|
Cased provides a mixin you can include in your models or in `ApplicationRecord` to automatically publish when new models are created, updated, or destroyed.
|
157
293
|
|
@@ -173,7 +309,7 @@ end
|
|
173
309
|
|
174
310
|
This mixin is intended to get you up and running quickly. You'll likely need to configure your own callbacks to control what exactly gets published to Cased.
|
175
311
|
|
176
|
-
|
312
|
+
#### Retrieving events from a Cased audit trail
|
177
313
|
|
178
314
|
If you plan on retrieving events from your audit trails to power a user facing audit trail or API you must use a Cased API key.
|
179
315
|
|
@@ -200,7 +336,7 @@ class AuditTrailController < ApplicationController
|
|
200
336
|
end
|
201
337
|
```
|
202
338
|
|
203
|
-
|
339
|
+
#### Retrieving events from multiple Cased audit trails
|
204
340
|
|
205
341
|
To retrieve events from one or more Cased audit trails you can configure multiple Cased API keys and retrieve events for each one by fetching their respective clients.
|
206
342
|
|
@@ -227,7 +363,7 @@ results.each do |event|
|
|
227
363
|
end
|
228
364
|
```
|
229
365
|
|
230
|
-
|
366
|
+
#### Exporting events
|
231
367
|
|
232
368
|
Exporting events from Cased allows you to provide users with exports of their own data or to respond to data requests.
|
233
369
|
|
@@ -243,7 +379,7 @@ export = Cased.policy.exports.create(
|
|
243
379
|
export.download_url # => https://api.cased.com/exports/export_1dSHQSNtAH90KA8zGTooMnmMdiD/download?token=eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoidXNlcl8xZFFwWThiQmdFd2RwbWRwVnJydER6TVg0ZkgiLCJ
|
244
380
|
```
|
245
381
|
|
246
|
-
|
382
|
+
#### Masking & filtering sensitive information
|
247
383
|
|
248
384
|
If you are handling sensitive information on behalf of your users you should consider masking or filtering any sensitive information.
|
249
385
|
|
@@ -258,7 +394,7 @@ Cased.publish(
|
|
258
394
|
)
|
259
395
|
```
|
260
396
|
|
261
|
-
|
397
|
+
#### Console Usage
|
262
398
|
|
263
399
|
Most Cased events will be created by users from actions on the website from
|
264
400
|
custom defined events or lifecycle callbacks. The exception is any console
|
@@ -275,7 +411,7 @@ Rails.application.console do
|
|
275
411
|
end
|
276
412
|
```
|
277
413
|
|
278
|
-
|
414
|
+
#### Disable publishing events
|
279
415
|
|
280
416
|
Although rare, there may be times where you wish to disable publishing events to Cased. To do so wrap your transaction inside of a `Cased.disable` block:
|
281
417
|
|
@@ -291,7 +427,7 @@ Or you can configure the entire process to disable publishing events.
|
|
291
427
|
CASED_DISABLE_PUBLISHING=1 bundle exec ruby crawl.rb
|
292
428
|
```
|
293
429
|
|
294
|
-
|
430
|
+
#### Context
|
295
431
|
|
296
432
|
When you include `cased-rails` in your application your Ruby on Rails application is configures a [Rack middleware](https://github.com/cased/cased-ruby/blob/master/lib/cased/rack_middleware.rb) that populates `Cased.context` with the following information for each request:
|
297
433
|
|
@@ -364,7 +500,7 @@ To clear/reset the context:
|
|
364
500
|
Cased.context.clear
|
365
501
|
```
|
366
502
|
|
367
|
-
|
503
|
+
#### Testing
|
368
504
|
|
369
505
|
`cased-rails` provides a Cased::TestHelper test helper class that you can use to test events are being published to Cased.
|
370
506
|
|
data/lib/cased/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cased-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garrett Bjerkhoel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cased-ruby
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.5.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.5.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jbuilder
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|