checken 0.0.6 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d6da20c9c5c377f6900bbaa81ec9bd0ebc8e874324147bb742a8041016486e2d
4
- data.tar.gz: e41b4eed54d9fbfa10163b46e05315e5cea479186548629831544ffc7493b536
3
+ metadata.gz: 136b7129a73d4d87eeee9f73edde72db1be22457a828e2c3cad94a88ecb7f0a9
4
+ data.tar.gz: 20069b119a49574d80f8a0db1d55ca5fba6d00903e397a71b7ecc54aac44e762
5
5
  SHA512:
6
- metadata.gz: b79c4b6803e77bed927201fc92cf02185a9a1cfb98d6e597ed2a2bf2c59d0343557987bd6b419722ac68738f591691a4197d776f84458699bfaf9b779b10c26e
7
- data.tar.gz: a7087a9d2c198704960eeb36480f018de292ffb20d4a41d88fc3cfcc12957e52e5d176a7636ede7ee0019c0b601d7b49a15d9ad6e39e2c9832c859252ead39b0
6
+ metadata.gz: 4e2d93519751eff404c72e9ec1ccab7b5a5aef99db3803bd59874e7975c254d96cb1680b4ff65681754b737e6c4abc083edf064e58d477ba6a0c5b4acdb042e8
7
+ data.tar.gz: 4a4b30492281eaab15a22ce019688aae46229fb8c94c4c4703b717a2f04cf8646afc3f2da4f35505ca9f3a410d76ad0cfb752abee7abb71fc1b771f37948cde7
@@ -17,13 +17,14 @@ module Checken
17
17
  # when performing permission checks using `restrict`.
18
18
  end
19
19
 
20
- def restrict(permission_path, object = nil, options = {}, strict: true)
20
+ def restrict(permission_path, object = nil, options = {})
21
21
  if checken_user_proxy.nil?
22
22
  user = send(Checken.current_schema.config.current_user_method_name)
23
23
  user_proxy = Checken.current_schema.config.user_proxy_class.new(user)
24
24
  else
25
25
  user_proxy = checken_user_proxy
26
26
  end
27
+ strict = options.delete(:strict) { true }
27
28
  granted_permissions = Checken.current_schema.check_permission!(permission_path, user_proxy, object, strict: strict)
28
29
  granted_permissions.each do |permission|
29
30
  granted_checken_permissions << permission
@@ -44,8 +45,8 @@ module Checken
44
45
  options = options_if_object_provided
45
46
  end
46
47
 
47
- strict = options.delete(:strict) { true }
48
- restrict_options = options.delete(:restrict_options)
48
+ restrict_options = options.delete(:restrict_options) || {}
49
+ restrict_options[:strict] = options.delete(:strict) { true }
49
50
 
50
51
  before_action(options) do
51
52
  if object.is_a?(Proc)
@@ -62,7 +63,7 @@ module Checken
62
63
  resolved_object = nil
63
64
  end
64
65
 
65
- restrict(permission_path, resolved_object, restrict_options, strict: strict)
66
+ restrict(permission_path, resolved_object, restrict_options)
66
67
  end
67
68
 
68
69
  end
@@ -309,7 +309,7 @@ module Checken
309
309
 
310
310
  group.schema.update_schema(
311
311
  {
312
- path => {
312
+ path_with_namespace => {
313
313
  type: :permission,
314
314
  description: description,
315
315
  group: group.path
@@ -171,7 +171,7 @@ module Checken
171
171
 
172
172
  schema.update_schema(
173
173
  {
174
- path => {
174
+ path_with_namespace => {
175
175
  type: :group,
176
176
  name: name,
177
177
  description: description,
@@ -25,6 +25,7 @@ module Checken
25
25
  # Add configuration for this schema
26
26
  def configure(&block)
27
27
  block.call(@config)
28
+ set_namespace if @config.namespace
28
29
  end
29
30
 
30
31
  # Does the given user have the appropriate permissions to handle?
@@ -169,5 +170,11 @@ module Checken
169
170
  raise error
170
171
  end
171
172
 
173
+ def set_namespace
174
+ @schema.transform_keys! do |key|
175
+ "#{@config.namespace}#{@config.namespace_delimiter}#{key}"
176
+ end
177
+ end
178
+
172
179
  end
173
180
  end
@@ -1,3 +1,3 @@
1
1
  module Checken
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-01 00:00:00.000000000 Z
11
+ date: 2025-04-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An authorization framework for Ruby & Rails applications.
14
14
  email: