jsonapi-authorization 1.0.0 β 2.0.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/.all-contributorsrc +13 -1
- data/README.md +3 -3
- data/jsonapi-authorization.gemspec +1 -1
- data/lib/jsonapi/authorization/authorizing_processor.rb +7 -3
- data/lib/jsonapi/authorization/default_pundit_authorizer.rb +6 -5
- data/lib/jsonapi/authorization/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 51967700aa7fc54f56208840d0f71d789bccd43fb434e5d2b7d5931640ca1ca3
|
|
4
|
+
data.tar.gz: 31a03f59caf1aab5c5a6c5203bf1ac7125b05e15406010239e036ef6c3b8f489
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f199b730e179e9c3b71460e4f4c8053809efe7fe3a3b4197b7e3e5c38f7bd1b24d52024348384aa690c9718e15b259dcd217670a4cca9980d87ab8615384eef
|
|
7
|
+
data.tar.gz: c4f8cd84c1e1883e73eb13b701015166ef104256842f44ce3c8713783271b226c799acdc7dfd3054cf79b8a69efcbd5bf79d9360489be9edd573b10c60f4f059
|
data/.all-contributorsrc
CHANGED
|
@@ -126,7 +126,19 @@
|
|
|
126
126
|
"test",
|
|
127
127
|
"infra"
|
|
128
128
|
]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"login": "Matthijsy",
|
|
132
|
+
"name": "Matthijsy",
|
|
133
|
+
"avatar_url": "https://avatars2.githubusercontent.com/u/5302372?v=4",
|
|
134
|
+
"profile": "https://github.com/Matthijsy",
|
|
135
|
+
"contributions": [
|
|
136
|
+
"bug",
|
|
137
|
+
"test",
|
|
138
|
+
"code"
|
|
139
|
+
]
|
|
129
140
|
}
|
|
130
141
|
],
|
|
131
|
-
"repoType": "github"
|
|
142
|
+
"repoType": "github",
|
|
143
|
+
"contributorsPerLine": 7
|
|
132
144
|
}
|
data/README.md
CHANGED
|
@@ -55,7 +55,7 @@ Or install it yourself as:
|
|
|
55
55
|
|
|
56
56
|
* `v0.6.x` supports JR `v0.7.x`
|
|
57
57
|
* `v0.8.x` supports JR `v0.8.x`
|
|
58
|
-
* `v1.
|
|
58
|
+
* `v1.x.x` and `v2.0.x` releases support JR `v0.9.x`
|
|
59
59
|
|
|
60
60
|
We aim to support the same Ruby and Ruby on Rails versions as `jsonapi-resources` does. If that's not the case, please [open an issue][issues].
|
|
61
61
|
|
|
@@ -185,9 +185,9 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
|
|
|
185
185
|
|
|
186
186
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
187
187
|
<!-- prettier-ignore -->
|
|
188
|
-
| [<img src="https://avatars.githubusercontent.com/u/482561?v=3" width="100px;"/><br /><sub><b>Vesa Laakso</b></sub>](http://vesalaakso.com)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=valscion "Code") [π](https://github.com/Venuu/jsonapi-authorization/commits?author=valscion "Documentation") [π](#infra-valscion "Infrastructure (Hosting, Build-Tools, etc)") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=valscion "Tests") [π](https://github.com/Venuu/jsonapi-authorization/issues?q=author%3Avalscion "Bug reports") [π¬](#question-valscion "Answering Questions") [π](#review-valscion "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/562204?v=3" width="100px;"/><br /><sub><b>Emil SΓ₯gfors</b></sub>](https://github.com/lime)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=lime "Code") [π](https://github.com/Venuu/jsonapi-authorization/commits?author=lime "Documentation") [π](#infra-lime "Infrastructure (Hosting, Build-Tools, etc)") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=lime "Tests") [π](https://github.com/Venuu/jsonapi-authorization/issues?q=author%3Alime "Bug reports") [π¬](#question-lime "Answering Questions") [π](#review-lime "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/1591161?v=3" width="100px;"/><br /><sub><b>Matthias Grundmann</b></sub>](https://github.com/matthias-g)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=matthias-g "Code") [π](https://github.com/Venuu/jsonapi-authorization/commits?author=matthias-g "Documentation") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=matthias-g "Tests") [π¬](#question-matthias-g "Answering Questions") | [<img src="https://avatars.githubusercontent.com/u/1322?v=3" width="100px;"/><br /><sub><b>Thibaud Guillaume-Gentil</b></sub>](http://thibaud.gg)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=thibaudgg "Code") | [<img src="https://avatars.githubusercontent.com/u/71660?v=3" width="100px;"/><br /><sub><b>Daniel SchweighΓΆfer</b></sub>](http://netsteward.net)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=acid "Code") | [<img src="https://avatars.githubusercontent.com/u/5076967?v=3" width="100px;"/><br /><sub><b>Bruno Sofiato</b></sub>](https://github.com/bsofiato)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=bsofiato "Code") | [<img src="https://avatars.githubusercontent.com/u/1896026?v=3" width="100px;"/><br /><sub><b>Adam Robertson</b></sub>](https://github.com/arcreative)<br />[π](https://github.com/Venuu/jsonapi-authorization/commits?author=arcreative "Documentation") |
|
|
188
|
+
| [<img src="https://avatars.githubusercontent.com/u/482561?v=3" width="100px;" alt="Vesa Laakso"/><br /><sub><b>Vesa Laakso</b></sub>](http://vesalaakso.com)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=valscion "Code") [π](https://github.com/Venuu/jsonapi-authorization/commits?author=valscion "Documentation") [π](#infra-valscion "Infrastructure (Hosting, Build-Tools, etc)") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=valscion "Tests") [π](https://github.com/Venuu/jsonapi-authorization/issues?q=author%3Avalscion "Bug reports") [π¬](#question-valscion "Answering Questions") [π](#review-valscion "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/562204?v=3" width="100px;" alt="Emil SΓ₯gfors"/><br /><sub><b>Emil SΓ₯gfors</b></sub>](https://github.com/lime)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=lime "Code") [π](https://github.com/Venuu/jsonapi-authorization/commits?author=lime "Documentation") [π](#infra-lime "Infrastructure (Hosting, Build-Tools, etc)") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=lime "Tests") [π](https://github.com/Venuu/jsonapi-authorization/issues?q=author%3Alime "Bug reports") [π¬](#question-lime "Answering Questions") [π](#review-lime "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/1591161?v=3" width="100px;" alt="Matthias Grundmann"/><br /><sub><b>Matthias Grundmann</b></sub>](https://github.com/matthias-g)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=matthias-g "Code") [π](https://github.com/Venuu/jsonapi-authorization/commits?author=matthias-g "Documentation") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=matthias-g "Tests") [π¬](#question-matthias-g "Answering Questions") | [<img src="https://avatars.githubusercontent.com/u/1322?v=3" width="100px;" alt="Thibaud Guillaume-Gentil"/><br /><sub><b>Thibaud Guillaume-Gentil</b></sub>](http://thibaud.gg)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=thibaudgg "Code") | [<img src="https://avatars.githubusercontent.com/u/71660?v=3" width="100px;" alt="Daniel SchweighΓΆfer"/><br /><sub><b>Daniel SchweighΓΆfer</b></sub>](http://netsteward.net)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=acid "Code") | [<img src="https://avatars.githubusercontent.com/u/5076967?v=3" width="100px;" alt="Bruno Sofiato"/><br /><sub><b>Bruno Sofiato</b></sub>](https://github.com/bsofiato)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=bsofiato "Code") | [<img src="https://avatars.githubusercontent.com/u/1896026?v=3" width="100px;" alt="Adam Robertson"/><br /><sub><b>Adam Robertson</b></sub>](https://github.com/arcreative)<br />[π](https://github.com/Venuu/jsonapi-authorization/commits?author=arcreative "Documentation") |
|
|
189
189
|
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
190
|
-
| [<img src="https://avatars3.githubusercontent.com/u/4742306?v=3" width="100px;"/><br /><sub><b>Greg Fisher</b></sub>](https://github.com/gnfisher)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=gnfisher "Code") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=gnfisher "Tests") | [<img src="https://avatars3.githubusercontent.com/u/370182?v=3" width="100px;"/><br /><sub><b>Sam</b></sub>](http://samlh.com)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=handlers "Code") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=handlers "Tests") | [<img src="https://avatars0.githubusercontent.com/u/2738630?v=3" width="100px;"/><br /><sub><b>Justas Palumickas</b></sub>](https://jpalumickas.com)<br />[π](https://github.com/Venuu/jsonapi-authorization/issues?q=author%3Ajpalumickas "Bug reports") [π»](https://github.com/Venuu/jsonapi-authorization/commits?author=jpalumickas "Code") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=jpalumickas "Tests") | [<img src="https://avatars1.githubusercontent.com/u/26158?v=4" width="100px;"/><br /><sub><b>Nicholas Rutherford</b></sub>](http://www.google.co.uk/profiles/nick.rutherford)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=nruth "Code") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=nruth "Tests") [π](#infra-nruth "Infrastructure (Hosting, Build-Tools, etc)") |
|
|
190
|
+
| [<img src="https://avatars3.githubusercontent.com/u/4742306?v=3" width="100px;" alt="Greg Fisher"/><br /><sub><b>Greg Fisher</b></sub>](https://github.com/gnfisher)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=gnfisher "Code") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=gnfisher "Tests") | [<img src="https://avatars3.githubusercontent.com/u/370182?v=3" width="100px;" alt="Sam"/><br /><sub><b>Sam</b></sub>](http://samlh.com)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=handlers "Code") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=handlers "Tests") | [<img src="https://avatars0.githubusercontent.com/u/2738630?v=3" width="100px;" alt="Justas Palumickas"/><br /><sub><b>Justas Palumickas</b></sub>](https://jpalumickas.com)<br />[π](https://github.com/Venuu/jsonapi-authorization/issues?q=author%3Ajpalumickas "Bug reports") [π»](https://github.com/Venuu/jsonapi-authorization/commits?author=jpalumickas "Code") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=jpalumickas "Tests") | [<img src="https://avatars1.githubusercontent.com/u/26158?v=4" width="100px;" alt="Nicholas Rutherford"/><br /><sub><b>Nicholas Rutherford</b></sub>](http://www.google.co.uk/profiles/nick.rutherford)<br />[π»](https://github.com/Venuu/jsonapi-authorization/commits?author=nruth "Code") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=nruth "Tests") [π](#infra-nruth "Infrastructure (Hosting, Build-Tools, etc)") | [<img src="https://avatars2.githubusercontent.com/u/5302372?v=4" width="100px;" alt="Matthijsy"/><br /><sub><b>Matthijsy</b></sub>](https://github.com/Matthijsy)<br />[π](https://github.com/Venuu/jsonapi-authorization/issues?q=author%3AMatthijsy "Bug reports") [β οΈ](https://github.com/Venuu/jsonapi-authorization/commits?author=Matthijsy "Tests") [π»](https://github.com/Venuu/jsonapi-authorization/commits?author=Matthijsy "Code") |
|
|
191
191
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
192
192
|
|
|
193
193
|
This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!
|
|
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.add_development_dependency "pry-rails"
|
|
32
32
|
spec.add_development_dependency "rubocop", "~> 0.36.0"
|
|
33
33
|
spec.add_development_dependency "phare", "~> 0.7.1"
|
|
34
|
-
spec.add_development_dependency "sqlite3"
|
|
34
|
+
spec.add_development_dependency "sqlite3", "~> 1.3.6"
|
|
35
35
|
end
|
|
@@ -101,12 +101,16 @@ module JSONAPI
|
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
def authorize_show_related_resources
|
|
104
|
-
|
|
104
|
+
source_resource = params[:source_klass].find_by_key(
|
|
105
105
|
params[:source_id],
|
|
106
106
|
context: context
|
|
107
|
-
)
|
|
107
|
+
)
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
source_record = source_resource._model
|
|
110
|
+
|
|
111
|
+
authorizer.show_related_resources(
|
|
112
|
+
source_record: source_record, related_record_class: @resource_klass._model_class
|
|
113
|
+
)
|
|
110
114
|
end
|
|
111
115
|
|
|
112
116
|
def authorize_replace_fields
|
|
@@ -3,10 +3,9 @@ module JSONAPI
|
|
|
3
3
|
# An authorizer is a class responsible for linking JSONAPI operations to
|
|
4
4
|
# your choice of authorization mechanism.
|
|
5
5
|
#
|
|
6
|
-
# This class uses Pundit for authorization.
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
# information.
|
|
6
|
+
# This class uses Pundit for authorization. You can use your own authorizer
|
|
7
|
+
# class instead if you have different needs. See the README.md for
|
|
8
|
+
# configuration information.
|
|
10
9
|
#
|
|
11
10
|
# Fetching records is the concern of +PunditScopedResource+ which in turn
|
|
12
11
|
# affects which records end up being passed here.
|
|
@@ -77,8 +76,10 @@ module JSONAPI
|
|
|
77
76
|
# ==== Parameters
|
|
78
77
|
#
|
|
79
78
|
# * +source_record+ - The record whose relationship is queried
|
|
80
|
-
|
|
79
|
+
# * +related_record_class+ - The associated record class to show
|
|
80
|
+
def show_related_resources(source_record:, related_record_class:)
|
|
81
81
|
::Pundit.authorize(user, source_record, 'show?')
|
|
82
|
+
::Pundit.authorize(user, related_record_class, 'index?')
|
|
82
83
|
end
|
|
83
84
|
|
|
84
85
|
# <tt>PATCH /resources/:id</tt>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jsonapi-authorization
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Vesa Laakso
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2019-
|
|
12
|
+
date: 2019-03-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: jsonapi-resources
|
|
@@ -203,16 +203,16 @@ dependencies:
|
|
|
203
203
|
name: sqlite3
|
|
204
204
|
requirement: !ruby/object:Gem::Requirement
|
|
205
205
|
requirements:
|
|
206
|
-
- - "
|
|
206
|
+
- - "~>"
|
|
207
207
|
- !ruby/object:Gem::Version
|
|
208
|
-
version:
|
|
208
|
+
version: 1.3.6
|
|
209
209
|
type: :development
|
|
210
210
|
prerelease: false
|
|
211
211
|
version_requirements: !ruby/object:Gem::Requirement
|
|
212
212
|
requirements:
|
|
213
|
-
- - "
|
|
213
|
+
- - "~>"
|
|
214
214
|
- !ruby/object:Gem::Version
|
|
215
|
-
version:
|
|
215
|
+
version: 1.3.6
|
|
216
216
|
description: Adds generic authorization to the jsonapi-resources gem using Pundit.
|
|
217
217
|
email:
|
|
218
218
|
- laakso.vesa@gmail.com
|