tiddle 1.3.0 → 1.7.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: e5b1f9267f263f6a7f6f8b571bd641dbdba3a3defeea0b1327288c2cb5ea00c9
4
- data.tar.gz: 59aa159c44adf4677e4820d2fd7ab63852376d1a8f80e3a58f807361e560ba6c
3
+ metadata.gz: d20d30a11350b4ee5ffe3a9c6ba9640afa90c13ddf87dac2c9bf6d4160339627
4
+ data.tar.gz: fcd8811ba7c94de4accbf4a7920e6903f780707d5af858c7e9a153691ec53351
5
5
  SHA512:
6
- metadata.gz: 2a03e818d5e1e2c220a6d7bbf4cabfcb7aab34123c4045c06ea443d12814b8e5c8e5799089286de24608066571ea90fc530fec0846b0f2eb537b71cada558972
7
- data.tar.gz: 1eb86b866420fa4877f587a1fbfcf6e7df55a9053f0883564d5b153596253e1f4f11d5007a09c5922802e737987e9b03adee9f53c175bc46e3741d5a7a1b6228
6
+ metadata.gz: baf2289d634255233c6efe5c2988789a63ca05bdf1c278be92d500e50a5009e6875b29ef15c7e1cbb9bd03f131349bcf11757938f166a329389fa3cc720a7399
7
+ data.tar.gz: b972e36c75bb0b1c3bc5f21ef9977d5d9f93e595dfaef6905bd59f458079b9b4f7fb6e5068e35fd6b1aaa6e4e63740c62609db68c89bb87a0353bddf1c702721
@@ -0,0 +1,46 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ gemfile:
15
+ - rails5.2
16
+ - rails6.0
17
+ - rails6.1
18
+ ruby:
19
+ - 2.6
20
+ - 2.7
21
+ - 3.0
22
+ backend:
23
+ - active_record
24
+ - mongoid
25
+ exclude:
26
+ - gemfile: rails5.2
27
+ ruby: 3.0
28
+ name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}, ${{ matrix.backend }}
29
+ runs-on: ubuntu-latest
30
+ env:
31
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
32
+ BACKEND: ${{ matrix.backend }}
33
+
34
+ steps:
35
+ - uses: actions/checkout@v2
36
+ - name: Set up Ruby
37
+ uses: ruby/setup-ruby@v1
38
+ with:
39
+ bundler-cache: true
40
+ ruby-version: ${{ matrix.ruby }}
41
+ - name: Start MongoDB
42
+ uses: supercharge/mongodb-github-action@1.3.0
43
+ if: ${{ matrix.backend == 'mongoid' }}
44
+ - name: Run tests
45
+ run: |
46
+ bundle exec rake spec
data/.rubocop.yml CHANGED
@@ -1,11 +1,13 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
2
+ TargetRubyVersion: 2.6
3
3
  Include:
4
- - 'lib'
5
- - 'spec'
4
+ - 'lib/**/*.rb'
5
+ - 'spec/**/*.rb'
6
6
  Exclude:
7
7
  - 'spec/rails_app/**/*'
8
8
  - 'spec/spec_helper.rb'
9
+ - 'vendor/bundle/**/*'
10
+ SuggestExtensions: false
9
11
  Style/StringLiterals:
10
12
  Enabled: false
11
13
  Style/Documentation:
@@ -14,17 +16,73 @@ Style/FrozenStringLiteralComment:
14
16
  Enabled: false
15
17
  Style/SignalException:
16
18
  Enabled: false
17
- Metrics/LineLength:
19
+ Layout/LineLength:
18
20
  Max: 100
19
21
  Gemspec/OrderedDependencies:
20
22
  Enabled: false
21
- Naming/FileName:
22
- Exclude:
23
- - 'Rakefile'
24
- - 'Gemfile'
25
- - 'Appraisals'
26
23
  Metrics/BlockLength:
27
24
  Exclude:
28
25
  - 'spec/**/*'
29
26
  Metrics/MethodLength:
30
27
  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/Appraisals CHANGED
@@ -1,19 +1,17 @@
1
- appraise "rails4.2" do
2
- gem "rails", "~> 4.2.0"
3
- gem "mongoid", "~> 5"
4
- end
5
-
6
- appraise "rails5.0" do
7
- gem "rails", "~> 5.0.0"
1
+ appraise "rails5.2" do
2
+ gem "rails", "~> 5.2.1"
8
3
  gem "mongoid", "~> 6"
