keyless 2.0.0 → 2.1.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/release.yml +1 -1
- data/.github/workflows/test.yml +1 -1
- data/.rubocop.yml +1 -1
- data/Appraisals +4 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -1
- data/gemfiles/rails_7.1.gemfile +1 -1
- data/gemfiles/rails_7.2.gemfile +1 -1
- data/gemfiles/rails_8.0.gemfile +1 -1
- data/gemfiles/rails_8.1.gemfile +23 -0
- data/keyless.gemspec +1 -1
- data/lib/keyless/configuration.rb +40 -2
- data/lib/keyless/jwt.rb +0 -5
- data/lib/keyless/version.rb +1 -1
- data/lib/keyless.rb +2 -1
- metadata +6 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e7856a57560d9da148dd9fd926e99a12b7e4893c817d60aeebe43f595abb2297
|
|
4
|
+
data.tar.gz: 6ae408a15651a845a135ea9cd70f478e38d35087be27adc0756cb755b623e111
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 98c7a9d1cb2637c1d2f1f359071b5354a43955c207cf35b03aae0eb072427aeb57999b8d81c59e8f99607e15a71320411239a8c12976a14a4a5fb682c540fade
|
|
7
|
+
data.tar.gz: 55742a9c23e02127190bbf56869dc6c4ee9d10a1411d936260d235c1432c28aa6f913f615c758b5c89c8932502b940b5d534bf46ad67580b48605aa3f9b755fc
|
data/.github/workflows/test.yml
CHANGED
data/.rubocop.yml
CHANGED
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
* TODO: Replace this bullet point with an actual description of a change.
|
|
4
4
|
|
|
5
|
+
### 2.1.0 (23 October 2025)
|
|
6
|
+
|
|
7
|
+
* Dropped Reek ([#14](https://github.com/hausgold/keyless/pull/14))
|
|
8
|
+
* Added support for Rails 8.1 ([#15](https://github.com/hausgold/keyless/pull/15))
|
|
9
|
+
* Switched from `ActiveSupport::Configurable` to a custom implementation based
|
|
10
|
+
on `ActiveSupport::OrderedOptions` ([#16](https://github.com/hausgold/keyless/pull/16))
|
|
11
|
+
|
|
5
12
|
### 2.0.0 (28 June 2025)
|
|
6
13
|
|
|
7
14
|
* Corrected some RuboCop glitches ([#12](https://github.com/hausgold/keyless/pull/12))
|
data/Gemfile
CHANGED
data/gemfiles/rails_7.1.gemfile
CHANGED
data/gemfiles/rails_7.2.gemfile
CHANGED
data/gemfiles/rails_8.0.gemfile
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# This file was generated by Appraisal
|
|
2
|
+
|
|
3
|
+
source "https://rubygems.org"
|
|
4
|
+
|
|
5
|
+
gem "appraisal", "~> 2.4"
|
|
6
|
+
gem "bundler", "~> 2.6"
|
|
7
|
+
gem "countless", "~> 2.2"
|
|
8
|
+
gem "guard-rspec", "~> 4.7"
|
|
9
|
+
gem "railties", ">= 7.1"
|
|
10
|
+
gem "rake", "~> 13.0"
|
|
11
|
+
gem "rspec", "~> 3.12"
|
|
12
|
+
gem "rubocop"
|
|
13
|
+
gem "rubocop-rails"
|
|
14
|
+
gem "rubocop-rspec"
|
|
15
|
+
gem "simplecov", ">= 0.22"
|
|
16
|
+
gem "timecop", ">= 0.9.6"
|
|
17
|
+
gem "vcr", "~> 6.0"
|
|
18
|
+
gem "webmock", "~> 3.18"
|
|
19
|
+
gem "yard", ">= 0.9.28"
|
|
20
|
+
gem "yard-activesupport-concern", ">= 0.0.1"
|
|
21
|
+
gem "activesupport", "~> 8.1.0"
|
|
22
|
+
|
|
23
|
+
gemspec path: "../"
|
data/keyless.gemspec
CHANGED
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
|
38
38
|
spec.add_dependency 'activesupport', '>= 7.1'
|
|
39
39
|
spec.add_dependency 'httparty', '>= 0.21'
|
|
40
40
|
spec.add_dependency 'jwt', '~> 2.6'
|
|
41
|
-
spec.add_dependency 'mutex_m', '
|
|
41
|
+
spec.add_dependency 'mutex_m', '>= 0.3'
|
|
42
42
|
spec.add_dependency 'recursive-open-struct', '~> 2.0'
|
|
43
43
|
spec.add_dependency 'zeitwerk', '~> 2.6'
|
|
44
44
|
end
|
|
@@ -2,8 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
module Keyless
|
|
4
4
|
# The configuration for the JWT authentication concern.
|
|
5
|
-
class Configuration
|
|
6
|
-
|
|
5
|
+
class Configuration < ActiveSupport::OrderedOptions
|
|
6
|
+
# Track our configurations settings (+Symbol+ keys) and their defaults as
|
|
7
|
+
# lazy-loaded +Proc+'s values
|
|
8
|
+
class_attribute :defaults,
|
|
9
|
+
instance_reader: true,
|
|
10
|
+
instance_writer: false,
|
|
11
|
+
instance_predicate: false,
|
|
12
|
+
default: {}
|
|
13
|
+
|
|
14
|
+
# Create a new +Configuration+ instance with all settings populated with
|
|
15
|
+
# their respective defaults.
|
|
16
|
+
#
|
|
17
|
+
# @param args [Hash{Symbol => Mixed}] additional settings which
|
|
18
|
+
# overwrite the defaults
|
|
19
|
+
# @return [Configuration] the new configuration instance
|
|
20
|
+
def initialize(**args)
|
|
21
|
+
super()
|
|
22
|
+
defaults.each { |key, default| self[key] = instance_exec(&default) }
|
|
23
|
+
merge!(**args)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# A simple DSL method to define new configuration accessors/settings with
|
|
27
|
+
# their defaults. The defaults can be retrieved with
|
|
28
|
+
# +Configuration.defaults+ or +Configuration.new.defaults+.
|
|
29
|
+
#
|
|
30
|
+
# @param name [Symbol, String] the name of the configuration
|
|
31
|
+
# accessor/setting
|
|
32
|
+
# @param default [Mixed, nil] a non-lazy-loaded static value, serving as a
|
|
33
|
+
# default value for the setting
|
|
34
|
+
# @param block [Proc] when given, the default value will be lazy-loaded
|
|
35
|
+
# (result of the Proc)
|
|
36
|
+
def self.config_accessor(name, default = nil, &block)
|
|
37
|
+
# Save the given configuration accessor default value
|
|
38
|
+
defaults[name.to_sym] = block || -> { default }
|
|
39
|
+
|
|
40
|
+
# Compile reader/writer methods so we don't have to go through
|
|
41
|
+
# +ActiveSupport::OrderedOptions#method_missing+.
|
|
42
|
+
define_method(name) { self[name] }
|
|
43
|
+
define_method("#{name}=") { |value| self[name] = value }
|
|
44
|
+
end
|
|
7
45
|
|
|
8
46
|
# The authenticator function which must be defined by the user to
|
|
9
47
|
# verify the given JSON Web Token. Here comes all your logic to lookup
|
data/lib/keyless/jwt.rb
CHANGED
|
@@ -20,8 +20,6 @@ module Keyless
|
|
|
20
20
|
::JWT::InvalidPayload
|
|
21
21
|
].freeze
|
|
22
22
|
|
|
23
|
-
# :reek:Attribute because its fine to be extern-modifiable at these
|
|
24
|
-
# instances
|
|
25
23
|
attr_reader :payload, :token
|
|
26
24
|
attr_writer :verification_key, :jwt_options
|
|
27
25
|
attr_accessor :issuer, :beholder
|
|
@@ -95,9 +93,6 @@ module Keyless
|
|
|
95
93
|
# JWT string representation and check this.
|
|
96
94
|
#
|
|
97
95
|
# @return [Boolean] Whenever the token is valid or not
|
|
98
|
-
#
|
|
99
|
-
# :reek:NilCheck because we have to check the token
|
|
100
|
-
# origin and react on it
|
|
101
96
|
def valid?
|
|
102
97
|
JWT.decode(token, verification_key, true, jwt_options) && true
|
|
103
98
|
rescue *RESCUE_JWT_EXCEPTIONS
|
data/lib/keyless/version.rb
CHANGED
data/lib/keyless.rb
CHANGED
|
@@ -4,8 +4,9 @@ require 'zeitwerk'
|
|
|
4
4
|
require 'logger'
|
|
5
5
|
require 'active_support'
|
|
6
6
|
require 'active_support/concern'
|
|
7
|
-
require 'active_support/
|
|
7
|
+
require 'active_support/ordered_options'
|
|
8
8
|
require 'active_support/cache'
|
|
9
|
+
require 'active_support/core_ext/class/attribute'
|
|
9
10
|
require 'active_support/core_ext/hash'
|
|
10
11
|
require 'active_support/time'
|
|
11
12
|
require 'active_support/time_with_zone'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: keyless
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hermann Mayer
|
|
@@ -57,16 +57,16 @@ dependencies:
|
|
|
57
57
|
name: mutex_m
|
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
|
60
|
-
- - "
|
|
60
|
+
- - ">="
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: 0.3
|
|
62
|
+
version: '0.3'
|
|
63
63
|
type: :runtime
|
|
64
64
|
prerelease: false
|
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
|
67
|
-
- - "
|
|
67
|
+
- - ">="
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: 0.3
|
|
69
|
+
version: '0.3'
|
|
70
70
|
- !ruby/object:Gem::Dependency
|
|
71
71
|
name: recursive-open-struct
|
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -134,6 +134,7 @@ files:
|
|
|
134
134
|
- gemfiles/rails_7.1.gemfile
|
|
135
135
|
- gemfiles/rails_7.2.gemfile
|
|
136
136
|
- gemfiles/rails_8.0.gemfile
|
|
137
|
+
- gemfiles/rails_8.1.gemfile
|
|
137
138
|
- keyless.gemspec
|
|
138
139
|
- lib/keyless.rb
|
|
139
140
|
- lib/keyless/configuration.rb
|