action_authorization 0.3.0 → 0.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ec2bb21ab2cd6e7a6fc961076931ba385d327272437427e2653f07dabd0901
|
4
|
+
data.tar.gz: 6b01e8b343d8fc465e9ad5c36bf76f515ca7f1b809bfc28f2ba4f66d106f6d5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d91740824f6f3aca60f1c98de4ac7fea9e3e231e710e1ce027465cb8908596264885710c0d3b3ca98d8cd877d26d9ef83a3d1c6848624aa171f2bedc0798fe52
|
7
|
+
data.tar.gz: 8f6b3b6a14ba8533f6361aa1cd1241141ee246ee1561098cfa88fba41b53d64124be783a4a45ec01b4ef95fe2f3628b327b17f4171652be16e4e8d33bb775d4a
|
data/Rakefile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ActionAuthorization
|
2
4
|
class BasePolicy
|
3
5
|
attr_accessor :user, :object
|
4
6
|
|
5
7
|
def self.type
|
6
|
-
name.
|
8
|
+
name.delete_suffix("Policy")
|
7
9
|
end
|
8
10
|
|
9
11
|
def self.type_class
|
@@ -21,6 +23,7 @@ module ActionAuthorization
|
|
21
23
|
|
22
24
|
# create alias to object from subclass name
|
23
25
|
def self.inherited(klass)
|
26
|
+
super
|
24
27
|
klass.send(:alias_method, klass.type.underscore, :object)
|
25
28
|
end
|
26
29
|
|
data/lib/action_authorization.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "active_support/core_ext/module/delegation"
|
2
4
|
require "active_support/core_ext/string/inflections"
|
3
5
|
require "action_authorization/version"
|
@@ -14,11 +16,9 @@ module ActionAuthorization
|
|
14
16
|
protected
|
15
17
|
|
16
18
|
def authorize(object, action: action_name, policy_class: nil)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
raise ActionAuthorization::AuthorizationFailure
|
21
|
-
end
|
19
|
+
raise AuthorizationFailure unless policy(object, policy_class).public_send(:"#{action}?")
|
20
|
+
|
21
|
+
object
|
22
22
|
end
|
23
23
|
|
24
24
|
def policy(object, policy_class = nil)
|
@@ -26,6 +26,6 @@ module ActionAuthorization
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def policy_class_for(object)
|
29
|
-
"#{object.
|
29
|
+
"#{object.model_name}Policy".constantize
|
30
30
|
end
|
31
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Baldwin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2024-07-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -45,7 +45,6 @@ licenses:
|
|
45
45
|
- MIT
|
46
46
|
metadata:
|
47
47
|
homepage_uri: https://github.com/wwidea/action_authorization
|
48
|
-
source_code_uri: https://github.com/wwidea/action_authorization
|
49
48
|
rubygems_mfa_required: 'true'
|
50
49
|
post_install_message:
|
51
50
|
rdoc_options: []
|
@@ -55,14 +54,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
54
|
requirements:
|
56
55
|
- - ">="
|
57
56
|
- !ruby/object:Gem::Version
|
58
|
-
version:
|
57
|
+
version: 3.1.0
|
59
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
59
|
requirements:
|
61
60
|
- - ">="
|
62
61
|
- !ruby/object:Gem::Version
|
63
62
|
version: '0'
|
64
63
|
requirements: []
|
65
|
-
rubygems_version: 3.
|
64
|
+
rubygems_version: 3.5.11
|
66
65
|
signing_key:
|
67
66
|
specification_version: 4
|
68
67
|
summary: Rails controller object-level action authorization.
|