loggable_activity 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/GETTING-STARTED.md +1 -0
- data/docker-compose.yml +27 -0
- data/docs/CHANGELOG_md.html +318 -0
- data/docs/CHEAT_SHEET_md.html +168 -0
- data/docs/CODE_OF_CONDUCT_md.html +250 -0
- data/docs/CreateLoggableActivities.html +175 -0
- data/docs/CreateLoggableActivityTables.html +173 -0
- data/docs/GETTING-STARTED_md.html +211 -0
- data/docs/Gemfile.html +153 -0
- data/docs/Gemfile_lock.html +438 -0
- data/docs/LoggableActivity/ActivitiesController.html +160 -0
- data/docs/LoggableActivity/ActivitiesHelper.html +158 -0
- data/docs/LoggableActivity/Activity.html +565 -0
- data/docs/LoggableActivity/ApplicationController.html +97 -0
- data/docs/LoggableActivity/ApplicationHelper.html +91 -0
- data/docs/LoggableActivity/ApplicationJob.html +97 -0
- data/docs/LoggableActivity/ApplicationMailer.html +97 -0
- data/docs/LoggableActivity/ApplicationRecord.html +97 -0
- data/docs/LoggableActivity/Configuration.html +237 -0
- data/docs/LoggableActivity/ConfigurationError.html +142 -0
- data/docs/LoggableActivity/CurrentActor.html +166 -0
- data/docs/LoggableActivity/DataOwner.html +138 -0
- data/docs/LoggableActivity/Encryption.html +321 -0
- data/docs/LoggableActivity/EncryptionError.html +142 -0
- data/docs/LoggableActivity/EncryptionKey.html +399 -0
- data/docs/LoggableActivity/Engine.html +108 -0
- data/docs/LoggableActivity/Error.html +142 -0
- data/docs/LoggableActivity/Generators/InstallGenerator.html +212 -0
- data/docs/LoggableActivity/Generators.html +91 -0
- data/docs/LoggableActivity/Hooks.html +841 -0
- data/docs/LoggableActivity/Payload.html +430 -0
- data/docs/LoggableActivity/Sanitizer.html +134 -0
- data/docs/LoggableActivity/Services/BasePayloadsBuilder.html +472 -0
- data/docs/LoggableActivity/Services/CustomPayloadsBuilder.html +225 -0
- data/docs/LoggableActivity/Services/DestroyPayloadsBuilder.html +396 -0
- data/docs/LoggableActivity/Services/PayloadsBuilder.html +348 -0
- data/docs/LoggableActivity/Services/UpdatePayloadsBuilder.html +540 -0
- data/docs/LoggableActivity/Services.html +93 -0
- data/docs/LoggableActivity.html +173 -0
- data/docs/MIT-LICENSE.html +132 -0
- data/docs/Object.html +110 -0
- data/docs/README_md.html +186 -0
- data/docs/Rakefile.html +134 -0
- data/docs/app/assets/config/loggable_activity_manifest_js.html +126 -0
- data/docs/app/assets/javascripts/loggable_activity/application_js.html +124 -0
- data/docs/app/assets/stylesheets/loggable_activity/activities_scss.html +154 -0
- data/docs/app/assets/stylesheets/loggable_activity/application_scss.html +142 -0
- data/docs/app/views/layouts/loggable_activity/application_html_slim.html +145 -0
- data/docs/app/views/loggable_activity/activities/_activities_html_slim.html +159 -0
- data/docs/created.rid +74 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +687 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/git-org/HEAD.html +126 -0
- data/docs/git-org/config.html +128 -0
- data/docs/git-org/description.html +126 -0
- data/docs/git-org/hooks/applypatch-msg_sample.html +128 -0
- data/docs/git-org/hooks/commit-msg_sample.html +138 -0
- data/docs/git-org/hooks/fsmonitor-watchman_sample.html +302 -0
- data/docs/git-org/hooks/post-update_sample.html +128 -0
- data/docs/git-org/hooks/pre-applypatch_sample.html +128 -0
- data/docs/git-org/hooks/pre-commit_sample.html +174 -0
- data/docs/git-org/hooks/pre-merge-commit_sample.html +133 -0
- data/docs/git-org/hooks/pre-push_sample.html +161 -0
- data/docs/git-org/hooks/pre-rebase_sample.html +282 -0
- data/docs/git-org/hooks/pre-receive_sample.html +144 -0
- data/docs/git-org/hooks/prepare-commit-msg_sample.html +136 -0
- data/docs/git-org/hooks/push-to-checkout_sample.html +178 -0
- data/docs/git-org/hooks/update_sample.html +226 -0
- data/docs/git-org/info/exclude.html +126 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +166 -0
- data/docs/js/darkfish.js +97 -0
- data/docs/js/navigation.js +105 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +110 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/lib/loggable_activity/config_schema_json.html +205 -0
- data/docs/lib/tasks/loggable_activity_tasks_rake.html +128 -0
- data/docs/table_of_contents.html +954 -0
- data/lib/loggable_activity/concerns/current_actor.rb +25 -0
- data/lib/loggable_activity/hooks.rb +41 -19
- data/lib/loggable_activity/version.rb +1 -1
- data/lib/loggable_activity.rb +1 -1
- metadata +114 -3
- data/lib/loggable_activity/concerns/current_user.rb +0 -26
@@ -0,0 +1,138 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class LoggableActivity::DataOwner - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">ActiveRecord::Base
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<div id="method-list-section" class="nav-section">
|
72
|
+
<h3>Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list" role="directory">
|
75
|
+
<li ><a href="#method-i-mark_as_deleted-21">#mark_as_deleted!</a>
|
76
|
+
</ul>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
</nav>
|
81
|
+
|
82
|
+
<main role="main" aria-labelledby="class-LoggableActivity::DataOwner">
|
83
|
+
<h1 id="class-LoggableActivity::DataOwner" class="class">
|
84
|
+
class LoggableActivity::DataOwner
|
85
|
+
</h1>
|
86
|
+
|
87
|
+
<section class="description">
|
88
|
+
|
89
|
+
<p>This class represends an additional data owner for a record. For it to kick in, the data_owner configuration has to be set to true in the loggable_activity.yaml file.</p>
|
90
|
+
|
91
|
+
</section>
|
92
|
+
|
93
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
100
|
+
<header>
|
101
|
+
<h3>Public Instance Methods</h3>
|
102
|
+
</header>
|
103
|
+
|
104
|
+
<div id="method-i-mark_as_deleted-21" class="method-detail ">
|
105
|
+
<div class="method-header">
|
106
|
+
<div class="method-heading">
|
107
|
+
<span class="method-name">mark_as_deleted!</span><span
|
108
|
+
class="method-args">()</span>
|
109
|
+
<span class="method-click-advice">click to toggle source</span>
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
|
113
|
+
<div class="method-description">
|
114
|
+
<p>When a record is deleted, all data owner added to the record is also deleted.</p>
|
115
|
+
|
116
|
+
<div class="method-source-code" id="mark_as_deleted-21-source">
|
117
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/data_owner.rb, line 13</span>
|
118
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">mark_as_deleted!</span>
|
119
|
+
<span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">mark_as_deleted!</span>
|
120
|
+
<span class="ruby-keyword">end</span></pre>
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
|
125
|
+
</div>
|
126
|
+
|
127
|
+
</section>
|
128
|
+
|
129
|
+
</section>
|
130
|
+
</main>
|
131
|
+
|
132
|
+
|
133
|
+
<footer id="validator-badges" role="contentinfo">
|
134
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
135
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
|
136
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
137
|
+
</footer>
|
138
|
+
|
@@ -0,0 +1,321 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>module LoggableActivity::Encryption - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="module">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
<!-- Method Quickref -->
|
65
|
+
<div id="method-list-section" class="nav-section">
|
66
|
+
<h3>Methods</h3>
|
67
|
+
|
68
|
+
<ul class="link-list" role="directory">
|
69
|
+
<li ><a href="#method-c-blank-3F">::blank?</a>
|
70
|
+
<li ><a href="#method-c-decrypt">::decrypt</a>
|
71
|
+
<li ><a href="#method-c-decrypt_array">::decrypt_array</a>
|
72
|
+
<li ><a href="#method-c-decrypt_data">::decrypt_data</a>
|
73
|
+
<li ><a href="#method-c-decrypt_hash">::decrypt_hash</a>
|
74
|
+
<li ><a href="#method-c-encrypt">::encrypt</a>
|
75
|
+
</ul>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
</div>
|
79
|
+
</nav>
|
80
|
+
|
81
|
+
<main role="main" aria-labelledby="module-LoggableActivity::Encryption">
|
82
|
+
<h1 id="module-LoggableActivity::Encryption" class="module">
|
83
|
+
module LoggableActivity::Encryption
|
84
|
+
</h1>
|
85
|
+
|
86
|
+
<section class="description">
|
87
|
+
|
88
|
+
<p>This module is used to encrypt and decrypt attributes</p>
|
89
|
+
|
90
|
+
</section>
|
91
|
+
|
92
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
99
|
+
<header>
|
100
|
+
<h3>Public Class Methods</h3>
|
101
|
+
</header>
|
102
|
+
|
103
|
+
<div id="method-c-blank-3F" class="method-detail ">
|
104
|
+
<div class="method-header">
|
105
|
+
<div class="method-heading">
|
106
|
+
<span class="method-name">blank?</span><span
|
107
|
+
class="method-args">(value)</span>
|
108
|
+
<span class="method-click-advice">click to toggle source</span>
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
|
112
|
+
<div class="method-description">
|
113
|
+
<p>Checks if a value is blank</p>
|
114
|
+
|
115
|
+
<div class="method-source-code" id="blank-3F-source">
|
116
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 69</span>
|
117
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">blank?</span>(<span class="ruby-identifier">value</span>)
|
118
|
+
<span class="ruby-identifier">value</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:empty?</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">empty?</span> <span class="ruby-operator">:</span> <span class="ruby-operator">!</span><span class="ruby-identifier">value</span>
|
119
|
+
<span class="ruby-keyword">end</span></pre>
|
120
|
+
</div>
|
121
|
+
</div>
|
122
|
+
|
123
|
+
|
124
|
+
</div>
|
125
|
+
|
126
|
+
<div id="method-c-decrypt" class="method-detail ">
|
127
|
+
<div class="method-header">
|
128
|
+
<div class="method-heading">
|
129
|
+
<span class="method-name">decrypt</span><span
|
130
|
+
class="method-args">(data, secret_key)</span>
|
131
|
+
<span class="method-click-advice">click to toggle source</span>
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
|
135
|
+
<div class="method-description">
|
136
|
+
<p>Decrypts the given data using the given encryption key</p>
|
137
|
+
|
138
|
+
<p>Example:</p>
|
139
|
+
|
140
|
+
<pre class="ruby"><span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">decrypt</span>(<span class="ruby-string">'SOME_ENCRYPTED_DATA'</span>, <span class="ruby-string">'SECRET_KEY'</span>)
|
141
|
+
</pre>
|
142
|
+
|
143
|
+
<p>Returns:</p>
|
144
|
+
|
145
|
+
<pre class="ruby"><span class="ruby-string">"my secret data"</span>
|
146
|
+
</pre>
|
147
|
+
|
148
|
+
<div class="method-source-code" id="decrypt-source">
|
149
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 45</span>
|
150
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decrypt</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
151
|
+
<span class="ruby-keyword">case</span> <span class="ruby-identifier">data</span>
|
152
|
+
<span class="ruby-keyword">when</span> <span class="ruby-constant">Hash</span>
|
153
|
+
<span class="ruby-identifier">decrypt_hash</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
154
|
+
<span class="ruby-keyword">when</span> <span class="ruby-constant">Array</span>
|
155
|
+
<span class="ruby-identifier">decrypt_array</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
156
|
+
<span class="ruby-keyword">else</span>
|
157
|
+
<span class="ruby-identifier">decrypt_data</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
158
|
+
<span class="ruby-keyword">end</span>
|
159
|
+
<span class="ruby-keyword">end</span></pre>
|
160
|
+
</div>
|
161
|
+
</div>
|
162
|
+
|
163
|
+
|
164
|
+
</div>
|
165
|
+
|
166
|
+
<div id="method-c-decrypt_array" class="method-detail ">
|
167
|
+
<div class="method-header">
|
168
|
+
<div class="method-heading">
|
169
|
+
<span class="method-name">decrypt_array</span><span
|
170
|
+
class="method-args">(data, secret_key)</span>
|
171
|
+
<span class="method-click-advice">click to toggle source</span>
|
172
|
+
</div>
|
173
|
+
</div>
|
174
|
+
|
175
|
+
<div class="method-description">
|
176
|
+
<p>Decrypts an array’s values using the given encryption key</p>
|
177
|
+
|
178
|
+
<div class="method-source-code" id="decrypt_array-source">
|
179
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 64</span>
|
180
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decrypt_array</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
181
|
+
<span class="ruby-identifier">data</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">decrypt</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">secret_key</span>) }
|
182
|
+
<span class="ruby-keyword">end</span></pre>
|
183
|
+
</div>
|
184
|
+
</div>
|
185
|
+
|
186
|
+
|
187
|
+
</div>
|
188
|
+
|
189
|
+
<div id="method-c-decrypt_data" class="method-detail ">
|
190
|
+
<div class="method-header">
|
191
|
+
<div class="method-heading">
|
192
|
+
<span class="method-name">decrypt_data</span><span
|
193
|
+
class="method-args">(data, secret_key)</span>
|
194
|
+
<span class="method-click-advice">click to toggle source</span>
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
|
198
|
+
<div class="method-description">
|
199
|
+
<p>Decrypts individual data using the given encryption key</p>
|
200
|
+
|
201
|
+
<div class="method-source-code" id="decrypt_data-source">
|
202
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 74</span>
|
203
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decrypt_data</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
204
|
+
<span class="ruby-keyword">return</span> <span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">'loggable_activity.activity.deleted'</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">secret_key</span>.<span class="ruby-identifier">nil?</span>
|
205
|
+
<span class="ruby-keyword">return</span> <span class="ruby-string">''</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">blank?</span>
|
206
|
+
|
207
|
+
<span class="ruby-identifier">encryption_key</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">secret_key</span>)
|
208
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">==</span> <span class="ruby-value">32</span>
|
209
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">"Decryption failed: Invalid encoded_key length: #{encryption_key.bytesize}"</span>
|
210
|
+
<span class="ruby-keyword">end</span>
|
211
|
+
|
212
|
+
<span class="ruby-identifier">cipher</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'AES-256-CBC'</span>).<span class="ruby-identifier">decrypt</span>
|
213
|
+
<span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">key</span> = <span class="ruby-identifier">encryption_key</span>
|
214
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-string">'Decryption failed: Invalid data length'</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">></span> <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">iv_len</span>
|
215
|
+
|
216
|
+
<span class="ruby-identifier">raw_data</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">data</span>)
|
217
|
+
<span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">iv</span> = <span class="ruby-identifier">raw_data</span>[<span class="ruby-value">0</span><span class="ruby-operator">...</span><span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">iv_len</span>] <span class="ruby-comment"># Extract IV from the beginning of raw_data</span>
|
218
|
+
<span class="ruby-identifier">decrypted_data</span> = <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">update</span>(<span class="ruby-identifier">raw_data</span>[<span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">iv_len</span><span class="ruby-operator">..</span>]) <span class="ruby-operator">+</span> <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">final</span>
|
219
|
+
|
220
|
+
<span class="ruby-identifier">decrypted_data</span>.<span class="ruby-identifier">force_encoding</span>(<span class="ruby-string">'UTF-8'</span>)
|
221
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span><span class="ruby-operator">::</span><span class="ruby-constant">CipherError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
222
|
+
<span class="ruby-constant">Rails</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">"CipherError Decryption failed: #{e.message}"</span>
|
223
|
+
<span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">'loggable_activity.decryption.failed'</span>)
|
224
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">EncryptionError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
225
|
+
<span class="ruby-constant">Rails</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">"EncryptionError: #{e.message}"</span>
|
226
|
+
<span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">'loggable_activity.decryption.failed'</span>)
|
227
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">ArgumentError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
228
|
+
<span class="ruby-constant">Rails</span>.<span class="ruby-identifier">logger</span>.<span class="ruby-identifier">error</span> <span class="ruby-node">"ArgumentError Decryption failed: #{e.message}"</span>
|
229
|
+
<span class="ruby-constant">I18n</span>.<span class="ruby-identifier">t</span>(<span class="ruby-string">'loggable_activity.decryption.failed'</span>)
|
230
|
+
<span class="ruby-keyword">end</span></pre>
|
231
|
+
</div>
|
232
|
+
</div>
|
233
|
+
|
234
|
+
|
235
|
+
</div>
|
236
|
+
|
237
|
+
<div id="method-c-decrypt_hash" class="method-detail ">
|
238
|
+
<div class="method-header">
|
239
|
+
<div class="method-heading">
|
240
|
+
<span class="method-name">decrypt_hash</span><span
|
241
|
+
class="method-args">(data, secret_key)</span>
|
242
|
+
<span class="method-click-advice">click to toggle source</span>
|
243
|
+
</div>
|
244
|
+
</div>
|
245
|
+
|
246
|
+
<div class="method-description">
|
247
|
+
<p>Decrypts a hash’s values using the given encryption key</p>
|
248
|
+
|
249
|
+
<div class="method-source-code" id="decrypt_hash-source">
|
250
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 57</span>
|
251
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">decrypt_hash</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
252
|
+
<span class="ruby-identifier">data</span>
|
253
|
+
.<span class="ruby-identifier">transform_values</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span> <span class="ruby-identifier">decrypt</span>(<span class="ruby-identifier">value</span>, <span class="ruby-identifier">secret_key</span>) }
|
254
|
+
.<span class="ruby-identifier">transform_keys</span>(<span class="ruby-operator">&</span><span class="ruby-value">:to_sym</span>)
|
255
|
+
<span class="ruby-keyword">end</span></pre>
|
256
|
+
</div>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
|
260
|
+
</div>
|
261
|
+
|
262
|
+
<div id="method-c-encrypt" class="method-detail ">
|
263
|
+
<div class="method-header">
|
264
|
+
<div class="method-heading">
|
265
|
+
<span class="method-name">encrypt</span><span
|
266
|
+
class="method-args">(data, secret_key)</span>
|
267
|
+
<span class="method-click-advice">click to toggle source</span>
|
268
|
+
</div>
|
269
|
+
</div>
|
270
|
+
|
271
|
+
<div class="method-description">
|
272
|
+
<p>Encrypts the given data using the given encryption key</p>
|
273
|
+
|
274
|
+
<p>Example:</p>
|
275
|
+
|
276
|
+
<pre class="ruby"><span class="ruby-operator">::</span><span class="ruby-constant">LoggableActivity</span><span class="ruby-operator">::</span><span class="ruby-constant">Encryption</span>.<span class="ruby-identifier">encrypt</span>(<span class="ruby-string">'my secret data'</span>, <span class="ruby-string">'my secret key'</span>)
|
277
|
+
</pre>
|
278
|
+
|
279
|
+
<p>Returns:</p>
|
280
|
+
|
281
|
+
<pre class="ruby"><span class="ruby-string">"SOME_ENCRYPTED_STRING"</span>
|
282
|
+
</pre>
|
283
|
+
|
284
|
+
<div class="method-source-code" id="encrypt-source">
|
285
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/encryption.rb, line 18</span>
|
286
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">encrypt</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">secret_key</span>)
|
287
|
+
<span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">secret_key</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span>
|
288
|
+
|
289
|
+
<span class="ruby-identifier">encryption_key</span> = <span class="ruby-constant">Base64</span>.<span class="ruby-identifier">decode64</span>(<span class="ruby-identifier">secret_key</span>)
|
290
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">encryption_key</span>.<span class="ruby-identifier">bytesize</span> <span class="ruby-operator">==</span> <span class="ruby-value">32</span>
|
291
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">"Encryption failed: Invalid encoded_key length #{encryption_key.bytesize}"</span>
|
292
|
+
<span class="ruby-keyword">end</span>
|
293
|
+
|
294
|
+
<span class="ruby-identifier">cipher</span> = <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">'AES-256-CBC'</span>).<span class="ruby-identifier">encrypt</span>
|
295
|
+
<span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">key</span> = <span class="ruby-identifier">encryption_key</span>
|
296
|
+
<span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">iv</span> = <span class="ruby-identifier">iv</span> = <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">random_iv</span>
|
297
|
+
|
298
|
+
<span class="ruby-identifier">encrypted</span> = <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">update</span>(<span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">cipher</span>.<span class="ruby-identifier">final</span>
|
299
|
+
<span class="ruby-comment"># Combine IV with encrypted data, encode with Base64 for storage/transmission</span>
|
300
|
+
<span class="ruby-constant">Base64</span>.<span class="ruby-identifier">encode64</span>(<span class="ruby-identifier">iv</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">encrypted</span>)
|
301
|
+
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">OpenSSL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cipher</span><span class="ruby-operator">::</span><span class="ruby-constant">CipherError</span> <span class="ruby-operator">=></span> <span class="ruby-identifier">e</span>
|
302
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncryptionError</span>, <span class="ruby-node">"Encryption failed: #{e.message}"</span>
|
303
|
+
<span class="ruby-keyword">end</span></pre>
|
304
|
+
</div>
|
305
|
+
</div>
|
306
|
+
|
307
|
+
|
308
|
+
</div>
|
309
|
+
|
310
|
+
</section>
|
311
|
+
|
312
|
+
</section>
|
313
|
+
</main>
|
314
|
+
|
315
|
+
|
316
|
+
<footer id="validator-badges" role="contentinfo">
|
317
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
318
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
|
319
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
320
|
+
</footer>
|
321
|
+
|
@@ -0,0 +1,142 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class LoggableActivity::EncryptionError - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="class">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="../index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
<div id="class-metadata">
|
59
|
+
|
60
|
+
|
61
|
+
<div id="parent-class-section" class="nav-section">
|
62
|
+
<h3>Parent</h3>
|
63
|
+
|
64
|
+
<p class="link">StandardError
|
65
|
+
</div>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
<!-- Method Quickref -->
|
71
|
+
<div id="method-list-section" class="nav-section">
|
72
|
+
<h3>Methods</h3>
|
73
|
+
|
74
|
+
<ul class="link-list" role="directory">
|
75
|
+
<li class="calls-super" ><a href="#method-c-new">::new</a>
|
76
|
+
</ul>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
</nav>
|
81
|
+
|
82
|
+
<main role="main" aria-labelledby="class-LoggableActivity::EncryptionError">
|
83
|
+
<h1 id="class-LoggableActivity::EncryptionError" class="class">
|
84
|
+
class LoggableActivity::EncryptionError
|
85
|
+
</h1>
|
86
|
+
|
87
|
+
<section class="description">
|
88
|
+
|
89
|
+
<p><a href="Error.html"><code>Error</code></a> class for encryption.</p>
|
90
|
+
|
91
|
+
</section>
|
92
|
+
|
93
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section">
|
100
|
+
<header>
|
101
|
+
<h3>Public Class Methods</h3>
|
102
|
+
</header>
|
103
|
+
|
104
|
+
<div id="method-c-new" class="method-detail ">
|
105
|
+
<div class="method-header">
|
106
|
+
<div class="method-heading">
|
107
|
+
<span class="method-name">new</span><span
|
108
|
+
class="method-args">(msg = '')</span>
|
109
|
+
<span class="method-click-advice">click to toggle source</span>
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
|
113
|
+
<div class="method-description">
|
114
|
+
|
115
|
+
<div class="method-calls-super">
|
116
|
+
Calls superclass method
|
117
|
+
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<div class="method-source-code" id="new-source">
|
121
|
+
<pre><span class="ruby-comment"># File lib/loggable_activity/error.rb, line 13</span>
|
122
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">msg</span> = <span class="ruby-string">''</span>)
|
123
|
+
<span class="ruby-keyword">super</span>
|
124
|
+
<span class="ruby-keyword">end</span></pre>
|
125
|
+
</div>
|
126
|
+
</div>
|
127
|
+
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
</section>
|
132
|
+
|
133
|
+
</section>
|
134
|
+
</main>
|
135
|
+
|
136
|
+
|
137
|
+
<footer id="validator-badges" role="contentinfo">
|
138
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
139
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.7.0.
|
140
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
141
|
+
</footer>
|
142
|
+
|