4
+ gem "sqlite3", "~> 1.3.13"
9
5
  end
10
6
 
11
- appraise "rails5.1" do
12
- gem "rails", "~> 5.1.0"
13
- gem "mongoid", "~> 6"
7
+ appraise "rails6.0" do
8
+ gem "rails", "~> 6.0.0"
9
+ gem "mongoid", "~> 7"
10
+ gem "sqlite3"
14
11
  end
15
12
 
16
- appraise "rails5.2" do
17
- gem "rails", "~> 5.2.1"
18
- gem "mongoid", "~> 6"
13
+ appraise "rails6.1" do
14
+ gem "rails", "~> 6.1.0"
15
+ gem "mongoid"
16
+ gem "sqlite3"
19
17
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ ### 1.7.0
2
+
3
+ Add ability to track additional info in tokens (Marcelo Silveira)
4
+
5
+ Remove Ruby 2.5 support
6
+
7
+ ### 1.6.0
8
+
9
+ Add Rails 6.1 support
10
+
11
+ Add Ruby 3.0 support
12
+
13
+ Remove Rails 4.2 support
14
+
15
+ Remove Ruby 2.4 support
16
+
17
+ ### 1.5.0
18
+
19
+ Add Rails 6 support
20
+
21
+ Fix warning on Ruby 2.7 (Andy Klimczak)
22
+
23
+ Skip CSRF clean up (Marcelo Silveira)
24
+
25
+ ### 1.4.0
26
+
27
+ Support for Devise 4.6.
28
+
29
+ Relax dependency on Devise.
30
+
31
+ ### 1.3.0
32
+
33
+ Support for Devise 4.5
34
+
1
35
  ### 1.2.0
2
36
 
3
37
  Adds support for MongoDB.
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem "rubocop", "~> 0.52.0"
4
-
5
3
  # Specify your gem's dependencies in tiddle.gemspec
6
4
  gemspec
data/README.md CHANGED
@@ -1,17 +1,11 @@
1
1
  # Tiddle
2
2
 
