tiddle 1.7.0 → 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d20d30a11350b4ee5ffe3a9c6ba9640afa90c13ddf87dac2c9bf6d4160339627
4
- data.tar.gz: fcd8811ba7c94de4accbf4a7920e6903f780707d5af858c7e9a153691ec53351
3
+ metadata.gz: a348d248985933eddf79f194679aa3c1ee6724006f3386a88d143efff7080b0d
4
+ data.tar.gz: 36f11c54b9cb1829fbbe07e200f404bb8958265582854dd71583a4f90565ef4b
5
5
  SHA512:
6
- metadata.gz: baf2289d634255233c6efe5c2988789a63ca05bdf1c278be92d500e50a5009e6875b29ef15c7e1cbb9bd03f131349bcf11757938f166a329389fa3cc720a7399
7
- data.tar.gz: b972e36c75bb0b1c3bc5f21ef9977d5d9f93e595dfaef6905bd59f458079b9b4f7fb6e5068e35fd6b1aaa6e4e63740c62609db68c89bb87a0353bddf1c702721
6
+ metadata.gz: b2001e1d59b7fe3596dd7727477e3315f7bc91d4725653ace774bdce0804dd11dceded3908d8be15bf05f8bbcb30e29b90ea8e99366069e693e2eb1ed7526960
7
+ data.tar.gz: 34064918737c1c9d1da935488fee01b711823cedc9c5b7ccfd411b30a94390b241ca7a9f6106ecb8c9acb7a6847a475ad2f9930a431d39417a495e7a9a4df812
@@ -15,16 +15,23 @@ jobs:
15
15
  - rails5.2
16
16
  - rails6.0
17
17
  - rails6.1
18
+ - rails7.0
18
19
  ruby:
19
- - 2.6
20
- - 2.7
21
- - 3.0
20
+ - "2.7"
21
+ - "3.0"
22
+ - "3.1"
22
23
  backend:
23
24
  - active_record
24
25
  - mongoid
25
26
  exclude:
26
27
  - gemfile: rails5.2
27
- ruby: 3.0
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"
28
35
  name: ${{ matrix.gemfile }}, ruby ${{ matrix.ruby }}, ${{ matrix.backend }}
29
36
  runs-on: ubuntu-latest
30
37
  env:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ### 1.7.1
2
+
3
+ Fix invalid headers generated when model is namespaced (Ariel Agne da Silveira)
4
+
5
+ Add Rails 7.0 support
6
+
7
+ Add Ruby 3.1 support
8
+
9
+ Remove Ruby 2.6 support
10
+
1
11
  ### 1.7.0
2
12
 
3
13
  Add ability to track additional info in tokens (Marcelo Silveira)
data/CONTRIBUTING.md CHANGED
@@ -4,8 +4,7 @@
4
4
  2. Run the tests:
5
5
 
6
6
  ```
7
- appraisal install
8
- rake
7
+ BUNDLE_GEMFILE=gemfiles/<PICK YOUR FAVOURITE>.gemfile rake
9
8
  ```
10
9
  3. Introduce your change. If it's a new feature then write a test for it as well.
11
10
  4. Make sure that tests are passing.
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Tiddle
2
2
 
