authorized_persona 0.9.0 → 0.11.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/.github/workflows/ci.yml +27 -0
- data/.gitignore +0 -2
- data/.rubocop.yml +6 -1
- data/.rubocop_todo.yml +100 -0
- data/.ruby-version +1 -0
- data/Appraisals +16 -0
- data/Gemfile.lock +155 -0
- data/README.md +6 -5
- data/Rakefile +2 -0
- data/authorized_persona.gemspec +11 -6
- data/gemfiles/rails_6_1.gemfile +10 -0
- data/gemfiles/rails_6_1.gemfile.lock +152 -0
- data/gemfiles/rails_7_0.gemfile +10 -0
- data/gemfiles/rails_7_0.gemfile.lock +152 -0
- data/gemfiles/rails_7_1.gemfile +10 -0
- data/gemfiles/rails_7_1.gemfile.lock +184 -0
- data/lib/authorized_persona/authorization.rb +7 -5
- data/lib/authorized_persona/persona.rb +5 -3
- data/lib/authorized_persona/railtie.rb +3 -1
- data/lib/authorized_persona/version.rb +3 -1
- data/lib/authorized_persona/view_helpers.rb +2 -0
- data/lib/authorized_persona.rb +2 -0
- metadata +58 -33
- data/.travis.yml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ed24355127dcd3b98f5763e523d65e578fdafb0957d4eebd51655d6c1fac4d5
|
4
|
+
data.tar.gz: f529b2dd701b51e85257a07e0b451c1c6271e714a622f90620a318d3709970db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d28d814d7f2238c6b4bfc41eb64713890bc1a5f9bd6917e4a2719df0b80fc615d366936bb3955d61ddb0d2b626ae8dd845395c7967e754b4aefd7c0d486e6287
|
7
|
+
data.tar.gz: 986de5cc04424cfdfb5662a0ba8114922b46344083e1134510c8ee844f7b5c8220cd92eb094d3e94e431691b32c0068af390a6d38acb8548a08bbfab1f09d3a3
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: ['3.0', '3.2']
|
12
|
+
gemfile:
|
13
|
+
- gemfiles/rails_6_1.gemfile
|
14
|
+
- gemfiles/rails_7_0.gemfile
|
15
|
+
- gemfiles/rails_7_1.gemfile
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
env:
|
20
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
24
|
+
- name: Run tests and linter
|
25
|
+
env:
|
26
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
27
|
+
run: bundle exec rake
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 99999`
|
3
|
+
# on 2023-05-09 13:01:46 UTC using RuboCop version 1.50.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 4
|
10
|
+
# Configuration parameters: EnforcedStyle, AllowedGems, Include.
|
11
|
+
# SupportedStyles: Gemfile, gems.rb, gemspec
|
12
|
+
# Include: **/*.gemspec, **/Gemfile, **/gems.rb
|
13
|
+
Gemspec/DevelopmentDependencies:
|
14
|
+
Exclude:
|
15
|
+
- 'authorized_persona.gemspec'
|
16
|
+
|
17
|
+
# Offense count: 1
|
18
|
+
# Configuration parameters: Severity, Include.
|
19
|
+
# Include: **/*.gemspec
|
20
|
+
Gemspec/RequiredRubyVersion:
|
21
|
+
Exclude:
|
22
|
+
- 'authorized_persona.gemspec'
|
23
|
+
|
24
|
+
# Offense count: 1
|
25
|
+
# This cop supports safe autocorrection (--autocorrect).
|
26
|
+
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
27
|
+
# URISchemes: http, https
|
28
|
+
Layout/LineLength:
|
29
|
+
Exclude:
|
30
|
+
- 'lib/authorized_persona/authorization.rb'
|
31
|
+
|
32
|
+
# Offense count: 2
|
33
|
+
Lint/MissingSuper:
|
34
|
+
Exclude:
|
35
|
+
- 'spec/authorized_persona/authorization_spec.rb'
|
36
|
+
- 'spec/authorized_persona/persona_spec.rb'
|
37
|
+
|
38
|
+
# Offense count: 2
|
39
|
+
# This cop supports safe autocorrection (--autocorrect).
|
40
|
+
Lint/RedundantCopDisableDirective:
|
41
|
+
Exclude:
|
42
|
+
- 'lib/authorized_persona/authorization.rb'
|
43
|
+
|
44
|
+
# Offense count: 1
|
45
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
46
|
+
Metrics/PerceivedComplexity:
|
47
|
+
Exclude:
|
48
|
+
- 'lib/authorized_persona/persona.rb'
|
49
|
+
|
50
|
+
# Offense count: 2
|
51
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
52
|
+
RSpec/BeEq:
|
53
|
+
Exclude:
|
54
|
+
- 'spec/authorized_persona/authorization_spec.rb'
|
55
|
+
|
56
|
+
# Offense count: 1
|
57
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
58
|
+
Rails/ActiveSupportOnLoad:
|
59
|
+
Exclude:
|
60
|
+
- 'lib/authorized_persona/railtie.rb'
|
61
|
+
|
62
|
+
# Offense count: 1
|
63
|
+
Rails/I18nLocaleTexts:
|
64
|
+
Exclude:
|
65
|
+
- 'lib/authorized_persona/authorization.rb'
|
66
|
+
|
67
|
+
# Offense count: 1
|
68
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
69
|
+
# Configuration parameters: Include.
|
70
|
+
# Include: **/Rakefile, **/*.rake
|
71
|
+
Rails/RakeEnvironment:
|
72
|
+
Exclude:
|
73
|
+
- 'Rakefile'
|
74
|
+
|
75
|
+
# Offense count: 1
|
76
|
+
# This cop supports safe autocorrection (--autocorrect).
|
77
|
+
Rake/Desc:
|
78
|
+
Exclude:
|
79
|
+
- 'Rakefile'
|
80
|
+
|
81
|
+
# Offense count: 2
|
82
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
83
|
+
# Configuration parameters: AllowedReceivers.
|
84
|
+
# AllowedReceivers: Thread.current
|
85
|
+
Style/HashEachMethods:
|
86
|
+
Exclude:
|
87
|
+
- 'lib/authorized_persona/persona.rb'
|
88
|
+
|
89
|
+
# Offense count: 1
|
90
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
91
|
+
Style/MapToHash:
|
92
|
+
Exclude:
|
93
|
+
- 'lib/authorized_persona/authorization.rb'
|
94
|
+
|
95
|
+
# Offense count: 1
|
96
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
97
|
+
# Configuration parameters: Mode.
|
98
|
+
Style/StringConcatenation:
|
99
|
+
Exclude:
|
100
|
+
- 'lib/authorized_persona/view_helpers.rb'
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/Appraisals
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
appraise 'rails-6-1' do
|
4
|
+
gem 'railties', '~> 6.1.0'
|
5
|
+
gem 'activemodel', '~>6.1.0'
|
6
|
+
end
|
7
|
+
|
8
|
+
appraise 'rails-7-0' do
|
9
|
+
gem 'railties', '~> 7.0.0'
|
10
|
+
gem 'activemodel', '~>7.0.0'
|
11
|
+
end
|
12
|
+
|
13
|
+
appraise 'rails-7-1' do
|
14
|
+
gem 'railties', '~> 7.1.0'
|
15
|
+
gem 'activemodel', '~>7.1.0'
|
16
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
authorized_persona (0.11.0)
|
5
|
+
railties (>= 6.1, < 7.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (7.0.8.4)
|
11
|
+
actionview (= 7.0.8.4)
|
12
|
+
activesupport (= 7.0.8.4)
|
13
|
+
rack (~> 2.0, >= 2.2.4)
|
14
|
+
rack-test (>= 0.6.3)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
17
|
+
actionview (7.0.8.4)
|
18
|
+
activesupport (= 7.0.8.4)
|
19
|
+
builder (~> 3.1)
|
20
|
+
erubi (~> 1.4)
|
21
|
+
rails-dom-testing (~> 2.0)
|
22
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
23
|
+
activemodel (7.0.8.4)
|
24
|
+
activesupport (= 7.0.8.4)
|
25
|
+
activesupport (7.0.8.4)
|
26
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
27
|
+
i18n (>= 1.6, < 2)
|
28
|
+
minitest (>= 5.1)
|
29
|
+
tzinfo (~> 2.0)
|
30
|
+
appraisal (2.5.0)
|
31
|
+
bundler
|
32
|
+
rake
|
33
|
+
thor (>= 0.14.0)
|
34
|
+
ast (2.4.2)
|
35
|
+
betterlint (1.7.0)
|
36
|
+
rubocop (> 1.0)
|
37
|
+
rubocop-performance
|
38
|
+
rubocop-rails
|
39
|
+
rubocop-rake
|
40
|
+
rubocop-rspec (>= 2.24)
|
41
|
+
builder (3.3.0)
|
42
|
+
concurrent-ruby (1.3.4)
|
43
|
+
crass (1.0.6)
|
44
|
+
diff-lcs (1.5.0)
|
45
|
+
erubi (1.13.0)
|
46
|
+
i18n (1.14.5)
|
47
|
+
concurrent-ruby (~> 1.0)
|
48
|
+
json (2.7.1)
|
49
|
+
language_server-protocol (3.17.0.3)
|
50
|
+
loofah (2.22.0)
|
51
|
+
crass (~> 1.0.2)
|
52
|
+
nokogiri (>= 1.12.0)
|
53
|
+
method_source (1.0.0)
|
54
|
+
minitest (5.25.1)
|
55
|
+
nokogiri (1.16.7-arm64-darwin)
|
56
|
+
racc (~> 1.4)
|
57
|
+
nokogiri (1.16.7-x86_64-darwin)
|
58
|
+
racc (~> 1.4)
|
59
|
+
nokogiri (1.16.7-x86_64-linux)
|
60
|
+
racc (~> 1.4)
|
61
|
+
parallel (1.24.0)
|
62
|
+
parser (3.2.2.4)
|
63
|
+
ast (~> 2.4.1)
|
64
|
+
racc
|
65
|
+
racc (1.8.1)
|
66
|
+
rack (2.2.9)
|
67
|
+
rack-test (2.1.0)
|
68
|
+
rack (>= 1.3)
|
69
|
+
rails-dom-testing (2.2.0)
|
70
|
+
activesupport (>= 5.0.0)
|
71
|
+
minitest
|
72
|
+
nokogiri (>= 1.6)
|
73
|
+
rails-html-sanitizer (1.6.0)
|
74
|
+
loofah (~> 2.21)
|
75
|
+
nokogiri (~> 1.14)
|
76
|
+
railties (7.0.8.4)
|
77
|
+
actionpack (= 7.0.8.4)
|
78
|
+
activesupport (= 7.0.8.4)
|
79
|
+
method_source
|
80
|
+
rake (>= 12.2)
|
81
|
+
thor (~> 1.0)
|
82
|
+
zeitwerk (~> 2.5)
|
83
|
+
rainbow (3.1.1)
|
84
|
+
rake (13.1.0)
|
85
|
+
regexp_parser (2.8.3)
|
86
|
+
rexml (3.3.6)
|
87
|
+
strscan
|
88
|
+
rspec (3.12.0)
|
89
|
+
rspec-core (~> 3.12.0)
|
90
|
+
rspec-expectations (~> 3.12.0)
|
91
|
+
rspec-mocks (~> 3.12.0)
|
92
|
+
rspec-core (3.12.2)
|
93
|
+
rspec-support (~> 3.12.0)
|
94
|
+
rspec-expectations (3.12.3)
|
95
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
96
|
+
rspec-support (~> 3.12.0)
|
97
|
+
rspec-mocks (3.12.6)
|
98
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
99
|
+
rspec-support (~> 3.12.0)
|
100
|
+
rspec-support (3.12.1)
|
101
|
+
rubocop (1.59.0)
|
102
|
+
json (~> 2.3)
|
103
|
+
language_server-protocol (>= 3.17.0)
|
104
|
+
parallel (~> 1.10)
|
105
|
+
parser (>= 3.2.2.4)
|
106
|
+
rainbow (>= 2.2.2, < 4.0)
|
107
|
+
regexp_parser (>= 1.8, < 3.0)
|
108
|
+
rexml (>= 3.2.5, < 4.0)
|
109
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
110
|
+
ruby-progressbar (~> 1.7)
|
111
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
112
|
+
rubocop-ast (1.30.0)
|
113
|
+
parser (>= 3.2.1.0)
|
114
|
+
rubocop-capybara (2.19.0)
|
115
|
+
rubocop (~> 1.41)
|
116
|
+
rubocop-factory_bot (2.24.0)
|
117
|
+
rubocop (~> 1.33)
|
118
|
+
rubocop-performance (1.20.1)
|
119
|
+
rubocop (>= 1.48.1, < 2.0)
|
120
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
121
|
+
rubocop-rails (2.23.1)
|
122
|
+
activesupport (>= 4.2.0)
|
123
|
+
rack (>= 1.1)
|
124
|
+
rubocop (>= 1.33.0, < 2.0)
|
125
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
126
|
+
rubocop-rake (0.6.0)
|
127
|
+
rubocop (~> 1.0)
|
128
|
+
rubocop-rspec (2.25.0)
|
129
|
+
rubocop (~> 1.40)
|
130
|
+
rubocop-capybara (~> 2.17)
|
131
|
+
rubocop-factory_bot (~> 2.22)
|
132
|
+
ruby-progressbar (1.13.0)
|
133
|
+
strscan (3.1.0)
|
134
|
+
thor (1.3.0)
|
135
|
+
tzinfo (2.0.6)
|
136
|
+
concurrent-ruby (~> 1.0)
|
137
|
+
unicode-display_width (2.5.0)
|
138
|
+
zeitwerk (2.6.12)
|
139
|
+
|
140
|
+
PLATFORMS
|
141
|
+
arm64-darwin-22
|
142
|
+
x86_64-darwin-22
|
143
|
+
x86_64-linux
|
144
|
+
|
145
|
+
DEPENDENCIES
|
146
|
+
activemodel (>= 6.1, < 7.2)
|
147
|
+
appraisal
|
148
|
+
authorized_persona!
|
149
|
+
betterlint
|
150
|
+
bundler
|
151
|
+
rake
|
152
|
+
rspec (~> 3.0)
|
153
|
+
|
154
|
+
BUNDLED WITH
|
155
|
+
2.4.21
|
data/README.md
CHANGED
@@ -107,23 +107,24 @@ end
|
|
107
107
|
class ApplicationController < ActionController::Base
|
108
108
|
include AuthorizedPersona::Authorization
|
109
109
|
|
110
|
-
# Any
|
110
|
+
# Any hooks your authentication library needs to ensure
|
111
111
|
# `current_user` is set before # authorization, e.g.:
|
112
112
|
#
|
113
|
-
#
|
113
|
+
# before_action :authenticate_user!
|
114
114
|
|
115
115
|
authorize_persona class_name: "User"
|
116
116
|
|
117
117
|
# or optionally override the method name we use to fetch current_[class_name] e.g.:
|
118
118
|
#
|
119
|
-
# authorize_persona class_name: "User",
|
119
|
+
# authorize_persona class_name: "User", current_user_method: :current_fancy_user
|
120
120
|
|
121
121
|
# Your code here...
|
122
122
|
end
|
123
123
|
```
|
124
124
|
|
125
125
|
At this point, no user is authorized to make a request to any descendent
|
126
|
-
of `ApplicationController`.
|
126
|
+
of `ApplicationController`. Note that any unauthenticated controllers (e.g. authentication
|
127
|
+
controllers) will need to have authorization disabled via `skip_before_action :authorize!`.
|
127
128
|
|
128
129
|
3. Grant privileges in your base controller or any subclass:
|
129
130
|
|
@@ -185,7 +186,7 @@ class BillSearch
|
|
185
186
|
end
|
186
187
|
|
187
188
|
def bills
|
188
|
-
# AuthorizedPersona::Persona provides #[tier]
|
189
|
+
# AuthorizedPersona::Persona provides #[tier]_or_above? methods for all defined tiers
|
189
190
|
relation = searcher.admin_or_above? ? Bills.all : Bills.nonsensitive
|
190
191
|
relation.where('title like ?', query)
|
191
192
|
end
|
data/Rakefile
CHANGED
data/authorized_persona.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require "authorized_persona/version"
|
@@ -11,24 +13,27 @@ Gem::Specification.new do |spec|
|
|
11
13
|
spec.summary = "the simplest authorization library you will ever love"
|
12
14
|
spec.description = "AuthorizedPersona is a rails implementation of Betterment's Persona Centric Authorization pattern"
|
13
15
|
spec.homepage = "https://github.com/Betterment/authorized_persona"
|
14
|
-
spec.license
|
16
|
+
spec.license = "MIT"
|
17
|
+
spec.required_ruby_version = ">= 3.0"
|
15
18
|
|
16
19
|
# Specify which files should be added to the gem when it is released.
|
17
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
-
spec.files
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
23
|
end
|
21
24
|
spec.bindir = "exe"
|
22
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
26
|
spec.require_paths = ["lib"]
|
24
27
|
|
25
|
-
rails_version_range = [">=
|
28
|
+
rails_version_range = [">= 6.1", "< 7.2"]
|
26
29
|
|
27
30
|
spec.add_dependency "railties", *rails_version_range
|
28
31
|
|
29
32
|
spec.add_development_dependency "activemodel", *rails_version_range
|
30
|
-
spec.add_development_dependency "
|
31
|
-
spec.add_development_dependency "
|
33
|
+
spec.add_development_dependency "appraisal"
|
34
|
+
spec.add_development_dependency "betterlint"
|
35
|
+
spec.add_development_dependency "bundler"
|
36
|
+
spec.add_development_dependency "rake"
|
32
37
|
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
-
spec.
|
38
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
34
39
|
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
authorized_persona (0.11.0)
|
5
|
+
railties (>= 6.1, < 7.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (6.1.7.6)
|
11
|
+
actionview (= 6.1.7.6)
|
12
|
+
activesupport (= 6.1.7.6)
|
13
|
+
rack (~> 2.0, >= 2.0.9)
|
14
|
+
rack-test (>= 0.6.3)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
17
|
+
actionview (6.1.7.6)
|
18
|
+
activesupport (= 6.1.7.6)
|
19
|
+
builder (~> 3.1)
|
20
|
+
erubi (~> 1.4)
|
21
|
+
rails-dom-testing (~> 2.0)
|
22
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
23
|
+
activemodel (6.1.7.6)
|
24
|
+
activesupport (= 6.1.7.6)
|
25
|
+
activesupport (6.1.7.6)
|
26
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
27
|
+
i18n (>= 1.6, < 2)
|
28
|
+
minitest (>= 5.1)
|
29
|
+
tzinfo (~> 2.0)
|
30
|
+
zeitwerk (~> 2.3)
|
31
|
+
appraisal (2.5.0)
|
32
|
+
bundler
|
33
|
+
rake
|
34
|
+
thor (>= 0.14.0)
|
35
|
+
ast (2.4.2)
|
36
|
+
betterlint (1.7.0)
|
37
|
+
rubocop (> 1.0)
|
38
|
+
rubocop-performance
|
39
|
+
rubocop-rails
|
40
|
+
rubocop-rake
|
41
|
+
rubocop-rspec (>= 2.24)
|
42
|
+
builder (3.2.4)
|
43
|
+
concurrent-ruby (1.2.2)
|
44
|
+
crass (1.0.6)
|
45
|
+
diff-lcs (1.5.0)
|
46
|
+
erubi (1.12.0)
|
47
|
+
i18n (1.14.1)
|
48
|
+
concurrent-ruby (~> 1.0)
|
49
|
+
json (2.7.1)
|
50
|
+
language_server-protocol (3.17.0.3)
|
51
|
+
loofah (2.22.0)
|
52
|
+
crass (~> 1.0.2)
|
53
|
+
nokogiri (>= 1.12.0)
|
54
|
+
method_source (1.0.0)
|
55
|
+
minitest (5.20.0)
|
56
|
+
nokogiri (1.15.5-arm64-darwin)
|
57
|
+
racc (~> 1.4)
|
58
|
+
nokogiri (1.15.5-x86_64-darwin)
|
59
|
+
racc (~> 1.4)
|
60
|
+
parallel (1.24.0)
|
61
|
+
parser (3.2.2.4)
|
62
|
+
ast (~> 2.4.1)
|
63
|
+
racc
|
64
|
+
racc (1.7.3)
|
65
|
+
rack (2.2.8)
|
66
|
+
rack-test (2.1.0)
|
67
|
+
rack (>= 1.3)
|
68
|
+
rails-dom-testing (2.2.0)
|
69
|
+
activesupport (>= 5.0.0)
|
70
|
+
minitest
|
71
|
+
nokogiri (>= 1.6)
|
72
|
+
rails-html-sanitizer (1.6.0)
|
73
|
+
loofah (~> 2.21)
|
74
|
+
nokogiri (~> 1.14)
|
75
|
+
railties (6.1.7.6)
|
76
|
+
actionpack (= 6.1.7.6)
|
77
|
+
activesupport (= 6.1.7.6)
|
78
|
+
method_source
|
79
|
+
rake (>= 12.2)
|
80
|
+
thor (~> 1.0)
|
81
|
+
rainbow (3.1.1)
|
82
|
+
rake (13.1.0)
|
83
|
+
regexp_parser (2.8.3)
|
84
|
+
rexml (3.2.6)
|
85
|
+
rspec (3.12.0)
|
86
|
+
rspec-core (~> 3.12.0)
|
87
|
+
rspec-expectations (~> 3.12.0)
|
88
|
+
rspec-mocks (~> 3.12.0)
|
89
|
+
rspec-core (3.12.2)
|
90
|
+
rspec-support (~> 3.12.0)
|
91
|
+
rspec-expectations (3.12.3)
|
92
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
93
|
+
rspec-support (~> 3.12.0)
|
94
|
+
rspec-mocks (3.12.6)
|
95
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
96
|
+
rspec-support (~> 3.12.0)
|
97
|
+
rspec-support (3.12.1)
|
98
|
+
rubocop (1.59.0)
|
99
|
+
json (~> 2.3)
|
100
|
+
language_server-protocol (>= 3.17.0)
|
101
|
+
parallel (~> 1.10)
|
102
|
+
parser (>= 3.2.2.4)
|
103
|
+
rainbow (>= 2.2.2, < 4.0)
|
104
|
+
regexp_parser (>= 1.8, < 3.0)
|
105
|
+
rexml (>= 3.2.5, < 4.0)
|
106
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
107
|
+
ruby-progressbar (~> 1.7)
|
108
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
109
|
+
rubocop-ast (1.30.0)
|
110
|
+
parser (>= 3.2.1.0)
|
111
|
+
rubocop-capybara (2.19.0)
|
112
|
+
rubocop (~> 1.41)
|
113
|
+
rubocop-factory_bot (2.24.0)
|
114
|
+
rubocop (~> 1.33)
|
115
|
+
rubocop-performance (1.20.1)
|
116
|
+
rubocop (>= 1.48.1, < 2.0)
|
117
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
118
|
+
rubocop-rails (2.23.1)
|
119
|
+
activesupport (>= 4.2.0)
|
120
|
+
rack (>= 1.1)
|
121
|
+
rubocop (>= 1.33.0, < 2.0)
|
122
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
123
|
+
rubocop-rake (0.6.0)
|
124
|
+
rubocop (~> 1.0)
|
125
|
+
rubocop-rspec (2.25.0)
|
126
|
+
rubocop (~> 1.40)
|
127
|
+
rubocop-capybara (~> 2.17)
|
128
|
+
rubocop-factory_bot (~> 2.22)
|
129
|
+
ruby-progressbar (1.13.0)
|
130
|
+
thor (1.3.0)
|
131
|
+
tzinfo (2.0.6)
|
132
|
+
concurrent-ruby (~> 1.0)
|
133
|
+
unicode-display_width (2.5.0)
|
134
|
+
zeitwerk (2.6.12)
|
135
|
+
|
136
|
+
PLATFORMS
|
137
|
+
arm64-darwin-22
|
138
|
+
x86_64-darwin-22
|
139
|
+
x86_64-linux
|
140
|
+
|
141
|
+
DEPENDENCIES
|
142
|
+
activemodel (~> 6.1.0)
|
143
|
+
appraisal
|
144
|
+
authorized_persona!
|
145
|
+
betterlint
|
146
|
+
bundler
|
147
|
+
railties (~> 6.1.0)
|
148
|
+
rake
|
149
|
+
rspec (~> 3.0)
|
150
|
+
|
151
|
+
BUNDLED WITH
|
152
|
+
2.4.21
|
@@ -0,0 +1,152 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
authorized_persona (0.11.0)
|
5
|
+
railties (>= 6.1, < 7.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (7.0.8)
|
11
|
+
actionview (= 7.0.8)
|
12
|
+
activesupport (= 7.0.8)
|
13
|
+
rack (~> 2.0, >= 2.2.4)
|
14
|
+
rack-test (>= 0.6.3)
|
15
|
+
rails-dom-testing (~> 2.0)
|
16
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
17
|
+
actionview (7.0.8)
|
18
|
+
activesupport (= 7.0.8)
|
19
|
+
builder (~> 3.1)
|
20
|
+
erubi (~> 1.4)
|
21
|
+
rails-dom-testing (~> 2.0)
|
22
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
23
|
+
activemodel (7.0.8)
|
24
|
+
activesupport (= 7.0.8)
|
25
|
+
activesupport (7.0.8)
|
26
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
27
|
+
i18n (>= 1.6, < 2)
|
28
|
+
minitest (>= 5.1)
|
29
|
+
tzinfo (~> 2.0)
|
30
|
+
appraisal (2.5.0)
|
31
|
+
bundler
|
32
|
+
rake
|
33
|
+
thor (>= 0.14.0)
|
34
|
+
ast (2.4.2)
|
35
|
+
betterlint (1.7.0)
|
36
|
+
rubocop (> 1.0)
|
37
|
+
rubocop-performance
|
38
|
+
rubocop-rails
|
39
|
+
rubocop-rake
|
40
|
+
rubocop-rspec (>= 2.24)
|
41
|
+
builder (3.2.4)
|
42
|
+
concurrent-ruby (1.2.2)
|
43
|
+
crass (1.0.6)
|
44
|
+
diff-lcs (1.5.0)
|
45
|
+
erubi (1.12.0)
|
46
|
+
i18n (1.14.1)
|
47
|
+
concurrent-ruby (~> 1.0)
|
48
|
+
json (2.7.1)
|
49
|
+
language_server-protocol (3.17.0.3)
|
50
|
+
loofah (2.22.0)
|
51
|
+
crass (~> 1.0.2)
|
52
|
+
nokogiri (>= 1.12.0)
|
53
|
+
method_source (1.0.0)
|
54
|
+
minitest (5.20.0)
|
55
|
+
nokogiri (1.15.5-arm64-darwin)
|
56
|
+
racc (~> 1.4)
|
57
|
+
nokogiri (1.15.5-x86_64-darwin)
|
58
|
+
racc (~> 1.4)
|
59
|
+
parallel (1.24.0)
|
60
|
+
parser (3.2.2.4)
|
61
|
+
ast (~> 2.4.1)
|
62
|
+
racc
|
63
|
+
racc (1.7.3)
|
64
|
+
rack (2.2.8)
|
65
|
+
rack-test (2.1.0)
|
66
|
+
rack (>= 1.3)
|
67
|
+
rails-dom-testing (2.2.0)
|
68
|
+
activesupport (>= 5.0.0)
|
69
|
+
minitest
|
70
|
+
nokogiri (>= 1.6)
|
71
|
+
rails-html-sanitizer (1.6.0)
|
72
|
+
loofah (~> 2.21)
|
73
|
+
nokogiri (~> 1.14)
|
74
|
+
railties (7.0.8)
|
75
|
+
actionpack (= 7.0.8)
|
76
|
+
activesupport (= 7.0.8)
|
77
|
+
method_source
|
78
|
+
rake (>= 12.2)
|
79
|
+
thor (~> 1.0)
|
80
|
+
zeitwerk (~> 2.5)
|
81
|
+
rainbow (3.1.1)
|
82
|
+
rake (13.1.0)
|
83
|
+
regexp_parser (2.8.3)
|
84
|
+
rexml (3.2.6)
|
85
|
+
rspec (3.12.0)
|
86
|
+
rspec-core (~> 3.12.0)
|
87
|
+
rspec-expectations (~> 3.12.0)
|
88
|
+
rspec-mocks (~> 3.12.0)
|
89
|
+
rspec-core (3.12.2)
|
90
|
+
rspec-support (~> 3.12.0)
|
91
|
+
rspec-expectations (3.12.3)
|
92
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
93
|
+
rspec-support (~> 3.12.0)
|
94
|
+
rspec-mocks (3.12.6)
|
95
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
96
|
+
rspec-support (~> 3.12.0)
|
97
|
+
rspec-support (3.12.1)
|
98
|
+
rubocop (1.59.0)
|
99
|
+
json (~> 2.3)
|
100
|
+
language_server-protocol (>= 3.17.0)
|
101
|
+
parallel (~> 1.10)
|
102
|
+
parser (>= 3.2.2.4)
|
103
|
+
rainbow (>= 2.2.2, < 4.0)
|
104
|
+
regexp_parser (>= 1.8, < 3.0)
|
105
|
+
rexml (>= 3.2.5, < 4.0)
|
106
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
107
|
+
ruby-progressbar (~> 1.7)
|
108
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
109
|
+
rubocop-ast (1.30.0)
|
110
|
+
parser (>= 3.2.1.0)
|
111
|
+
rubocop-capybara (2.19.0)
|
112
|
+
rubocop (~> 1.41)
|
113
|
+
rubocop-factory_bot (2.24.0)
|
114
|
+
rubocop (~> 1.33)
|
115
|
+
rubocop-performance (1.20.1)
|
116
|
+
rubocop (>= 1.48.1, < 2.0)
|
117
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
118
|
+
rubocop-rails (2.23.1)
|
119
|
+
activesupport (>= 4.2.0)
|
120
|
+
rack (>= 1.1)
|
121
|
+
rubocop (>= 1.33.0, < 2.0)
|
122
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
123
|
+
rubocop-rake (0.6.0)
|
124
|
+
rubocop (~> 1.0)
|
125
|
+
rubocop-rspec (2.25.0)
|
126
|
+
rubocop (~> 1.40)
|
127
|
+
rubocop-capybara (~> 2.17)
|
128
|
+
rubocop-factory_bot (~> 2.22)
|
129
|
+
ruby-progressbar (1.13.0)
|
130
|
+
thor (1.3.0)
|
131
|
+
tzinfo (2.0.6)
|
132
|
+
concurrent-ruby (~> 1.0)
|
133
|
+
unicode-display_width (2.5.0)
|
134
|
+
zeitwerk (2.6.12)
|
135
|
+
|
136
|
+
PLATFORMS
|
137
|
+
arm64-darwin-22
|
138
|
+
x86_64-darwin-22
|
139
|
+
x86_64-linux
|
140
|
+
|
141
|
+
DEPENDENCIES
|
142
|
+
activemodel (~> 7.0.0)
|
143
|
+
appraisal
|
144
|
+
authorized_persona!
|
145
|
+
betterlint
|
146
|
+
bundler
|
147
|
+
railties (~> 7.0.0)
|
148
|
+
rake
|
149
|
+
rspec (~> 3.0)
|
150
|
+
|
151
|
+
BUNDLED WITH
|
152
|
+
2.4.21
|
@@ -0,0 +1,184 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
authorized_persona (0.11.0)
|
5
|
+
railties (>= 6.1, < 7.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (7.1.3.2)
|
11
|
+
actionview (= 7.1.3.2)
|
12
|
+
activesupport (= 7.1.3.2)
|
13
|
+
nokogiri (>= 1.8.5)
|
14
|
+
racc
|
15
|
+
rack (>= 2.2.4)
|
16
|
+
rack-session (>= 1.0.1)
|
17
|
+
rack-test (>= 0.6.3)
|
18
|
+
rails-dom-testing (~> 2.2)
|
19
|
+
rails-html-sanitizer (~> 1.6)
|
20
|
+
actionview (7.1.3.2)
|
21
|
+
activesupport (= 7.1.3.2)
|
22
|
+
builder (~> 3.1)
|
23
|
+
erubi (~> 1.11)
|
24
|
+
rails-dom-testing (~> 2.2)
|
25
|
+
rails-html-sanitizer (~> 1.6)
|
26
|
+
activemodel (7.1.3.2)
|
27
|
+
activesupport (= 7.1.3.2)
|
28
|
+
activesupport (7.1.3.2)
|
29
|
+
base64
|
30
|
+
bigdecimal
|
31
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
32
|
+
connection_pool (>= 2.2.5)
|
33
|
+
drb
|
34
|
+
i18n (>= 1.6, < 2)
|
35
|
+
minitest (>= 5.1)
|
36
|
+
mutex_m
|
37
|
+
tzinfo (~> 2.0)
|
38
|
+
appraisal (2.5.0)
|
39
|
+
bundler
|
40
|
+
rake
|
41
|
+
thor (>= 0.14.0)
|
42
|
+
ast (2.4.2)
|
43
|
+
base64 (0.2.0)
|
44
|
+
betterlint (1.10.1)
|
45
|
+
rubocop (~> 1.62.0)
|
46
|
+
rubocop-performance (~> 1.21.0)
|
47
|
+
rubocop-rails (~> 2.24.0)
|
48
|
+
rubocop-rake (~> 0.6.0)
|
49
|
+
rubocop-rspec (~> 2.28.0)
|
50
|
+
bigdecimal (3.1.7)
|
51
|
+
builder (3.2.4)
|
52
|
+
concurrent-ruby (1.2.3)
|
53
|
+
connection_pool (2.4.1)
|
54
|
+
crass (1.0.6)
|
55
|
+
diff-lcs (1.5.1)
|
56
|
+
drb (2.2.1)
|
57
|
+
erubi (1.12.0)
|
58
|
+
i18n (1.14.4)
|
59
|
+
concurrent-ruby (~> 1.0)
|
60
|
+
io-console (0.7.2)
|
61
|
+
irb (1.12.0)
|
62
|
+
rdoc
|
63
|
+
reline (>= 0.4.2)
|
64
|
+
json (2.7.2)
|
65
|
+
language_server-protocol (3.17.0.3)
|
66
|
+
loofah (2.22.0)
|
67
|
+
crass (~> 1.0.2)
|
68
|
+
nokogiri (>= 1.12.0)
|
69
|
+
minitest (5.22.3)
|
70
|
+
mutex_m (0.2.0)
|
71
|
+
nokogiri (1.16.4-arm64-darwin)
|
72
|
+
racc (~> 1.4)
|
73
|
+
nokogiri (1.16.4-x86_64-linux)
|
74
|
+
racc (~> 1.4)
|
75
|
+
parallel (1.24.0)
|
76
|
+
parser (3.3.0.5)
|
77
|
+
ast (~> 2.4.1)
|
78
|
+
racc
|
79
|
+
psych (5.1.2)
|
80
|
+
stringio
|
81
|
+
racc (1.7.3)
|
82
|
+
rack (3.0.10)
|
83
|
+
rack-session (2.0.0)
|
84
|
+
rack (>= 3.0.0)
|
85
|
+
rack-test (2.1.0)
|
86
|
+
rack (>= 1.3)
|
87
|
+
rackup (2.1.0)
|
88
|
+
rack (>= 3)
|
89
|
+
webrick (~> 1.8)
|
90
|
+
rails-dom-testing (2.2.0)
|
91
|
+
activesupport (>= 5.0.0)
|
92
|
+
minitest
|
93
|
+
nokogiri (>= 1.6)
|
94
|
+
rails-html-sanitizer (1.6.0)
|
95
|
+
loofah (~> 2.21)
|
96
|
+
nokogiri (~> 1.14)
|
97
|
+
railties (7.1.3.2)
|
98
|
+
actionpack (= 7.1.3.2)
|
99
|
+
activesupport (= 7.1.3.2)
|
100
|
+
irb
|
101
|
+
rackup (>= 1.0.0)
|
102
|
+
rake (>= 12.2)
|
103
|
+
thor (~> 1.0, >= 1.2.2)
|
104
|
+
zeitwerk (~> 2.6)
|
105
|
+
rainbow (3.1.1)
|
106
|
+
rake (13.2.1)
|
107
|
+
rdoc (6.6.3.1)
|
108
|
+
psych (>= 4.0.0)
|
109
|
+
regexp_parser (2.9.0)
|
110
|
+
reline (0.5.3)
|
111
|
+
io-console (~> 0.5)
|
112
|
+
rexml (3.2.6)
|
113
|
+
rspec (3.13.0)
|
114
|
+
rspec-core (~> 3.13.0)
|
115
|
+
rspec-expectations (~> 3.13.0)
|
116
|
+
rspec-mocks (~> 3.13.0)
|
117
|
+
rspec-core (3.13.0)
|
118
|
+
rspec-support (~> 3.13.0)
|
119
|
+
rspec-expectations (3.13.0)
|
120
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
121
|
+
rspec-support (~> 3.13.0)
|
122
|
+
rspec-mocks (3.13.0)
|
123
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
124
|
+
rspec-support (~> 3.13.0)
|
125
|
+
rspec-support (3.13.1)
|
126
|
+
rubocop (1.62.1)
|
127
|
+
json (~> 2.3)
|
128
|
+
language_server-protocol (>= 3.17.0)
|
129
|
+
parallel (~> 1.10)
|
130
|
+
parser (>= 3.3.0.2)
|
131
|
+
rainbow (>= 2.2.2, < 4.0)
|
132
|
+
regexp_parser (>= 1.8, < 3.0)
|
133
|
+
rexml (>= 3.2.5, < 4.0)
|
134
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
135
|
+
ruby-progressbar (~> 1.7)
|
136
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
137
|
+
rubocop-ast (1.31.2)
|
138
|
+
parser (>= 3.3.0.4)
|
139
|
+
rubocop-capybara (2.20.0)
|
140
|
+
rubocop (~> 1.41)
|
141
|
+
rubocop-factory_bot (2.25.1)
|
142
|
+
rubocop (~> 1.41)
|
143
|
+
rubocop-performance (1.21.0)
|
144
|
+
rubocop (>= 1.48.1, < 2.0)
|
145
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
146
|
+
rubocop-rails (2.24.1)
|
147
|
+
activesupport (>= 4.2.0)
|
148
|
+
rack (>= 1.1)
|
149
|
+
rubocop (>= 1.33.0, < 2.0)
|
150
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
151
|
+
rubocop-rake (0.6.0)
|
152
|
+
rubocop (~> 1.0)
|
153
|
+
rubocop-rspec (2.28.0)
|
154
|
+
rubocop (~> 1.40)
|
155
|
+
rubocop-capybara (~> 2.17)
|
156
|
+
rubocop-factory_bot (~> 2.22)
|
157
|
+
rubocop-rspec_rails (~> 2.28)
|
158
|
+
rubocop-rspec_rails (2.28.3)
|
159
|
+
rubocop (~> 1.40)
|
160
|
+
ruby-progressbar (1.13.0)
|
161
|
+
stringio (3.1.0)
|
162
|
+
thor (1.3.1)
|
163
|
+
tzinfo (2.0.6)
|
164
|
+
concurrent-ruby (~> 1.0)
|
165
|
+
unicode-display_width (2.5.0)
|
166
|
+
webrick (1.8.1)
|
167
|
+
zeitwerk (2.6.13)
|
168
|
+
|
169
|
+
PLATFORMS
|
170
|
+
arm64-darwin-22
|
171
|
+
x86_64-linux
|
172
|
+
|
173
|
+
DEPENDENCIES
|
174
|
+
activemodel (~> 7.1.0)
|
175
|
+
appraisal
|
176
|
+
authorized_persona!
|
177
|
+
betterlint
|
178
|
+
bundler
|
179
|
+
railties (~> 7.1.0)
|
180
|
+
rake
|
181
|
+
rspec (~> 3.0)
|
182
|
+
|
183
|
+
BUNDLED WITH
|
184
|
+
2.4.21
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AuthorizedPersona
|
2
4
|
module Authorization
|
3
5
|
extend ActiveSupport::Concern
|
@@ -13,7 +15,7 @@ module AuthorizedPersona
|
|
13
15
|
|
14
16
|
class_methods do
|
15
17
|
# Configure authorization for an authorized persona class
|
16
|
-
def authorize_persona(class_name:, current_user_method: nil) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/
|
18
|
+
def authorize_persona(class_name:, current_user_method: nil) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/
|
17
19
|
raise AuthorizedPersona::Error, "you can only configure authorization once" if authorization_persona_class_name.present?
|
18
20
|
raise AuthorizedPersona::Error, "class_name must be a string" unless class_name.is_a?(String)
|
19
21
|
raise AuthorizedPersona::Error, "current_user_method must be a symbol" if current_user_method && !current_user_method.is_a?(Symbol)
|
@@ -36,13 +38,13 @@ module AuthorizedPersona
|
|
36
38
|
|
37
39
|
# Grants replace all previous grants to avoid privilege leakage
|
38
40
|
def grant(privileges) # rubocop:disable Metrics/AbcSize
|
39
|
-
self.authorized_actions =
|
41
|
+
self.authorized_actions = privileges.map { |auth_tier, actions| [auth_tier.to_s, [actions].flatten.map(&:to_sym)] }.to_h
|
40
42
|
|
41
43
|
tier_names = authorization_persona.authorization_tier_names
|
42
44
|
extra_keys = authorized_actions.keys - authorization_persona.authorization_tier_names
|
43
45
|
if extra_keys.present?
|
44
46
|
raise AuthorizedPersona::Error, "invalid grant: #{authorization_persona_class_name} " \
|
45
|
-
|
47
|
+
"has authorization tiers #{tier_names.join(', ')} but received extra keys: #{extra_keys.join(', ')}"
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -79,7 +81,7 @@ module AuthorizedPersona
|
|
79
81
|
def authorization_current_user
|
80
82
|
unless authorization_current_user_method.is_a?(Symbol)
|
81
83
|
raise AuthorizedPersona::Error, "you must configure authorization with a valid current_user method name, " \
|
82
|
-
|
84
|
+
"e.g. `authorize_persona class_name: 'User', current_user_method: :my_custom_current_user`"
|
83
85
|
end
|
84
86
|
|
85
87
|
send(self.class.authorization_current_user_method)
|
@@ -89,7 +91,7 @@ module AuthorizedPersona
|
|
89
91
|
self.class.authorized_tier(action: params[:action])
|
90
92
|
end
|
91
93
|
|
92
|
-
def authorize!
|
94
|
+
def authorize!
|
93
95
|
return if authorized?
|
94
96
|
|
95
97
|
respond_to do |format|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AuthorizedPersona
|
2
4
|
module Persona
|
3
5
|
extend ActiveSupport::Concern
|
@@ -34,7 +36,7 @@ module AuthorizedPersona
|
|
34
36
|
end
|
35
37
|
|
36
38
|
# Configure the authorization tiers in my_tier_slug: "My Tier Title And Description" form from lowest to highest privilege.
|
37
|
-
def authorization_tiers(tiers) # rubocop:disable Metrics/AbcSize
|
39
|
+
def authorization_tiers(tiers) # rubocop:disable Metrics/AbcSize
|
38
40
|
raise AuthorizedPersona::Error, "you can only define authorization tiers once" if instance_variable_defined?(:@authorization_tiers)
|
39
41
|
|
40
42
|
if !tiers.is_a?(Hash) || !tiers.all? { |k, v| k.is_a?(Symbol) && v.is_a?(String) }
|
@@ -47,7 +49,7 @@ module AuthorizedPersona
|
|
47
49
|
|
48
50
|
instance_methods.module_eval do
|
49
51
|
tiers.keys.each do |tier|
|
50
|
-
define_method "#{tier}_or_above?" do
|
52
|
+
define_method :"#{tier}_or_above?" do
|
51
53
|
authorization_tier_at_or_above?(tier)
|
52
54
|
end
|
53
55
|
end
|
@@ -59,7 +61,7 @@ module AuthorizedPersona
|
|
59
61
|
|
60
62
|
class_methods.module_eval do
|
61
63
|
tiers.keys.each do |tier|
|
62
|
-
define_method "#{tier}_or_above" do
|
64
|
+
define_method :"#{tier}_or_above" do
|
63
65
|
with_authorization_tier_at_or_above(tier)
|
64
66
|
end
|
65
67
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module AuthorizedPersona
|
2
4
|
class Railtie < Rails::Railtie
|
3
5
|
initializer "authorized_persona.view_helpers" do
|
4
|
-
ActionView::Base.
|
6
|
+
ActionView::Base.include AuthorizedPersona::ViewHelpers
|
5
7
|
end
|
6
8
|
end
|
7
9
|
end
|
data/lib/authorized_persona.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authorized_persona
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Mileham
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -16,84 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '6.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '7'
|
22
|
+
version: '7.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: '6.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '7'
|
32
|
+
version: '7.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activemodel
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: '6.1'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '7'
|
42
|
+
version: '7.2'
|
43
43
|
type: :development
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: '6.1'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '7'
|
52
|
+
version: '7.2'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
54
|
+
name: appraisal
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - "
|
57
|
+
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: '
|
59
|
+
version: '0'
|
60
60
|
type: :development
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- - "
|
64
|
+
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version: '
|
66
|
+
version: '0'
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
68
|
+
name: betterlint
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- - "
|
71
|
+
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '
|
73
|
+
version: '0'
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - "
|
78
|
+
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
80
|
+
version: '0'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
|
-
name:
|
82
|
+
name: bundler
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- - "
|
85
|
+
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '
|
87
|
+
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- - "
|
92
|
+
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: '
|
94
|
+
version: '0'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
96
|
+
name: rake
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
99
|
- - ">="
|
@@ -106,6 +106,20 @@ dependencies:
|
|
106
106
|
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: rspec
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '3.0'
|
116
|
+
type: :development
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - "~>"
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '3.0'
|
109
123
|
description: AuthorizedPersona is a rails implementation of Betterment's Persona Centric
|
110
124
|
Authorization pattern
|
111
125
|
email:
|
@@ -114,18 +128,28 @@ executables: []
|
|
114
128
|
extensions: []
|
115
129
|
extra_rdoc_files: []
|
116
130
|
files:
|
131
|
+
- ".github/workflows/ci.yml"
|
117
132
|
- ".gitignore"
|
118
133
|
- ".rspec"
|
119
134
|
- ".rubocop.yml"
|
120
|
-
- ".
|
135
|
+
- ".rubocop_todo.yml"
|
136
|
+
- ".ruby-version"
|
137
|
+
- Appraisals
|
121
138
|
- CODE_OF_CONDUCT.md
|
122
139
|
- Gemfile
|
140
|
+
- Gemfile.lock
|
123
141
|
- LICENSE.txt
|
124
142
|
- README.md
|
125
143
|
- Rakefile
|
126
144
|
- authorized_persona.gemspec
|
127
145
|
- bin/console
|
128
146
|
- bin/setup
|
147
|
+
- gemfiles/rails_6_1.gemfile
|
148
|
+
- gemfiles/rails_6_1.gemfile.lock
|
149
|
+
- gemfiles/rails_7_0.gemfile
|
150
|
+
- gemfiles/rails_7_0.gemfile.lock
|
151
|
+
- gemfiles/rails_7_1.gemfile
|
152
|
+
- gemfiles/rails_7_1.gemfile.lock
|
129
153
|
- lib/authorized_persona.rb
|
130
154
|
- lib/authorized_persona/authorization.rb
|
131
155
|
- lib/authorized_persona/persona.rb
|
@@ -135,8 +159,9 @@ files:
|
|
135
159
|
homepage: https://github.com/Betterment/authorized_persona
|
136
160
|
licenses:
|
137
161
|
- MIT
|
138
|
-
metadata:
|
139
|
-
|
162
|
+
metadata:
|
163
|
+
rubygems_mfa_required: 'true'
|
164
|
+
post_install_message:
|
140
165
|
rdoc_options: []
|
141
166
|
require_paths:
|
142
167
|
- lib
|
@@ -144,15 +169,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
144
169
|
requirements:
|
145
170
|
- - ">="
|
146
171
|
- !ruby/object:Gem::Version
|
147
|
-
version: '0'
|
172
|
+
version: '3.0'
|
148
173
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
174
|
requirements:
|
150
175
|
- - ">="
|
151
176
|
- !ruby/object:Gem::Version
|
152
177
|
version: '0'
|
153
178
|
requirements: []
|
154
|
-
rubygems_version: 3.
|
155
|
-
signing_key:
|
179
|
+
rubygems_version: 3.5.23
|
180
|
+
signing_key:
|
156
181
|
specification_version: 4
|
157
182
|
summary: the simplest authorization library you will ever love
|
158
183
|
test_files: []
|