3
- [![Build Status](https://travis-ci.org/adamniedzielski/tiddle.svg?branch=master)](https://travis-ci.org/adamniedzielski/tiddle)
4
- [![Coverage Status](https://coveralls.io/repos/adamniedzielski/tiddle/badge.svg?branch=master)](https://coveralls.io/r/adamniedzielski/tiddle?branch=master)
5
3
  [![Code Climate](https://codeclimate.com/github/adamniedzielski/tiddle/badges/gpa.svg)](https://codeclimate.com/github/adamniedzielski/tiddle)
6
4
 
7
5
  Tiddle provides Devise strategy for token authentication in API-only Ruby on Rails applications. Its main feature is **support for multiple tokens per user**.
8
6
 
9
7
  Tiddle is lightweight and non-configurable. It does what it has to do and leaves some manual implementation to you.
10
8
 
11
- ## Versions
12
-
13
- Versions 0.7.x+ are meant to support Rails 5.0, but they require Devise 4. If you want to use Devise 3 with Rails 4.2 then take a look at the ```0.6.x``` branch.
14
-
15
9
  ## Installation
16
10
 
17
11
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'appraisal'
6
6
  RSpec::Core::RakeTask.new(spec: :rubocop)
7
7
  RuboCop::RakeTask.new(:rubocop)
8
8
 
9
- if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
9
+ if !ENV["APPRAISAL_INITIALIZED"]
10
10
  task default: :appraisal
11
11
  else
12
12
  task default: :spec
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rubocop", "~> 0.52.0"
6
5
  gem "rails", "~> 5.2.1"
7
6
  gem "mongoid", "~> 6"
7
+ gem "sqlite3", "~> 1.3.13"
8
8
 
9
9
  gemspec path: "../"
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rubocop", "~> 0.52.0"
6
- gem "rails", "~> 4.2.0"
7
- gem "mongoid", "~> 5"
5
+ gem "rails", "~> 6.0.0"
6
+ gem "mongoid", "~> 7"
7
+ gem "sqlite3"
8
8
 
9
9
  gemspec path: "../"
@@ -2,8 +2,8 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rubocop", "~> 0.52.0"
6
- gem "rails", "~> 5.0.0"
7
- gem "mongoid", "~> 6"
5
+ gem "rails", "~> 6.1.0"
6
+ gem "mongoid"
7
+ gem "sqlite3"
8
8
 
9
9
  gemspec path: "../"
@@ -28,6 +28,14 @@ module Devise
28
28
  false
29
29
  end
30
30
 
31
+ # Avoid CSRF clean up for token authentication as it might trigger session creation in API
32
+ # environments even if CSRF prevention is not being used.
33
+ # Devise provides a `clean_up_csrf_token_on_authentication` option but it's not always viable
34
+ # in applications with multiple user models and authentication strategies.
35
+ def clean_up_csrf?
36
+ false
37
+ end
38
+
31
39
  private
32
40
 
33
41
  def authentication_keys_from_headers
@@ -12,12 +12,17 @@ module Tiddle
12
12
  self.maximum_tokens_per_user = maximum_tokens_per_user
13
13
  end
14
14
 
15
- def create_and_return_token(resource, request, expires_in: nil)
15
+ def create_and_return_token(resource, request, expires_in: nil, metadata: {})
16
16
  token_class = authentication_token_class(resource)
17
17
  token, token_body = Devise.token_generator.generate(token_class, :body)
18
18
 
19
19
  resource.authentication_tokens.create!(
20
- token_attributes(token_body, request, expires_in)
20
+ token_attributes(
21
+ token_body: token_body,
22
+ request: request,
23
+ expires_in: expires_in,
24
+ metadata: metadata
25
+ )
21
26
  )
22
27
 
23
28
  token
@@ -56,13 +61,13 @@ module Tiddle
56
61
  end
57
62
  end
58
63
 
59
- def token_attributes(token_body, request, expires_in)
64
+ def token_attributes(token_body:, request:, expires_in:, metadata: {})
60
65
  attributes = {
61
66
  body: token_body,
62
67
  last_used_at: Time.current,
63
68
  ip_address: request.remote_ip,
64
69
  user_agent: request.user_agent
65
- }
70
+ }.merge(metadata)
66
71
 
67
72
  if expires_in
68
73
  attributes.merge(expires_in: expires_in)
@@ -1,3 +1,3 @@
1
1
  module Tiddle
2
- VERSION = "1.3.0".freeze
2
+ VERSION = "1.7.0".freeze
3
3
  end
data/lib/tiddle.rb CHANGED
@@ -6,7 +6,7 @@ require "tiddle/token_issuer"
6
6
 
7
7
  module Tiddle
8
8
  def self.create_and_return_token(resource, request, options = {})
9
- TokenIssuer.build.create_and_return_token(resource, request, options)
9
+ TokenIssuer.build.create_and_return_token(resource, request, **options)
10
10
  end
11
11
 
12
12
  def self.expire_token(resource, request)
@@ -1,4 +1,4 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require File.expand_path('boot', __dir__)
2
2
 
3
3
  require "active_model/railtie"
4
4
  require "active_record/railtie"
@@ -8,7 +8,7 @@ require "action_view/railtie"
8
8
  module RailsApp
9
9
  class Application < Rails::Application
10
10
  config.eager_load = true
11
- config.root = File.expand_path('../../.', __FILE__)
11
+ config.root = File.expand_path('..', __dir__)
12
12
  config.consider_all_requests_local = true
13
13
  config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3
14
14
  end
@@ -1,2 +1,2 @@
1
- ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../../Gemfile', __FILE__)
1
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../Gemfile', __dir__)
2
2
  require 'bundler/setup'
@@ -1,5 +1,5 @@
1
1
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
2
+ require File.expand_path('application', __dir__)
3
3
 
4
4
  # Initialize the Rails application.
5
5
  Rails.application.initialize!
@@ -1,10 +1,4 @@
1
- migration_class = if Rails::VERSION::MAJOR > 4
2
- ActiveRecord::Migration[4.2]
3
- else
4
- ActiveRecord::Migration
5
- end
6
-
7
- class CreateTables < migration_class
1
+ class CreateTables < ActiveRecord::Migration[4.2]
8
2
  # rubocop:disable Metrics/AbcSize
9
3
  # rubocop:disable Metrics/MethodLength
10
4
  def change
@@ -61,6 +55,7 @@ class CreateTables < migration_class
61
55
  t.integer :expires_in, null: false, default: 0
62
56
  t.string :ip_address
63
57
  t.string :user_agent
58
+ t.string :metadata_attr1
64
59
 
65
60
  t.timestamps null: false
66
61
  end
@@ -8,4 +8,5 @@ class AuthenticationToken
8
8
  field :ip_address, type: String
9
9
  field :user_agent, type: String
10
10
  field :expires_in, type: Integer, default: 0
11
+ field :metadata_attr1, type: String
11
12
  end
@@ -5,7 +5,7 @@ class User
5
5
  :registerable,
6
6
  :recoverable,
7
7
  :trackable,
8
- #:validatable Triggers callback to will_save_change_to_email?, fails with mongoid
8
+ :validatable,
9
9
  :token_authenticatable
10
10
 
11
11
  has_many :authentication_tokens
@@ -1,4 +1,4 @@
1
- require File.expand_path('../boot', __FILE__)
1
+ require File.expand_path('boot', __dir__)
2
2
 
3
3
  require "active_model/railtie"
4
4
  require "active_job/railtie"
@@ -9,8 +9,7 @@ require "action_view/railtie"
9
9
  module RailsApp
10
10
  class Application < Rails::Application
11
11
  config.eager_load = true
12
- config.root = File.expand_path('../../.', __FILE__)
12
+ config.root = File.expand_path('..', __dir__)
13
13
  config.consider_all_requests_local = true
14
- config.active_record.sqlite3.represent_boolean_as_integer = true if config.active_record.sqlite3
15
14
  end
16
15
  end
@@ -1,2 +1,2 @@
1
- ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../../Gemfile', __FILE__)
1
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../Gemfile', __dir__)
2
2
  require 'bundler/setup'
@@ -1,5 +1,5 @@
1
1
  # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
2
+ require File.expand_path('application', __dir__)
3
3
 
4
4
  # Initialize the Rails application.
5
5
  Rails.application.initialize!
data/spec/spec_helper.rb CHANGED
@@ -1,11 +1,6 @@
1
1
  require 'bundler/setup'
2
2
  require 'simplecov'
3
- require 'coveralls'
4
3
 
5
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
6
- SimpleCov::Formatter::HTMLFormatter,
7
- Coveralls::SimpleCov::Formatter
8
- ])
9
4
  SimpleCov.start do
10
5
  add_filter "/spec/"
11
6
  end
@@ -13,16 +8,16 @@ end
13
8
  ENV["RAILS_ENV"] = 'test'
14
9
  ENV["DATABASE_URL"] = "sqlite3:db/test.sqlite3"
15
10
 
16
- require 'rails/all'
17
- require 'rspec/rails'
11
+ Dir[__dir__ + "/support/**/*.rb"].each { |f| require f }
12
+
18
13
  require 'devise'
19
14
  require 'tiddle'
20
15
 
21
- Dir[__dir__ + "/support/**/*.rb"].each { |f| require f }
22
-
23
16
  backend = Backend.from_name(ENV['BACKEND'])
24
17
  backend.load!
25
18
 
19
+ require 'rspec/rails'
20
+
26
21
  # This file was generated by the `rspec --init` command. Conventionally, all
27
22
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
28
23
  # The generated `.rspec` file contains `--require spec_helper` which will cause
@@ -6,7 +6,7 @@ describe "Authentication using Tiddle strategy", type: :request do
6
6
  end
7
7
 
8
8
  it "allows to access endpoints which require authentication" do
9
- warningless_get(
9
+ get(
10
10
  secrets_path,
11
11
  headers: {
12
12
  "X-USER-EMAIL" => "test@example.com",
@@ -25,7 +25,7 @@ describe "Authentication using Tiddle strategy", type: :request do
25
25
 
26
26
  it "updates last_used_at field" do
27
27
  expect do
28
- warningless_get(
28
+ get(
29
29
  secrets_path,
30
30
  headers: {
31
31
  "X-USER-EMAIL" => "test@example.com",
@@ -43,7 +43,7 @@ describe "Authentication using Tiddle strategy", type: :request do
43
43
 
44
44
  it "does not update last_used_at field" do
45
45
  expect do
46
- warningless_get(
46
+ get(
47
47
  secrets_path,
48
48
  headers: {
49
49
  "X-USER-EMAIL" => "test@example.com",
@@ -57,7 +57,7 @@ describe "Authentication using Tiddle strategy", type: :request do
57
57
 
58
58
  context "when email contains uppercase letters" do
59
59
  it "converts email to lower case and authenticates user" do
60
- warningless_get(
60
+ get(
61
61
  secrets_path,
62
62
  headers: {
63
63
  "X-USER-EMAIL" => "TEST@example.com",
@@ -76,7 +76,7 @@ describe "Authentication using Tiddle strategy", type: :request do
76
76
  end
77
77
 
78
78
  it "does not allow to access endpoints which require authentication" do
79
- warningless_get(
79
+ get(
80
80
  secrets_path,
81
81
  headers: {
82
82
  "X-USER-EMAIL" => "wrong@example.com",
@@ -94,7 +94,7 @@ describe "Authentication using Tiddle strategy", type: :request do
94
94
  end
95
95
 
96
96
  it "does not allow to access endpoints which require authentication" do
97
- warningless_get(
97
+ get(
98
98
  secrets_path,
99
99
  headers: {
100
100
  "X-USER-EMAIL" => "test@example.com",
@@ -107,7 +107,7 @@ describe "Authentication using Tiddle strategy", type: :request do
107
107
 
108
108
  context "when no headers are passed" do
109
109
  it "does not allow to access endpoints which require authentication" do
110
- warningless_get secrets_path, headers: {}
110
+ get secrets_path, headers: {}
111
111
  expect(response.status).to eq 401
112
112
  end
113
113
  end
@@ -119,7 +119,7 @@ describe "Authentication using Tiddle strategy", type: :request do
119
119
  end
120
120
 
121
121
  it "allows to access endpoints which require authentication" do
122
- warningless_get(
122
+ get(
123
123
  long_secrets_path,
124
124
  headers: {
125
125
  "X-ADMIN-USER-EMAIL" => "test@example.com",
@@ -152,7 +152,7 @@ describe "Authentication using Tiddle strategy", type: :request do
152
152
 
153
153
  it "allows to access endpoints which require authentication with valid \
154
154
  nick name and token" do
155
- warningless_get(
155
+ get(
156
156
  secrets_path,
157
157
  headers: { "X-USER-NICK-NAME" => "test", "X-USER-TOKEN" => @token }
158
158
  )
@@ -168,7 +168,7 @@ describe "Authentication using Tiddle strategy", type: :request do
168
168
 
169
169
  describe "token is not expired" do
170
170
  it "does allow to access endpoints which require authentication" do
171
- warningless_get(
171
+ get(
172
172
  secrets_path,
173
173
  headers: {
174
174
  "X-USER-EMAIL" => "test@example.com",
@@ -181,12 +181,12 @@ describe "Authentication using Tiddle strategy", type: :request do
181
181
 
182
182
  describe "token is expired" do
183
183
  before do
184
- token = @user.authentication_tokens.sort_by(&:id).last
184
+ token = @user.authentication_tokens.max_by(&:id)
185
185
  token.update_attribute(:last_used_at, 1.month.ago)
186
186
  end
187
187
 
188
188
  it "does not allow to access endpoints which require authentication" do
189
- warningless_get(
189
+ get(
190
190
  secrets_path,
191
191
  headers: {
192
192
  "X-USER-EMAIL" => "test@example.com",
@@ -23,10 +23,13 @@ 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
- if Gem::Requirement.new(">= 5.2.0.rc1") =~ Rails.gem_version
27
- ActiveRecord::MigrationContext.new(path).migrate
26
+ if Gem::Requirement.new(">= 6.0.0") =~ Rails.gem_version
27
+ ActiveRecord::MigrationContext.new(
28
+ path,
29
+ ActiveRecord::SchemaMigration
30
+ ).migrate
28
31
  else
29
- ActiveRecord::Migrator.migrate(path)
32
+ ActiveRecord::MigrationContext.new(path).migrate
30
33
  end
31
34
  end
32
35
  end
@@ -36,11 +39,11 @@ module Backend
36
39
  require 'mongoid'
37
40
  require 'devise/orm/mongoid'
38
41
  require 'rails_app_mongoid/config/environment'
39
- require 'database_cleaner'
42
+ require 'database_cleaner-mongoid'
40
43
  end
41
44
 
42
45
  def setup_database_cleaner
43
- DatabaseCleaner[:mongoid].strategy = :truncation
46
+ DatabaseCleaner.allow_remote_database_url = true
44
47
  end
45
48
 
46
49
  def migrate!
@@ -9,7 +9,5 @@ class FakeRequest
9
9
  self.headers = headers
10
10
  end
11
11
 
12
- attr_accessor :remote_ip
13
- attr_accessor :user_agent
14
- attr_accessor :headers
12
+ attr_accessor :remote_ip, :user_agent, :headers
15
13
  end
data/spec/tiddle_spec.rb CHANGED
@@ -38,6 +38,11 @@ describe Tiddle do
38
38
  FakeRequest.new(user_agent: "Internet Explorer 4.0")
39
39
  expect(@user.authentication_tokens.last.user_agent).to eq "Internet Explorer 4.0"
40
40
  end
41
+
42
+ it "saves additional metadata" do
43
+ Tiddle.create_and_return_token @user, FakeRequest.new, metadata: { metadata_attr1: "abc" }
44
+ expect(@user.authentication_tokens.last.metadata_attr1).to eq "abc"
45
+ end
41
46
  end
42
47
 
43
48
  describe "find_token" do
data/tiddle.gemspec CHANGED
@@ -16,17 +16,15 @@ 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 = '>= 2.3.0'
19
+ spec.required_ruby_version = '>= 2.6.0'
20
20
 
21
- spec.add_dependency "devise", ">= 4.0.0.rc1", "< 4.6"
22
- spec.add_dependency "activerecord", ">= 4.2.0"
23
- spec.add_development_dependency "bundler", "~> 1.7"
24
- spec.add_development_dependency "rake", "~> 12.0"
21
+ spec.add_dependency "devise", ">= 4.0.0.rc1", "< 5"
22
+ spec.add_dependency "activerecord", ">= 5.2.0"
23
+ spec.add_development_dependency "rake"
25
24
  spec.add_development_dependency "rspec-rails"
26
25
  spec.add_development_dependency "appraisal"
27
- spec.add_development_dependency "sqlite3"
28
- spec.add_development_dependency "coveralls"
29
26
  spec.add_development_dependency "simplecov"
30
27
  spec.add_development_dependency "rubocop"
31
- spec.add_development_dependency "database_cleaner"
28
+ spec.add_development_dependency "database_cleaner-active_record"
29
+ spec.add_development_dependency "database_cleaner-mongoid"
32
30
  end
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.3.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Niedzielski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-24 00:00:00.000000000 Z
11
+ date: 2021-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 4.0.0.rc1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4.6'
22
+ version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,51 +29,23 @@ dependencies:
29
29
  version: 4.0.0.rc1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4.6'
32
+ version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activerecord
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 4.2.0
39
+ version: 5.2.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: 4.2.0
47
- - !ruby/object:Gem::Dependency
48
- name: bundler
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '1.7'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '1.7'
46
+ version: 5.2.0
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: rake
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '12.0'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '12.0'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec-rails
77
49
  requirement: !ruby/object:Gem::Requirement
78
50
  requirements:
79
51
  - - ">="
@@ -87,7 +59,7 @@ dependencies:
87
59
  - !ruby/object:Gem::Version
88
60
  version: '0'
89
61
  - !ruby/object:Gem::Dependency
90
- name: appraisal
62
+ name: rspec-rails
91
63
  requirement: !ruby/object:Gem::Requirement
92
64
  requirements:
93
65
  - - ">="
@@ -101,7 +73,7 @@ dependencies:
101
73
  - !ruby/object:Gem::Version
102
74
  version: '0'
103
75
  - !ruby/object:Gem::Dependency
104
- name: sqlite3
76
+ name: appraisal
105
77
  requirement: !ruby/object:Gem::Requirement
106
78
  requirements:
107
79
  - - ">="
@@ -115,7 +87,7 @@ dependencies:
115
87
  - !ruby/object:Gem::Version
116
88
  version: '0'
117
89
  - !ruby/object:Gem::Dependency
118
- name: coveralls
90
+ name: simplecov
119
91
  requirement: !ruby/object:Gem::Requirement
120
92
  requirements:
121
93
  - - ">="
@@ -129,7 +101,7 @@ dependencies:
129
101
  - !ruby/object:Gem::Version
130
102
  version: '0'
131
103
  - !ruby/object:Gem::Dependency
132
- name: simplecov
104
+ name: rubocop
133
105
  requirement: !ruby/object:Gem::Requirement
134
106
  requirements:
135
107
  - - ">="
@@ -143,7 +115,7 @@ dependencies:
143
115
  - !ruby/object:Gem::Version
144
116
  version: '0'
145
117
  - !ruby/object:Gem::Dependency
146
- name: rubocop
118
+ name: database_cleaner-active_record
147
119
  requirement: !ruby/object:Gem::Requirement
148
120
  requirements:
149
121
  - - ">="
@@ -157,7 +129,7 @@ dependencies:
157
129
  - !ruby/object:Gem::Version
158
130
  version: '0'
159
131
  - !ruby/object:Gem::Dependency
160
- name: database_cleaner
132
+ name: database_cleaner-mongoid
161
133
  requirement: !ruby/object:Gem::Requirement
162
134
  requirements:
163
135
  - - ">="
@@ -177,10 +149,10 @@ executables: []
177
149
  extensions: []
178
150
  extra_rdoc_files: []
179
151
  files:
152
+ - ".github/workflows/ruby.yml"
180
153
  - ".gitignore"
181
154
  - ".rspec"
182
155
  - ".rubocop.yml"
183
- - ".travis.yml"
184
156
  - Appraisals
185
157
  - CHANGELOG.md
186
158
  - CONTRIBUTING.md
@@ -189,10 +161,9 @@ files:
189
161
  - README.md
190
162
  - Rakefile
191
163
  - config/locales/en.yml
192
- - gemfiles/rails4.2.gemfile
193
- - gemfiles/rails5.0.gemfile
194
- - gemfiles/rails5.1.gemfile
195
164
  - gemfiles/rails5.2.gemfile
165
+ - gemfiles/rails6.0.gemfile
166
+ - gemfiles/rails6.1.gemfile
196
167
  - lib/tiddle.rb
197
168
  - lib/tiddle/model.rb
198
169
  - lib/tiddle/model_name.rb
@@ -228,7 +199,6 @@ files:
228
199
  - spec/strategy_spec.rb
229
200
  - spec/support/backend.rb
230
201
  - spec/support/fake_request.rb
231
- - spec/support/warningless_get.rb
232
202
  - spec/tiddle_spec.rb
233
203
  - tiddle.gemspec
234
204
  homepage: ''
@@ -243,15 +213,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
243
213
  requirements:
244
214
  - - ">="
245
215
  - !ruby/object:Gem::Version
246
- version: 2.3.0
216
+ version: 2.6.0
247
217
  required_rubygems_version: !ruby/object:Gem::Requirement
248
218
  requirements:
249
219
  - - ">="
250
220
  - !ruby/object:Gem::Version
251
221
  version: '0'
252
222
  requirements: []
253
- rubyforge_project:
254
- rubygems_version: 2.7.3
223
+ rubygems_version: 3.1.2
255
224
  signing_key:
256
225
  specification_version: 4
257
226
  summary: Token authentication for Devise which supports multiple tokens per model
@@ -284,5 +253,4 @@ test_files:
284
253
  - spec/strategy_spec.rb
285
254
  - spec/support/backend.rb
286
255
  - spec/support/fake_request.rb
287
- - spec/support/warningless_get.rb
288
256
  - spec/tiddle_spec.rb
data/.travis.yml DELETED
@@ -1,16 +0,0 @@
1
- language: ruby
2
- before_install: gem update --system
3
- services:
4
- - mongodb
5
- rvm:
6
- - "2.3.5"
7
- - "2.4.2"
8
- - "2.5.0"
9
- gemfile:
10
- - "gemfiles/rails4.2.gemfile"
11
- - "gemfiles/rails5.0.gemfile"
12
- - "gemfiles/rails5.1.gemfile"
13
- - "gemfiles/rails5.2.gemfile"
14
- env:
15
- - BACKEND=mongoid
16
- - BACKEND=active_record
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rubocop", "~> 0.52.0"
6
- gem "rails", "~> 5.1.0"
7
- gem "mongoid", "~> 6"
8
-
9
- gemspec path: "../"
@@ -1,7 +0,0 @@
1
- def warningless_get(path, headers:)
2
- if Gem::Requirement.new(">= 5") =~ Rails.gem_version
3
- get path, headers: headers
4
- else
5
- get path, {}, headers
6
- end
7
- end