zaikio-jwt_auth 2.4.0 → 2.5.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: 3f46dba4c35870df1d25710905ff3451588f23f1fa8d02e304d9555c6816319c
4
- data.tar.gz: 42124c9514465ee6bd6a7a069402730cd0049ec6c9be2fea0e6348107176be6b
3
+ metadata.gz: 2973a0c217c47da109e5a5023a7a430a153c8b61dae1a0ab21d24511420c209a
4
+ data.tar.gz: adbf5e6c3beb55f437ba68f04966186b0b6c886d4cb78b0db3ce294dc8d99710
5
5
  SHA512:
6
- metadata.gz: '018c6eb5215993e066d7f4b080250df0f1e02788675c86ce6da62d75a378c7f96e0d63b7b94cd81dea5ecc01d7c0fda8775691fb90ca05ab250708e0dbb3a4ba'
7
- data.tar.gz: 0cfdfc49f7c07fb39c076b693371bff9cc444e3a39aeb740bb281208cb9acf9651e84ad77662bd871399cda5b2d2666a515b0c86b39bec5f75bc06b1184427c9
6
+ metadata.gz: 7a30f36608a792d86bd839402b17b3ad6b0ae4aa2554f53f23bf80c70526763a756a2cc727c8b5043687535353886f63e80759a84999d2e1b399cb6646a8da52
7
+ data.tar.gz: f40fa02553e687c3d2d653e35c0c4a6d43e2bcc14e2f46328127ae78960e9d8a95303cb735aa65f43797d6a29613d1d3fa3891cb88c31027377ff49ea2fbf4ce
@@ -5,7 +5,7 @@ require "logger"
5
5
  module Zaikio
6
6
  module JWTAuth
7
7
  class DirectoryCache
8
- class UpdateJob < ::ActiveJob::Base
8
+ class UpdateJob < ::ActiveJob::Base # rubocop:disable Rails/ApplicationJob
9
9
  def perform(directory_path)
10
10
  DirectoryCache.fetch(directory_path)
11
11
  true # This job will always re-queue until it succeeds.
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module JWTAuth
3
- VERSION = "2.4.0".freeze
3
+ VERSION = "2.5.0".freeze
4
4
  end
5
5
  end
@@ -119,7 +119,7 @@ module Zaikio
119
119
  end
120
120
 
121
121
  def update_revoked_access_tokens_by_webhook
122
- return unless params[:name] == "directory.revoked_access_token"
122
+ return unless %w[directory.revoked_access_token zaikio.revoked_access_token].include?(params[:name])
123
123
 
124
124
  DirectoryCache.update("api/v1/revoked_access_tokens.json", expires_after: 60.minutes) do |data|
125
125
  data["revoked_token_ids"] << params[:payload][:access_token_id]
@@ -131,8 +131,8 @@ module Zaikio
131
131
 
132
132
  private
133
133
 
134
- def find_scope_configuration(scope_configurations)
135
- scope_configurations.find do |scope_configuration|
134
+ def find_scope_configurations(scope_configurations)
135
+ scope_configurations.select do |scope_configuration|
136
136
  action_matches = action_matches_config?(scope_configuration)
137
137
 
138
138
  if action_matches && scope_configuration[:if] && !instance_exec(&scope_configuration[:if])
@@ -169,21 +169,23 @@ module Zaikio
169
169
  end
170
170
 
171
171
  def show_error_if_authorize_by_jwt_scopes_fails(token_data)
172
- configuration = find_scope_configuration(self.class.authorize_by_jwt_scopes)
172
+ configurations = find_scope_configurations(self.class.authorize_by_jwt_scopes)
173
173
 
174
- return if token_data.scope_by_configurations?(
175
- configuration,
176
- action_name
177
- )
174
+ return if configurations.empty?
178
175
 
179
- details = nil
176
+ configuration = configurations.find do |scope_configuration|
177
+ token_data.scope_by_configurations?(
178
+ scope_configuration,
179
+ action_name
180
+ )
181
+ end
180
182
 
181
- if configuration
182
- required_scopes = required_scopes(token_data, configuration)
183
+ return if configuration
183
184
 
184
- details = "This endpoint requires one of the following scopes: #{required_scopes.join(', ')} but your " \
185
- "access token only includes the following scopes: #{token_data.scope.join(', ')} - #{DOCS_LINK}"
186
- end
185
+ required_scopes = required_scopes(token_data, configuration || configurations.first)
186
+
187
+ details = "This endpoint requires one of the following scopes: #{required_scopes.join(', ')} but your " \
188
+ "access token only includes the following scopes: #{token_data.scope.join(', ')} - #{DOCS_LINK}"
187
189
 
188
190
  render_error(["unpermitted_scope", details])
189
191
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - crispymtn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-03-27 00:00:00.000000000 Z
13
+ date: 2023-05-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activejob