tiddle 1.7.1 → 1.8.1
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/ruby.yml +3 -12
- data/.rubocop.yml +1 -61
- data/CHANGELOG.md +14 -0
- data/CONTRIBUTING.md +22 -0
- data/Dockerfile +12 -0
- data/Makefile +16 -0
- data/docker-compose.yml +24 -0
- data/gemfiles/rails6.1.gemfile +1 -1
- data/gemfiles/rails7.0.gemfile +1 -1
- data/gemfiles/rails7.1.gemfile +7 -0
- data/lib/tiddle/strategy.rb +18 -3
- data/lib/tiddle/version.rb +1 -1
- data/spec/strategy_spec.rb +84 -0
- data/spec/support/backend.rb +4 -8
- data/tiddle.gemspec +2 -2
- metadata +14 -12
- data/gemfiles/rails5.2.gemfile +0 -7
- data/gemfiles/rails6.0.gemfile +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f2ed0612bc75fa65d51698a55ee988a5c490a4d3effb5427dd4d1a28e6245dd
|
4
|
+
data.tar.gz: 427329473b539b834b336fa06b1d7ec2112a1518eee77ade08b82bbd7aefb2a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dc7f6abcdccab03224a92f2d7086afa8efa1b20f9fda55289028ccb5530ed930d0e0ed3ca56954fc25f376edad07d3bc0483dbeb69c0675ee7d7698f9786876
|
7
|
+
data.tar.gz: 2c061b3ecf31c7b75481f973ea947c1d722f8bb052b22b20cab86fc45417227d35deede8b91afd585935a4371ab44dfefbc72d3d3f3f872c6a2709c54fd8b722
|
data/.github/workflows/ruby.yml
CHANGED
@@ -12,26 +12,17 @@ jobs:
|
|
12
12
|
fail-fast: false
|
13
13
|
matrix:
|
14
14
|
gemfile:
|
15
|
-
- rails5.2
|
16
|
-
- rails6.0
|
17
15
|
- rails6.1
|
18
16
|
- rails7.0
|
17
|
+
- rails7.1
|
19
18
|
ruby:
|
20
|
-
- "2.7"
|
21
19
|
- "3.0"
|
22
20
|
- "3.1"
|
21
|
+
- "3.2"
|
22
|
+
- "3.3"
|
23
23
|
backend:
|
24
24
|
- active_record
|
25
25
|
- mongoid
|
26
|
-
exclude:
|
27
|
-
- gemfile: rails5.2
|
28
|
-
ruby: "3.0"
|
29
|
-
- gemfile: rails5.2
|
30
|
-
ruby: "3.1"
|
31
|
-
- gemfile: rails6.0
|
32
|
-
ruby: "3.1"
|
33
|
-
- gemfile: rails6.1
|
34
|
-
ruby: "3.1"
|
35
26
|
name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}, ${{ matrix.backend }}
|
36
27
|
runs-on: ubuntu-latest
|
37
28
|
env:
|
data/.rubocop.yml
CHANGED
@@ -8,6 +8,7 @@ AllCops:
|
|
8
8
|
- 'spec/spec_helper.rb'
|
9
9
|
- 'vendor/bundle/**/*'
|
10
10
|
SuggestExtensions: false
|
11
|
+
NewCops: enable
|
11
12
|
Style/StringLiterals:
|
12
13
|
Enabled: false
|
13
14
|
Style/Documentation:
|
@@ -25,64 +26,3 @@ Metrics/BlockLength:
|
|
25
26
|
- 'spec/**/*'
|
26
27
|
Metrics/MethodLength:
|
27
28
|
Max: 15
|
28
|
-
|
29
|
-
Gemspec/DateAssignment:
|
30
|
-
Enabled: true
|
31
|
-
Layout/SpaceBeforeBrackets:
|
32
|
-
Enabled: true
|
33
|
-
Lint/AmbiguousAssignment:
|
34
|
-
Enabled: true
|
35
|
-
Lint/DeprecatedConstants:
|
36
|
-
Enabled: true
|
37
|
-
Lint/DuplicateBranch:
|
38
|
-
Enabled: true
|
39
|
-
Lint/DuplicateRegexpCharacterClassElement:
|
40
|
-
Enabled: true
|
41
|
-
Lint/EmptyBlock:
|
42
|
-
Enabled: true
|
43
|
-
Lint/EmptyClass:
|
44
|
-
Enabled: true
|
45
|
-
Lint/LambdaWithoutLiteralBlock:
|
46
|
-
Enabled: true
|
47
|
-
Lint/NoReturnInBeginEndBlocks:
|
48
|
-
Enabled: true
|
49
|
-
Lint/NumberedParameterAssignment:
|
50
|
-
Enabled: true
|
51
|
-
Lint/OrAssignmentToConstant:
|
52
|
-
Enabled: true
|
53
|
-
Lint/RedundantDirGlobSort:
|
54
|
-
Enabled: true
|
55
|
-
Lint/SymbolConversion:
|
56
|
-
Enabled: true
|
57
|
-
Lint/ToEnumArguments:
|
58
|
-
Enabled: true
|
59
|
-
Lint/TripleQuotes:
|
60
|
-
Enabled: true
|
61
|
-
Lint/UnexpectedBlockArity:
|
62
|
-
Enabled: true
|
63
|
-
Lint/UnmodifiedReduceAccumulator:
|
64
|
-
Enabled: true
|
65
|
-
Style/ArgumentsForwarding:
|
66
|
-
Enabled: true
|
67
|
-
Style/CollectionCompact:
|
68
|
-
Enabled: true
|
69
|
-
Style/DocumentDynamicEvalDefinition:
|
70
|
-
Enabled: true
|
71
|
-
Style/EndlessMethod:
|
72
|
-
Enabled: true
|
73
|
-
Style/HashConversion:
|
74
|
-
Enabled: true
|
75
|
-
Style/HashExcept:
|
76
|
-
Enabled: true
|
77
|
-
Style/IfWithBooleanLiteralBranches:
|
78
|
-
Enabled: true
|
79
|
-
Style/NegatedIfElseCondition:
|
80
|
-
Enabled: true
|
81
|
-
Style/NilLambda:
|
82
|
-
Enabled: true
|
83
|
-
Style/RedundantArgument:
|
84
|
-
Enabled: true
|
85
|
-
Style/StringChars:
|
86
|
-
Enabled: true
|
87
|
-
Style/SwapValues:
|
88
|
-
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
### 1.8.1
|
2
|
+
|
3
|
+
Remove Rails 5.2 and 6.0 support
|
4
|
+
|
5
|
+
Remove Ruby 2.7 support
|
6
|
+
|
7
|
+
Add Rails 7.1 support
|
8
|
+
|
9
|
+
Add Ruby 3.2 and 3.3 support
|
10
|
+
|
11
|
+
### 1.8.0
|
12
|
+
|
13
|
+
Support different touch interval based on expiration time (Daniel André da Silva)
|
14
|
+
|
1
15
|
### 1.7.1
|
2
16
|
|
3
17
|
Fix invalid headers generated when model is namespaced (Ariel Agne da Silveira)
|
data/CONTRIBUTING.md
CHANGED
@@ -9,3 +9,25 @@
|
|
9
9
|
3. Introduce your change. If it's a new feature then write a test for it as well.
|
10
10
|
4. Make sure that tests are passing.
|
11
11
|
5. Push to your fork and submit a pull request.
|
12
|
+
|
13
|
+
#### Docker for development
|
14
|
+
|
15
|
+
Alternatively you can use Docker for the development setup. This requires Docker
|
16
|
+
and Docker Compose installed.
|
17
|
+
|
18
|
+
```
|
19
|
+
make build
|
20
|
+
make bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
And in order to run the tests and linter checks:
|
24
|
+
|
25
|
+
```
|
26
|
+
make test
|
27
|
+
```
|
28
|
+
|
29
|
+
After you're done, cleanup leftover containers:
|
30
|
+
|
31
|
+
```
|
32
|
+
make cleanup
|
33
|
+
```
|
data/Dockerfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
FROM ruby:3.3-alpine
|
2
|
+
|
3
|
+
RUN apk add build-base sqlite-dev tzdata git bash
|
4
|
+
RUN gem update --system && gem install bundler
|
5
|
+
|
6
|
+
WORKDIR /library
|
7
|
+
|
8
|
+
ENV BUNDLE_PATH=/vendor/bundle \
|
9
|
+
BUNDLE_BIN=/vendor/bundle/bin \
|
10
|
+
GEM_HOME=/vendor/bundle
|
11
|
+
|
12
|
+
ENV PATH="${BUNDLE_BIN}:${PATH}"
|
data/Makefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
.PHONY: build bundle test bash cleanup
|
2
|
+
|
3
|
+
build:
|
4
|
+
docker-compose build
|
5
|
+
|
6
|
+
bundle:
|
7
|
+
docker-compose run --rm library bundle install
|
8
|
+
|
9
|
+
test:
|
10
|
+
docker-compose run --rm library bundle exec rake
|
11
|
+
|
12
|
+
bash:
|
13
|
+
docker-compose run --rm library bash
|
14
|
+
|
15
|
+
cleanup:
|
16
|
+
docker-compose down
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
version: "3.9"
|
2
|
+
services:
|
3
|
+
library:
|
4
|
+
platform: linux/x86_64
|
5
|
+
build:
|
6
|
+
context: .
|
7
|
+
stdin_open: true
|
8
|
+
tty: true
|
9
|
+
volumes:
|
10
|
+
- ".:/library"
|
11
|
+
- vendor:/vendor
|
12
|
+
depends_on:
|
13
|
+
- redis
|
14
|
+
environment:
|
15
|
+
- REDIS_URL=redis://redis:6379/1
|
16
|
+
- BUNDLE_GEMFILE=gemfiles/rails7.1.gemfile
|
17
|
+
redis:
|
18
|
+
image: "redis:6-alpine"
|
19
|
+
command: redis-server
|
20
|
+
volumes:
|
21
|
+
- "redis:/data"
|
22
|
+
volumes:
|
23
|
+
vendor:
|
24
|
+
redis:
|
data/gemfiles/rails6.1.gemfile
CHANGED
data/gemfiles/rails7.0.gemfile
CHANGED
data/lib/tiddle/strategy.rb
CHANGED
@@ -57,15 +57,30 @@ module Devise
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def touch_token(token)
|
60
|
-
|
60
|
+
return unless token.last_used_at < touch_token_interval(token).ago
|
61
|
+
|
62
|
+
token.update_attribute(:last_used_at, Time.current)
|
61
63
|
end
|
62
64
|
|
63
65
|
def unexpired?(token)
|
64
|
-
return true
|
65
|
-
return true if token.expires_in.blank? || token.expires_in.zero?
|
66
|
+
return true if expiration_disabled?(token)
|
66
67
|
|
67
68
|
Time.current <= token.last_used_at + token.expires_in
|
68
69
|
end
|
70
|
+
|
71
|
+
def touch_token_interval(token)
|
72
|
+
return 1.hour if expiration_disabled?(token) || token.expires_in >= 24.hours
|
73
|
+
|
74
|
+
return 5.minutes if token.expires_in >= 1.hour
|
75
|
+
|
76
|
+
1.minute
|
77
|
+
end
|
78
|
+
|
79
|
+
def expiration_disabled?(token)
|
80
|
+
!token.respond_to?(:expires_in) ||
|
81
|
+
token.expires_in.blank? ||
|
82
|
+
token.expires_in.zero?
|
83
|
+
end
|
69
84
|
end
|
70
85
|
end
|
71
86
|
end
|
data/lib/tiddle/version.rb
CHANGED
data/spec/strategy_spec.rb
CHANGED
@@ -217,5 +217,89 @@ describe "Authentication using Tiddle strategy", type: :request do
|
|
217
217
|
expect(response.status).to eq 401
|
218
218
|
end
|
219
219
|
end
|
220
|
+
|
221
|
+
context "with value lower than 24 hours" do
|
222
|
+
before do
|
223
|
+
@token = Tiddle.create_and_return_token(@user, FakeRequest.new, expires_in: 1.hour)
|
224
|
+
end
|
225
|
+
|
226
|
+
context "and token was last used a minute ago" do
|
227
|
+
before do
|
228
|
+
@user.authentication_tokens.last.update_attribute(:last_used_at, 1.minute.ago)
|
229
|
+
end
|
230
|
+
|
231
|
+
it "does not update last_used_at field" do
|
232
|
+
expect do
|
233
|
+
get(
|
234
|
+
secrets_path,
|
235
|
+
headers: {
|
236
|
+
"X-USER-EMAIL" => "test@example.com",
|
237
|
+
"X-USER-TOKEN" => @token
|
238
|
+
}
|
239
|
+
)
|
240
|
+
end.not_to(change { @user.authentication_tokens.last.reload.last_used_at })
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context "and token was last used 5 minutes ago" do
|
245
|
+
before do
|
246
|
+
@user.authentication_tokens.last.update_attribute(:last_used_at, 5.minute.ago)
|
247
|
+
end
|
248
|
+
|
249
|
+
it "updates last_used_at field" do
|
250
|
+
expect do
|
251
|
+
get(
|
252
|
+
secrets_path,
|
253
|
+
headers: {
|
254
|
+
"X-USER-EMAIL" => "test@example.com",
|
255
|
+
"X-USER-TOKEN" => @token
|
256
|
+
}
|
257
|
+
)
|
258
|
+
end.to(change { @user.authentication_tokens.last.reload.last_used_at })
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
context "with value lower than 1 hour" do
|
264
|
+
before do
|
265
|
+
@token = Tiddle.create_and_return_token(@user, FakeRequest.new, expires_in: 30.minutes)
|
266
|
+
end
|
267
|
+
|
268
|
+
context "and token was last used less than a minute ago" do
|
269
|
+
before do
|
270
|
+
@user.authentication_tokens.last.update_attribute(:last_used_at, 30.seconds.ago)
|
271
|
+
end
|
272
|
+
|
273
|
+
it "does not update last_used_at field" do
|
274
|
+
expect do
|
275
|
+
get(
|
276
|
+
secrets_path,
|
277
|
+
headers: {
|
278
|
+
"X-USER-EMAIL" => "test@example.com",
|
279
|
+
"X-USER-TOKEN" => @token
|
280
|
+
}
|
281
|
+
)
|
282
|
+
end.not_to(change { @user.authentication_tokens.last.reload.last_used_at })
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
context "and token was last used a minute ago" do
|
287
|
+
before do
|
288
|
+
@user.authentication_tokens.last.update_attribute(:last_used_at, 1.minute.ago)
|
289
|
+
end
|
290
|
+
|
291
|
+
it "updates last_used_at field" do
|
292
|
+
expect do
|
293
|
+
get(
|
294
|
+
secrets_path,
|
295
|
+
headers: {
|
296
|
+
"X-USER-EMAIL" => "test@example.com",
|
297
|
+
"X-USER-TOKEN" => @token
|
298
|
+
}
|
299
|
+
)
|
300
|
+
end.to(change { @user.authentication_tokens.last.reload.last_used_at })
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
220
304
|
end
|
221
305
|
end
|
data/spec/support/backend.rb
CHANGED
@@ -23,14 +23,10 @@ module Backend
|
|
23
23
|
# Do initial migration
|
24
24
|
path = File.expand_path("../rails_app_active_record/db/migrate/", File.dirname(__FILE__))
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
).migrate
|
31
|
-
else
|
32
|
-
ActiveRecord::MigrationContext.new(path).migrate
|
33
|
-
end
|
26
|
+
ActiveRecord::MigrationContext.new(
|
27
|
+
path,
|
28
|
+
ActiveRecord::SchemaMigration
|
29
|
+
).migrate
|
34
30
|
end
|
35
31
|
end
|
36
32
|
|
data/tiddle.gemspec
CHANGED
@@ -16,10 +16,10 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.required_ruby_version = '>=
|
19
|
+
spec.required_ruby_version = '>= 3.0.0'
|
20
20
|
|
21
21
|
spec.add_dependency "devise", ">= 4.0.0.rc1", "< 5"
|
22
|
-
spec.add_dependency "activerecord", ">=
|
22
|
+
spec.add_dependency "activerecord", ">= 6.1.0"
|
23
23
|
spec.add_development_dependency "rake"
|
24
24
|
spec.add_development_dependency "rspec-rails"
|
25
25
|
spec.add_development_dependency "simplecov"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tiddle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Niedzielski
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: devise
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
39
|
+
version: 6.1.0
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
version: 6.1.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,7 @@ dependencies:
|
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
|
-
description:
|
131
|
+
description:
|
132
132
|
email:
|
133
133
|
- adamsunday@gmail.com
|
134
134
|
executables: []
|
@@ -141,14 +141,16 @@ files:
|
|
141
141
|
- ".rubocop.yml"
|
142
142
|
- CHANGELOG.md
|
143
143
|
- CONTRIBUTING.md
|
144
|
+
- Dockerfile
|
144
145
|
- LICENSE.txt
|
146
|
+
- Makefile
|
145
147
|
- README.md
|
146
148
|
- Rakefile
|
147
149
|
- config/locales/en.yml
|
148
|
-
-
|
149
|
-
- gemfiles/rails6.0.gemfile
|
150
|
+
- docker-compose.yml
|
150
151
|
- gemfiles/rails6.1.gemfile
|
151
152
|
- gemfiles/rails7.0.gemfile
|
153
|
+
- gemfiles/rails7.1.gemfile
|
152
154
|
- lib/tiddle.rb
|
153
155
|
- lib/tiddle/model.rb
|
154
156
|
- lib/tiddle/model_name.rb
|
@@ -194,7 +196,7 @@ homepage: ''
|
|
194
196
|
licenses:
|
195
197
|
- MIT
|
196
198
|
metadata: {}
|
197
|
-
post_install_message:
|
199
|
+
post_install_message:
|
198
200
|
rdoc_options: []
|
199
201
|
require_paths:
|
200
202
|
- lib
|
@@ -202,15 +204,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
204
|
requirements:
|
203
205
|
- - ">="
|
204
206
|
- !ruby/object:Gem::Version
|
205
|
-
version:
|
207
|
+
version: 3.0.0
|
206
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
209
|
requirements:
|
208
210
|
- - ">="
|
209
211
|
- !ruby/object:Gem::Version
|
210
212
|
version: '0'
|
211
213
|
requirements: []
|
212
|
-
rubygems_version: 3.
|
213
|
-
signing_key:
|
214
|
+
rubygems_version: 3.5.12
|
215
|
+
signing_key:
|
214
216
|
specification_version: 4
|
215
217
|
summary: Token authentication for Devise which supports multiple tokens per model
|
216
218
|
test_files:
|
data/gemfiles/rails5.2.gemfile
DELETED