ronflex 0.1.2 → 0.1.3
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/CHANGELOG.md +8 -0
- data/README.md +4 -4
- data/lib/ronflex/configuration.rb +2 -2
- data/lib/ronflex/rule.rb +1 -1
- data/lib/ronflex/version.rb +1 -1
- data/lib/ronflex.rb +4 -5
- 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: e07dc7d221a3d851d0b547183578aa2f8eb5d6de29362e0c9561074c67b01229
|
4
|
+
data.tar.gz: bb9f4b8d37d4cd95c2d80a0a16b920826fa67fe47ebd18064bcd17764f930373
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cf22dc9e37c2aedcb4628fe2e958a691d192f46272b6e34697d028bb6deecefaf16465edeebf4c6eab73f7ffdaa6535db418a88905c6853c3289e6ed4638190
|
7
|
+
data.tar.gz: 477915e2dae95542a00c61bba7142385b3d989d6bdddfb7193ed8a3486c54274efe24c8215970d6907db22ebd5b2976756ab7afd170ecc2636a3281e99531d94
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,18 +8,18 @@
|
|
8
8
|
|
9
9
|
Run:
|
10
10
|
|
11
|
-
bundle add
|
11
|
+
bundle add ronflex
|
12
12
|
|
13
13
|
Or install it yourself as:
|
14
14
|
|
15
|
-
$ gem install
|
15
|
+
$ gem install ronflex
|
16
16
|
|
17
17
|
## Configuration
|
18
18
|
|
19
19
|
```ruby
|
20
20
|
Ronflex.configure do |config|
|
21
|
-
# The list of paths that are always accessible (no restrictions)
|
22
|
-
config.excluded_path
|
21
|
+
# The list of paths that are always accessible by default "/health_check" and "/favicon.ico"(no restrictions)
|
22
|
+
config.excluded_path += ["/status"]
|
23
23
|
|
24
24
|
# Define a provider for user model (can be a Proc or Lambda)
|
25
25
|
config.provider = ->(env) { User.find_by(api_key: env['HTTP_API_KEY']) }
|
@@ -37,7 +37,7 @@ module Ronflex
|
|
37
37
|
# These paths are ignored by the defined rules.
|
38
38
|
#
|
39
39
|
# @return [Array<String>]
|
40
|
-
DEFAULT_EXCLUDED_PATHS = ["/health_check"]
|
40
|
+
DEFAULT_EXCLUDED_PATHS = ["/health_check", "/favicon.ico"]
|
41
41
|
# Default provider.
|
42
42
|
# by default, it is a lambda which returns `nil`.
|
43
43
|
#
|
@@ -111,7 +111,7 @@ module Ronflex
|
|
111
111
|
# request = OpenStruct.new(path: "/admin/dashboard")
|
112
112
|
# config.allowed?(model, request) # => true or false
|
113
113
|
def allowed?(model, request)
|
114
|
-
rules.any? { |rule| rule.matches?(model, request) }
|
114
|
+
rules.empty? || rules.any? { |rule| rule.matches?(model, request) }
|
115
115
|
end
|
116
116
|
|
117
117
|
|
data/lib/ronflex/rule.rb
CHANGED
@@ -40,7 +40,7 @@ module Ronflex
|
|
40
40
|
# @param request [Object] The request to check (e.g., an HTTP request object).
|
41
41
|
# @return [Boolean] `true` if the model matches the rule's type and satisfies the block's logic, `false` otherwise.
|
42
42
|
def matches?(model, request)
|
43
|
-
|
43
|
+
rule.call(model, request)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/lib/ronflex/version.rb
CHANGED
data/lib/ronflex.rb
CHANGED
@@ -6,18 +6,17 @@ require "ronflex/rest"
|
|
6
6
|
|
7
7
|
module Ronflex
|
8
8
|
class << self
|
9
|
-
# Method to configure `
|
9
|
+
# Method to configure `Ronflex` with a block
|
10
10
|
#
|
11
|
-
# @yield [config] The block receives an instance of `
|
12
|
-
# @yieldparam config [
|
11
|
+
# @yield [config] The block receives an instance of `Ronflex::Configuration`
|
12
|
+
# @yieldparam config [Ronflex::Configuration] The configuration object to modify.
|
13
13
|
def configure
|
14
|
-
@configuration ||= Configuration.new
|
15
14
|
yield @configuration if block_given?
|
16
15
|
end
|
17
16
|
|
18
17
|
# Accesses global configuration
|
19
18
|
#
|
20
|
-
# @return [
|
19
|
+
# @return [Ronflex::Configuration] The global instance of the configuration
|
21
20
|
def configuration
|
22
21
|
@configuration ||= Configuration.new
|
23
22
|
end
|