3
- [![Code Climate](https://codeclimate.com/github/adamniedzielski/tiddle/badges/gpa.svg)](https://codeclimate.com/github/adamniedzielski/tiddle)
4
-
5
3
  Tiddle provides Devise strategy for token authentication in API-only Ruby on Rails applications. Its main feature is **support for multiple tokens per user**.
6
4
 
7
5
  Tiddle is lightweight and non-configurable. It does what it has to do and leaves some manual implementation to you.
@@ -83,7 +81,7 @@ end
83
81
 
84
82
  5) Send ```X-USER-EMAIL``` and ```X-USER-TOKEN``` as headers of every request which requires authentication.
85
83
 
86
- You can read more in a blog post dedicated to Tiddle - http://adamniedzielski.github.io/blog/2015/04/04/token-authentication-with-tiddle/
84
+ You can read more in a blog post dedicated to Tiddle - https://blog.sundaycoding.com/blog/2015/04/04/token-authentication-with-tiddle/
87
85
 
88
86
  ## Note on Rails session
89
87
 
@@ -93,7 +91,7 @@ The safest solution in API-only application is not to rely on Rails session at a
93
91
  config.middleware.delete ActionDispatch::Session::CookieStore
94
92
  ```
95
93
 
96
- More: http://adamniedzielski.github.io/blog/2015/04/04/token-authentication-with-tiddle/#rails-session
94
+ More: https://blog.sundaycoding.com/blog/2015/04/04/token-authentication-with-tiddle/#rails-session
97
95
 
98
96
  ## Using field other than email
99
97
 
data/Rakefile CHANGED
@@ -1,13 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require 'rspec/core/rake_task'
3
3
  require 'rubocop/rake_task'
4
- require 'appraisal'
5
4
 
6
5
  RSpec::Core::RakeTask.new(spec: :rubocop)
7
6
  RuboCop::RakeTask.new(:rubocop)
8
7
 
9
- if !ENV["APPRAISAL_INITIALIZED"]
10
- task default: :appraisal
11
- else
12
- task default: :spec
13
- end
8
+ task default: :spec
@@ -1,5 +1,3 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
3
  gem "rails", "~> 5.2.1"
@@ -1,5 +1,3 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
3
  gem "rails", "~> 6.0.0"
@@ -1,5 +1,3 @@
1
- # This file was generated by Appraisal
2
-
3
1
  source "https://rubygems.org"
4
2
 
5
3
  gem "rails", "~> 6.1.0"
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rails", "~> 7.0.2"
4
+ gem "mongoid"
5
+ gem "sqlite3"
6
+
7
+ gemspec path: "../"
@@ -1,11 +1,17 @@
1
1
  module Tiddle
2
2
  class ModelName
3
3
  def with_underscores(model)
4
- model.model_name.to_s.underscore.upcase
4
+ colon_to_underscore(model).underscore.upcase
5
5
  end
6
6
 
7
7
  def with_dashes(model)
8
8
  with_underscores(model).dasherize
9
9
  end
10
+
11
+ private
12
+
13
+ def colon_to_underscore(model)
14
+ model.model_name.to_s.tr(':', '_')
15
+ end
10
16
  end
11
17
  end
@@ -1,3 +1,3 @@
1
1
  module Tiddle
2
- VERSION = "1.7.0".freeze
2
+ VERSION = "1.7.1".freeze
3
3
  end
@@ -0,0 +1,7 @@
1
+ class NamespacedUsersController < ApplicationController
2
+ before_action :authenticate_namespaced_user!
3
+
4
+ def index
5
+ head :ok
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Namespace
2
+ class NamespacedUser < ActiveRecord::Base
3
+ devise :database_authenticatable, :registerable,
4
+ :recoverable, :trackable, :validatable,
5
+ :token_authenticatable
6
+
7
+ has_many :authentication_tokens, as: :authenticatable
8
+ end
9
+ end
@@ -4,6 +4,7 @@ require "active_model/railtie"
4
4
  require "active_record/railtie"
5
5
  require "action_controller/railtie"
6
6
  require "action_view/railtie"
7
+ require "action_mailer/railtie"
7
8
 
8
9
  module RailsApp
9
10
  class Application < Rails::Application
@@ -1,6 +1,8 @@
1
1
  Rails.application.routes.draw do
2
2
  devise_for :users
3
3
  devise_for :admin_users
4
+ devise_for :namespaced_user, class_name: 'Namespace::NamespacedUser'
4
5
  resources :secrets, only: [:index], defaults: { format: 'json' }
5
6
  resources :long_secrets, only: [:index], defaults: { format: 'json' }
7
+ resources :namespaced_users, only: [:index], defaults: { format: 'json' }
6
8
  end
@@ -59,6 +59,27 @@ class CreateTables < ActiveRecord::Migration[4.2]
59
59
 
60
60
  t.timestamps null: false
61
61
  end
62
+
63
+ create_table(:namespaced_users) do |t|
64
+ ## Database authenticatable
65
+ t.string :email, null: false, default: ""
66
+ t.string :encrypted_password, null: false, default: ""
67
+
68
+ ## Recoverable
69
+ t.string :reset_password_token
70
+ t.datetime :reset_password_sent_at
71
+
72
+ ## Trackable
73
+ t.integer :sign_in_count, default: 0, null: false
74
+ t.datetime :current_sign_in_at
75
+ t.datetime :last_sign_in_at
76
+ t.string :current_sign_in_ip
77
+ t.string :last_sign_in_ip
78
+
79
+ t.string :nick_name
80
+
81
+ t.timestamps null: false
82
+ end
62
83
  end
63
84
  # rubocop:enable Metrics/AbcSize
64
85
  # rubocop:enable Metrics/MethodLength
@@ -0,0 +1,7 @@
1
+ class NamespacedUsersController < ApplicationController
2
+ before_action :authenticate_namespaced_user!
3
+
4
+ def index
5
+ head :ok
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Namespace
2
+ class NamespacedUser < User
3
+ end
4
+ end
@@ -1,6 +1,8 @@
1
1
  Rails.application.routes.draw do
2
2
  devise_for :users
3
3
  devise_for :admin_users
4
+ devise_for :namespaced_user, class_name: 'Namespace::NamespacedUser'
4
5
  resources :secrets, only: [:index], defaults: { format: 'json' }
5
6
  resources :long_secrets, only: [:index], defaults: { format: 'json' }
7
+ resources :namespaced_users, only: [:index], defaults: { format: 'json' }
6
8
  end
@@ -130,6 +130,27 @@ describe "Authentication using Tiddle strategy", type: :request do
130
130
  end
131
131
  end
132
132
 
133
+ context "when the model name is composed of a namespace" do
134
+ before do
135
+ @user = Namespace::NamespacedUser.create!(
136
+ email: "test@example.com",
137
+ password: "12345678"
138
+ )
139
+ @token = Tiddle.create_and_return_token(@user, FakeRequest.new)
140
+ end
141
+
142
+ it "allows to access endpoints which require authentication" do
143
+ get(
144
+ namespaced_users_path,
145
+ headers: {
146
+ "X-NAMESPACE--NAMESPACED-USER-EMAIL" => "test@example.com",
147
+ "X-NAMESPACE--NAMESPACED-USER-TOKEN" => @token
148
+ }
149
+ )
150
+ expect(response.status).to eq 200
151
+ end
152
+ end
153
+
133
154
  describe "using field other than email" do
134
155
  before do
135
156
  Devise.setup do |config|
data/tiddle.gemspec CHANGED
@@ -16,13 +16,12 @@ 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.6.0'
19
+ spec.required_ruby_version = '>= 2.7.0'
20
20
 
21
21
  spec.add_dependency "devise", ">= 4.0.0.rc1", "< 5"
22
22
  spec.add_dependency "activerecord", ">= 5.2.0"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rspec-rails"
25
- spec.add_development_dependency "appraisal"
26
25
  spec.add_development_dependency "simplecov"
27
26
  spec.add_development_dependency "rubocop"
28
27
  spec.add_development_dependency "database_cleaner-active_record"
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.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Niedzielski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2022-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -72,20 +72,6 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: appraisal
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
75
  - !ruby/object:Gem::Dependency
90
76
  name: simplecov
91
77
  requirement: !ruby/object:Gem::Requirement
@@ -153,10 +139,8 @@ files:
153
139
  - ".gitignore"
154
140
  - ".rspec"
155
141
  - ".rubocop.yml"
156
- - Appraisals
157
142
  - CHANGELOG.md
158
143
  - CONTRIBUTING.md
159
- - Gemfile
160
144
  - LICENSE.txt
161
145
  - README.md
162
146
  - Rakefile
@@ -164,6 +148,7 @@ files:
164
148
  - gemfiles/rails5.2.gemfile
165
149
  - gemfiles/rails6.0.gemfile
166
150
  - gemfiles/rails6.1.gemfile
151
+ - gemfiles/rails7.0.gemfile
167
152
  - lib/tiddle.rb
168
153
  - lib/tiddle/model.rb
169
154
  - lib/tiddle/model_name.rb
@@ -173,9 +158,11 @@ files:
173
158
  - lib/tiddle/version.rb
174
159
  - spec/rails_app_active_record/app/controllers/application_controller.rb
175
160
  - spec/rails_app_active_record/app/controllers/long_secrets_controller.rb
161
+ - spec/rails_app_active_record/app/controllers/namespaced_users_controller.rb
176
162
  - spec/rails_app_active_record/app/controllers/secrets_controller.rb
177
163
  - spec/rails_app_active_record/app/models/admin_user.rb
178
164
  - spec/rails_app_active_record/app/models/authentication_token.rb
165
+ - spec/rails_app_active_record/app/models/namespace/namespaced_user.rb
179
166
  - spec/rails_app_active_record/app/models/user.rb
180
167
  - spec/rails_app_active_record/config/application.rb
181
168
  - spec/rails_app_active_record/config/boot.rb
@@ -185,9 +172,11 @@ files:
185
172
  - spec/rails_app_active_record/db/migrate/20150217000000_create_tables.rb
186
173
  - spec/rails_app_mongoid/app/controllers/application_controller.rb
187
174
  - spec/rails_app_mongoid/app/controllers/long_secrets_controller.rb
175
+ - spec/rails_app_mongoid/app/controllers/namespaced_users_controller.rb
188
176
  - spec/rails_app_mongoid/app/controllers/secrets_controller.rb
189
177
  - spec/rails_app_mongoid/app/models/admin_user.rb
190
178
  - spec/rails_app_mongoid/app/models/authentication_token.rb
179
+ - spec/rails_app_mongoid/app/models/namespace/namespaced_user.rb
191
180
  - spec/rails_app_mongoid/app/models/user.rb
192
181
  - spec/rails_app_mongoid/config/application.rb
193
182
  - spec/rails_app_mongoid/config/boot.rb
@@ -213,23 +202,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
202
  requirements:
214
203
  - - ">="
215
204
  - !ruby/object:Gem::Version
216
- version: 2.6.0
205
+ version: 2.7.0
217
206
  required_rubygems_version: !ruby/object:Gem::Requirement
218
207
  requirements:
219
208
  - - ">="
220
209
  - !ruby/object:Gem::Version
221
210
  version: '0'
222
211
  requirements: []
223
- rubygems_version: 3.1.2
212
+ rubygems_version: 3.1.6
224
213
  signing_key:
225
214
  specification_version: 4
226
215
  summary: Token authentication for Devise which supports multiple tokens per model
227
216
  test_files:
228
217
  - spec/rails_app_active_record/app/controllers/application_controller.rb
229
218
  - spec/rails_app_active_record/app/controllers/long_secrets_controller.rb
219
+ - spec/rails_app_active_record/app/controllers/namespaced_users_controller.rb
230
220
  - spec/rails_app_active_record/app/controllers/secrets_controller.rb
231
221
  - spec/rails_app_active_record/app/models/admin_user.rb
232
222
  - spec/rails_app_active_record/app/models/authentication_token.rb
223
+ - spec/rails_app_active_record/app/models/namespace/namespaced_user.rb
233
224
  - spec/rails_app_active_record/app/models/user.rb
234
225
  - spec/rails_app_active_record/config/application.rb
235
226
  - spec/rails_app_active_record/config/boot.rb
@@ -239,9 +230,11 @@ test_files:
239
230
  - spec/rails_app_active_record/db/migrate/20150217000000_create_tables.rb
240
231
  - spec/rails_app_mongoid/app/controllers/application_controller.rb
241
232
  - spec/rails_app_mongoid/app/controllers/long_secrets_controller.rb
233
+ - spec/rails_app_mongoid/app/controllers/namespaced_users_controller.rb
242
234
  - spec/rails_app_mongoid/app/controllers/secrets_controller.rb
243
235
  - spec/rails_app_mongoid/app/models/admin_user.rb
244
236
  - spec/rails_app_mongoid/app/models/authentication_token.rb
237
+ - spec/rails_app_mongoid/app/models/namespace/namespaced_user.rb
245
238
  - spec/rails_app_mongoid/app/models/user.rb
246
239
  - spec/rails_app_mongoid/config/application.rb
247
240
  - spec/rails_app_mongoid/config/boot.rb
data/Appraisals DELETED
@@ -1,17 +0,0 @@
1
- appraise "rails5.2" do
2
- gem "rails", "~> 5.2.1"
3
- gem "mongoid", "~> 6"
4
- gem "sqlite3", "~> 1.3.13"
5
- end
6
-
7
- appraise "rails6.0" do
8
- gem "rails", "~> 6.0.0"
9
- gem "mongoid", "~> 7"
10
- gem "sqlite3"
11
- end
12
-
13
- appraise "rails6.1" do
14
- gem "rails", "~> 6.1.0"
15
- gem "mongoid"
16
- gem "sqlite3"
17
- end
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in tiddle.gemspec
4
- gemspec