consent 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/docs/CHANGELOG.md +4 -0
- data/gemfiles/rails_7_1.gemfile.lock +1 -1
- data/gemfiles/rails_7_2.gemfile.lock +1 -1
- data/lib/consent/action.rb +7 -1
- data/lib/consent/permission_definition_payload.rb +2 -1
- data/lib/consent/subject.rb +9 -1
- data/lib/consent/version.rb +1 -1
- data/lib/consent/view.rb +4 -0
- data/lib/consent.rb +5 -15
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a6c7e94dbb1d102068875abf44fd3cc46eca7e437eb6958a5523a2a044790e4d
|
|
4
|
+
data.tar.gz: 86424bc2149fcb347526554c9b4a82822f5f68c728031ae7313fb728efe55c08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cfe9c13129199fdc7c6ae108646bbdd928e7879355896592fa97df8b41cd2039a8a5bbea9c0b44516c94055cb226bb75abf955c0fcb839d58a6f748306cfd039
|
|
7
|
+
data.tar.gz: ccd782f1aa33ff06111b8d0407e849ee4f99a2b610248a368c66f4a4ef9b9c4c45e9501a93109ef5dc29fc7801a2bc496c7c272e59a7e80078f47737f9ee54ac
|
data/Gemfile.lock
CHANGED
data/docs/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
### [2.6.0] - 2026-06-15
|
|
4
|
+
|
|
5
|
+
- Changed permission checksum calculation to use permission data rather than permission file contents. [#438](https://github.com/powerhome/power-tools/pull/438)
|
|
6
|
+
|
|
3
7
|
### [2.5.0] - 2026-05-27
|
|
4
8
|
|
|
5
9
|
- Drop support for Ruby < 3.3 and Rails < 7.1 [#396](https://github.com/powerhome/power-tools/pull/396)
|
data/lib/consent/action.rb
CHANGED
|
@@ -22,12 +22,18 @@ module Consent
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def to_permission_payload
|
|
25
|
+
views = self.views.values.sort
|
|
25
26
|
{
|
|
26
27
|
action: key,
|
|
27
28
|
label: label,
|
|
28
|
-
views: views.
|
|
29
|
+
views: views.map(&:to_permission_payload),
|
|
30
|
+
options: options.except(:views),
|
|
29
31
|
default_view: default_view&.to_permission_payload,
|
|
30
32
|
}
|
|
31
33
|
end
|
|
34
|
+
|
|
35
|
+
def <=>(other)
|
|
36
|
+
key <=> other.key
|
|
37
|
+
end
|
|
32
38
|
end
|
|
33
39
|
end
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
module Consent
|
|
4
4
|
class PermissionDefinitionPayload
|
|
5
5
|
def self.generate
|
|
6
|
+
subjects = Consent.subjects.sort
|
|
6
7
|
{
|
|
7
8
|
consent_version: Consent::VERSION,
|
|
8
|
-
permissions:
|
|
9
|
+
permissions: subjects.map(&:to_permission_payload),
|
|
9
10
|
}
|
|
10
11
|
end
|
|
11
12
|
end
|
data/lib/consent/subject.rb
CHANGED
|
@@ -12,12 +12,20 @@ module Consent
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def to_permission_payload
|
|
15
|
+
actions = self.actions.sort
|
|
16
|
+
views = self.views.values.sort
|
|
15
17
|
{
|
|
16
18
|
subject: key,
|
|
17
19
|
label: label,
|
|
18
20
|
actions: actions.map(&:to_permission_payload),
|
|
19
|
-
views: views.
|
|
21
|
+
views: views.map(&:to_permission_payload),
|
|
20
22
|
}
|
|
21
23
|
end
|
|
24
|
+
|
|
25
|
+
def <=>(other)
|
|
26
|
+
key = Consent::SubjectCoder.dump(key)
|
|
27
|
+
other_key = Consent::SubjectCoder.dump(other.key)
|
|
28
|
+
key <=> other_key
|
|
29
|
+
end
|
|
22
30
|
end
|
|
23
31
|
end
|
data/lib/consent/version.rb
CHANGED
data/lib/consent/view.rb
CHANGED
data/lib/consent.rb
CHANGED
|
@@ -84,24 +84,14 @@ module Consent
|
|
|
84
84
|
Dir[*permission_files].each { |file| Kernel.load(file) }
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
-
#
|
|
87
|
+
# Calculates a deterministic checksum of all permission definitions
|
|
88
88
|
#
|
|
89
|
-
# @
|
|
90
|
-
|
|
91
|
-
def self.subjects_content(paths)
|
|
92
|
-
permission_files = paths.map { |dir| File.join(dir, "*.rb") }
|
|
93
|
-
files = Dir[*permission_files].sort
|
|
94
|
-
files.map { |file| File.read(file) }.join
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# Calculates a deterministic checksum of all permission files
|
|
98
|
-
#
|
|
99
|
-
# @param paths [Array<String,#to_s>] paths where the ruby files are located
|
|
100
|
-
# @return [String] SHA256 hexdigest of all permission file contents
|
|
101
|
-
def self.subjects_checksum(paths)
|
|
89
|
+
# @return [String] SHA256 hexdigest of all permission definitions
|
|
90
|
+
def self.subjects_checksum
|
|
102
91
|
require "digest/sha2"
|
|
103
92
|
|
|
104
|
-
|
|
93
|
+
subjects = Consent.subjects.sort
|
|
94
|
+
Digest::SHA256.hexdigest(subjects.map(&:to_permission_payload).to_json)
|
|
105
95
|
end
|
|
106
96
|
|
|
107
97
|
# Defines a subject with the given key, label and options
|