warden-jwt_auth 0.10.1 → 0.11.0

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: 60f3a20e896744f9907bae893ef869cebf5240e3250c98ea9e642aee65f69971
4
- data.tar.gz: c3fcb1ebf73d1553d8b91c2195b465095ed9b0cf888ccf0a4474f6ccbba7329e
3
+ metadata.gz: 0b1a585fc4b4ab038046cf25e745fdebb4363001374d31a3ab4c31b41e35b10e
4
+ data.tar.gz: e6e3ed8c59296a260b80d851a26fbd347662571b6650987d791dcaa1e9e2ef44
5
5
  SHA512:
6
- metadata.gz: a7a29ff7471a33da771a5a5ace1906e7e017aa3640f79779d1cd42c8edf1e52d2c3470489021c4826eefa7bf4023135260347cc004a2df9ddfcdb639a3fa0dfe
7
- data.tar.gz: d9192d67594cc4f86392b5d45b3f41ed13e7321cc52406168f9edb073bcc985c384252000713c20294c6a38ed8fe8960ff544216cd73f9a3c74447050c8176a7
6
+ metadata.gz: 38e048fa380035adf7907ce3839911d0515686537a2cc6e7e96bce559006ef54aadcfadbfaf0edf73ab26d285e9de3593d5cbbd35e935c050f8b3423e4db8a2d
7
+ data.tar.gz: 80ffb413ffcf71cea9cf68e766a55a4f22a03f7f1f9128a7746be1357b2cca2b06a60ca8863533625c6c2298ffd859e6afd9303bc19be5580d9e52fdcb8196af
@@ -0,0 +1,21 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby-version: ['3.0', '3.1', '3.2', '3.3', ruby-head]
11
+
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - name: Set up Ruby ${{ matrix.ruby-version }}
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby-version }}
18
+ bundler-cache: true # 'bundle install' and cache
19
+ - name: Run specs
20
+ run: |
21
+ bundle exec rspec
@@ -0,0 +1,17 @@
1
+ name: Lint
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ lint:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ - name: Set up Ruby ${{ matrix.ruby-version }}
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.7
14
+ bundler-cache: true # 'bundle install' and cache
15
+ - name: Run specs
16
+ run: |
17
+ bundle exec rubocop
data/CHANGELOG.md CHANGED
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [0.11.0] - 2024-12-20
8
+ - Prevent strategy from running when the current path matches a dispatch request ([60](https://github.com/waiting-for-dev/warden-jwt_auth/pull/60))
9
+
7
10
  ## [0.10.1] - 2024-12-15
8
11
  - Fix version mismatch
9
12
 
@@ -47,8 +47,7 @@ module Warden
47
47
  end
48
48
 
49
49
  def request_matches?(path_info, method)
50
- dispatch_requests.each do |tuple|
51
- dispatch_method, dispatch_path = tuple
50
+ dispatch_requests.each do |(dispatch_method, dispatch_path)|
52
51
  return true if path_info.match(dispatch_path) &&
53
52
  method == dispatch_method
54
53
  end
@@ -7,8 +7,10 @@ module Warden
7
7
  # Warden strategy to authenticate an user through a JWT token in the
8
8
  # `Authorization` request header
9
9
  class Strategy < Warden::Strategies::Base
10
+ include JWTAuth::Import['dispatch_requests']
11
+
10
12
  def valid?
11
- token_exists? && issuer_claim_valid?
13
+ token_exists? && issuer_claim_valid? && !path_is_dispatch_request_path?
12
14
  end
13
15
 
14
16
  def store?
@@ -25,6 +27,14 @@ module Warden
25
27
 
26
28
  private
27
29
 
30
+ def path_is_dispatch_request_path?
31
+ current_path = EnvHelper.path_info(env)
32
+ request_method = EnvHelper.request_method(env)
33
+ dispatch_requests.any? do |(dispatch_method, dispatch_path)|
34
+ request_method == dispatch_method && current_path.match(dispatch_path)
35
+ end
36
+ end
37
+
28
38
  def issuer_claim_valid?
29
39
  configured_issuer = Warden::JWTAuth.config.issuer
30
40
  return true if configured_issuer.nil?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Warden
4
4
  module JWTAuth
5
- VERSION = '0.10.1'
5
+ VERSION = '0.11.0'
6
6
  end
7
7
  end
@@ -19,6 +19,8 @@ module Warden
19
19
  module JWTAuth
20
20
  extend Dry::Configurable
21
21
 
22
+ module_function
23
+
22
24
  def symbolize_keys(hash)
23
25
  hash.transform_keys(&:to_sym)
24
26
  end
@@ -36,8 +38,6 @@ module Warden
36
38
  end
37
39
  end
38
40
 
39
- module_function :constantize_values, :symbolize_keys, :upcase_first_items
40
-
41
41
  # The secret used to encode the token
42
42
  setting :secret
43
43
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden-jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Busqué
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-15 00:00:00.000000000 Z
11
+ date: 2024-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-auto_inject
@@ -214,10 +214,11 @@ extra_rdoc_files: []
214
214
  files:
215
215
  - ".codeclimate.yml"
216
216
  - ".github/FUNDING.yml"
217
+ - ".github/workflows/ci.yml"
218
+ - ".github/workflows/lint.yml"
217
219
  - ".gitignore"
218
220
  - ".rspec"
219
221
  - ".rubocop.yml"
220
- - ".travis.yml"
221
222
  - CHANGELOG.md
222
223
  - CODE_OF_CONDUCT.md
223
224
  - Dockerfile
data/.travis.yml DELETED
@@ -1,21 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.6
5
- - 2.7
6
- - 3.0
7
- - ruby-head
8
- before_install:
9
- - gem update --system --no-doc
10
- - gem install bundler
11
- script:
12
- - bundle exec rspec
13
- - bundle exec rubocop
14
- - bundle exec codeclimate-test-reporter
15
- jobs:
16
- allow_failures:
17
- - rvm: ruby-head
18
- addons:
19
- code_climate:
20
- repo_token:
21
- secure: neJ5LVLV6vgeCnerSQjUpLuQDvxEH87iW8swCSWl2hTtPcD/GuwYSeSXnhH72HVHi/9basHHhaYPcE2YeBwBCr39PhiHMNwS5GGGk/RGjKpU/Gt1KXV8KXTbNGT4v+ZMM3cdsdDfe8OnzGguNVsdxseHa3KE2pyuvo2a0swXwKa7BU9VB/3ZoZvvfI3Xr9im4eklWam5yCwVR0FOF7epzmNTKMXcUga2BOc9PV5aVELzLILLCHCJSCupe5Rx8mfcsRoRmZXKduF8Ke3eq8eULvLEo4EGfC107najOqrKt7x8uDVIsuGrP4LUQ4ainmNEb2jIvpjuqAxpusMjhpjCINF1Tn0OXK93OXAp4QKeIYoYEqKtzRxX0TWFNWHB8ombF9HTMF2DmloDZyFRiI40JSMImU0hc4MDxRgiTW5MDWGbohDaJ+9VV6+rIqtlEfLhgj1grFBAroaJce9BB7RQEmfsZPzhC2VXwGxHw/YkJgzBNGq1/9E1DoTY9RPSNTQfSRodhI3XW8LSQSHTBeXZvymVcjeOyYgjzJYviLHR8QS4cXpUALtlFXyaMkPHUBLUn8XsBa5Azfh5y3qPMGiJq1/qaHA4mKj5ls+ngFbzOq82sYGAKgQHj/ZDb+FZMQQanp4jyWADKcpXcmINb9jEQwkU0bjpuhUYtghASxH1Kl8=