gdpr_admin 1.4.2 → 1.6.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
  SHA256:
3
- metadata.gz: 0ec941ad2e7b5708375e99e895438d87a0ba4d444793e160eb856153e50416e4
4
- data.tar.gz: 3c32e9b55b937b8ae8f3985aa94303cdacb2886ecd310b698cc42131425ae449
3
+ metadata.gz: b8f6f1437e957b783de64f6a16847142b7eff9ebf14428b8c1d6d8db4011dcde
4
+ data.tar.gz: 4ea36ea2245d25a95883501dbe7727149bb1f971c4e5f1de27c00621f7526f69
5
5
  SHA512:
6
- metadata.gz: 6ce2ae11b31814d2a70da810245f966247a1bff2080a6c65c44b25df4d29af81bebd04f8e0d8ae75b25f06c1a9d5e0ca40941620404dd1f8dae9f02d05a9cac0
7
- data.tar.gz: bfee1582a3e58facf792acf4ca077cf880009d3c75129d39d6ad2203481a86805b8a2de3fd505c2246f3ebf3fd052e53e3dca4defba73657f51ebde27a0cba8a
6
+ metadata.gz: 931d742f6e132f9aac3ebf5babf2cf3596b49827830cb90dc5c169f4b8fd570c45ce43a0be4b76c62bea487b2b0bbe1dc643d8486f7e9e58ff35610c4313b77b
7
+ data.tar.gz: 9f19d2ad664ea3dd95b73524ca914e4f1cd2bdcacfd83a305a2128443bee3036da70002f21bb9487614b4593c2350d0a815f36d70239a2005b34f6a1e27d83a1
data/README.md CHANGED
@@ -47,12 +47,20 @@ Implement the methods `#scope`, `#export` and `#erase` for the new data policy.
47
47
  able to access the `GdprAdmin::Request` object in any method by calling the method `request` - you can, therefore, have
48
48
  different scopes and different removal behaviors depending on the request.
49
49
 
50
+ Optinally, you may declare a `#subject_scope` method with logic for scoping subject data. If this method is not present,
51
+ it will fallback to the `#scope` method.
52
+
50
53
  ```ruby
51
54
  class UserDataPolicy < GdprAdmin::ApplicationDataPolicy
52
55
  def scope
53
56
  User.with_deleted.where(updated_at: ...request.data_older_than)
54
57
  end
55
58
 
59
+ # Optional
60
+ def subject_scope
61
+ scope.where(email: request.subject)
62
+ end
63
+
56
64
  def erase(user)
57
65
  user.update_columns(
58
66
  first_name: 'Anonymous',
@@ -3,7 +3,7 @@
3
3
  module GdprAdmin
4
4
  class Request < ApplicationRecord
5
5
  belongs_to :tenant, class_name: GdprAdmin.config.tenant_class
6
- belongs_to :requester, class_name: GdprAdmin.config.requester_class, optional: true
6
+ belongs_to :requester, polymorphic: true, optional: true
7
7
 
8
8
  VALID_STATUS_TRANSITIONS = {
9
9
  pending: %i[processing],
@@ -29,20 +29,26 @@ module GdprAdmin
29
29
  after_create_commit :schedule_processing
30
30
 
31
31
  validates :status, presence: true
32
+ validates :subject, presence: true, if: :subject_request?
33
+ validates :subject, absence: true, unless: :subject_request?
32
34
  validate :valid_status_transition?
33
35
 
34
36
  def process!
35
37
  GdprAdmin.load_data_policies
36
- with_lock { processing! }
38
+ reload.with_lock { processing! }
37
39
  with_lock do
38
40
  process_policies
39
41
  completed!
40
42
  end
41
43
  rescue StandardError
42
- with_lock { failed! }
44
+ failed!
43
45
  raise
44
46
  end
45
47
 
48
+ def subject_request?
49
+ export_subject? || erase_subject?
50
+ end
51
+
46
52
  def erase?
47
53
  erase_data? || erase_subject?
48
54
  end
@@ -4,7 +4,7 @@ class CreateGdprAdminRequests < ActiveRecord::Migration[7.0]
4
4
  def change
5
5
  create_table :gdpr_admin_requests do |t|
6
6
  t.references :tenant, null: false, foreign_key: { to_table: :organizations }
7
- t.references :requester, null: true, foreign_key: { to_table: :admin_users }
7
+ t.references :requester, null: true, polymorphic: true
8
8
  t.string :request_type, null: false
9
9
  t.string :status, default: 'pending', null: false
10
10
  t.datetime :data_older_than, null: false
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddSubjectToGdprAdminRequests < ActiveRecord::Migration[7.0]
4
+ def change
5
+ add_column :gdpr_admin_requests, :subject, :string
6
+ end
7
+ end
@@ -43,14 +43,14 @@ module GdprAdmin
43
43
  def process
44
44
  GdprAdmin.config.tenant_adapter.with_tenant(request.tenant) do
45
45
  run_preprocessors
46
- process_scope(scope)
46
+ process_scope
47
47
  rescue SkipDataPolicyError
48
48
  nil
49
49
  end
50
50
  end
51
51
 
52
- def process_scope(scope)
53
- scope.find_each do |record|
52
+ def process_scope
53
+ policy_scope.find_each do |record|
54
54
  process_record(record)
55
55
  end
56
56
  end
@@ -59,6 +59,12 @@ module GdprAdmin
59
59
 
60
60
  attr_reader :request
61
61
 
62
+ def policy_scope
63
+ return subject_scope if request.subject_request? && respond_to?(:subject_scope)
64
+
65
+ scope
66
+ end
67
+
62
68
  def process_record(record)
63
69
  run_record_preprocessors(record)
64
70
  export(record) if request.export?
@@ -2,13 +2,12 @@
2
2
 
3
3
  module GdprAdmin
4
4
  class Configuration
5
- attr_accessor :tenant_class, :requester_class, :data_policies_path, :default_job_queue,
5
+ attr_accessor :tenant_class, :data_policies_path, :default_job_queue,
6
6
  :erasure_grace_period, :export_grace_period
7
7
  attr_writer :tenant_adapter
8
8
 
9
9
  def initialize
10
10
  @tenant_class = 'Organization'
11
- @requester_class = 'AdminUser'
12
11
  @tenant_adapter = TenantAdapters::ActsAsTenantAdapter.new
13
12
  @data_policies_path = Rails.root.join('app', 'gdpr')
14
13
  @default_job_queue = :default
@@ -2,6 +2,6 @@
2
2
 
3
3
  # :nocov:
4
4
  module GdprAdmin
5
- VERSION = '1.4.2'
5
+ VERSION = '1.6.0'
6
6
  end
7
7
  # :nocov:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gdpr_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-03 00:00:00.000000000 Z
11
+ date: 2023-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -156,6 +156,7 @@ files:
156
156
  - config/routes.rb
157
157
  - db/migrate/20230212185817_create_gdpr_admin_requests.rb
158
158
  - db/migrate/20230216171202_create_gdpr_admin_data_retention_policies.rb
159
+ - db/migrate/20230417104258_add_subject_to_gdpr_admin_requests.rb
159
160
  - lib/gdpr_admin.rb
160
161
  - lib/gdpr_admin/anonymizers/company_anonymizer.rb
161
162
  - lib/gdpr_admin/anonymizers/contact_anonymizer.rb