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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9964c80bda556e297a4e6fc123a35d213debefa7d418ab60d627f9eb3401f334
4
- data.tar.gz: 64e0146d4b454e7417b7e4afd2ee6c9b4d365a7c62d3a2993e44f2c006711542
3
+ metadata.gz: 51967700aa7fc54f56208840d0f71d789bccd43fb434e5d2b7d5931640ca1ca3
4
+ data.tar.gz: 31a03f59caf1aab5c5a6c5203bf1ac7125b05e15406010239e036ef6c3b8f489
5
5
  SHA512:
6
- metadata.gz: f729a9f5b558008f1baa2c7760f4f31ce59b06e86d2d9bf56894a0e3f648eb985e05e998f3d8718b39f6d3b0d913757ff48ace6ae399cbd2519fa0f72afccad6
7
- data.tar.gz: 68925bea3461cea96c3538b76c85b222e43bb8565e401a881f021d40a1a4c9ecc37021c0487d25efbdc66b339e17b2bb042d2c29da41a544a86416bc37c57b38
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.0.0` alpha and beta releases support JR `v0.9.x`
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
- source_record = params[:source_klass].find_by_key(
104
+ source_resource = params[:source_klass].find_by_key(
105
105
  params[:source_id],
106
106
  context: context
107
- )._model
107
+ )
108
108
 
109
- authorizer.show_related_resources(source_record: source_record)
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. It does not yet support all
7
- # the available operations β€” you can use your own authorizer class instead
8
- # if you have different needs. See the README.md for configuration
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
- def show_related_resources(source_record:)
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>
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module JSONAPI
3
3
  module Authorization
4
- VERSION = "1.0.0".freeze
4
+ VERSION = "2.0.0".freeze
5
5
  end
6
6
  end
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: 1.0.0
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-01-22 00:00:00.000000000 Z
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: '0'
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: '0'
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