solidus_jwt 1.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gem_release.yml +1 -1
  3. data/.rubocop.yml +0 -17
  4. data/CHANGELOG.md +98 -0
  5. data/Gemfile +9 -1
  6. data/README.md +13 -0
  7. data/app/decorators/{solidus_jwt → controllers/solidus_jwt}/spree/api/base_controller_decorator.rb +3 -1
  8. data/app/decorators/{solidus_jwt → models/solidus_jwt}/spree/user_decorator.rb +22 -0
  9. data/app/models/solidus_jwt/base_record.rb +2 -0
  10. data/app/models/solidus_jwt/token.rb +2 -0
  11. data/bin/r +9 -0
  12. data/bin/rails +4 -14
  13. data/bin/rails-engine +15 -0
  14. data/bin/rails-sandbox +17 -0
  15. data/bin/rake +7 -0
  16. data/bin/sandbox +4 -1
  17. data/bin/sandbox_rails +9 -0
  18. data/config/routes.rb +2 -0
  19. data/db/migrate/20190222220038_create_solidus_jwt_tokens.rb +2 -0
  20. data/db/migrate/20191212083655_add_foreign_key_to_users_table.rb +2 -0
  21. data/{app/controllers → lib/controllers/api}/spree/api/oauths_controller.rb +2 -0
  22. data/lib/generators/solidus_jwt/install/install_generator.rb +2 -0
  23. data/lib/solidus_jwt/concerns/decodeable.rb +2 -0
  24. data/lib/solidus_jwt/concerns/encodeable.rb +2 -0
  25. data/lib/solidus_jwt/config.rb +2 -0
  26. data/lib/solidus_jwt/devise_strategies/base.rb +2 -0
  27. data/lib/solidus_jwt/devise_strategies/password.rb +2 -0
  28. data/lib/solidus_jwt/devise_strategies/refresh_token.rb +2 -0
  29. data/lib/solidus_jwt/distributor/devise.rb +2 -0
  30. data/lib/solidus_jwt/engine.rb +3 -1
  31. data/lib/solidus_jwt/factories.rb +2 -0
  32. data/lib/solidus_jwt/preferences.rb +2 -0
  33. data/lib/solidus_jwt/version.rb +3 -1
  34. data/lib/solidus_jwt.rb +2 -0
  35. data/solidus_jwt.gemspec +6 -4
  36. data/spec/lib/solidus_jwt/config_spec.rb +2 -0
  37. data/spec/lib/solidus_jwt/devise_strategies/password_spec.rb +2 -0
  38. data/spec/lib/solidus_jwt/devise_strategies/refresh_token_spec.rb +2 -0
  39. data/spec/lib/solidus_jwt/preferences_spec.rb +2 -0
  40. data/spec/lib/solidus_jwt_spec.rb +2 -0
  41. data/spec/models/solidus_jwt/token_spec.rb +2 -0
  42. data/spec/requests/spree/api/json_web_tokens_spec.rb +4 -2
  43. data/spec/requests/spree/api/oauths_spec.rb +2 -0
  44. data/spec/spec_helper.rb +2 -0
  45. data/spec/support/shared_examples/decodeable_examples.rb +2 -0
  46. data/spec/support/shared_examples/encodeable_examples.rb +2 -0
  47. metadata +26 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f3f9ec2c12488185b2ee9bff66409693f0d92ab52bde2adb67cc47df182a82a
4
- data.tar.gz: a77951e23f7d2352c5a2dde5a2742997f38bfb8e07ac31f1ae4f8be7b6bfc12c
3
+ metadata.gz: c4f62820292cb45a7c1e638d7c7f62006d379bb5c9bbad5efd840b8bc04ac574
4
+ data.tar.gz: ea71387db0d75e9fd22966968516a35c26dc870dbeaa420229ed6bc6cc1d9e90
5
5
  SHA512:
6
- metadata.gz: '058c6e5d8bcc54fa1b623b68ab46848f9e9ffb6feee2e97f048c1047ed6a5c11ce78990aef67b6432d051471e718c09ef00b30717b0419edd88d95cbf0ca8412'
7
- data.tar.gz: 95993510aecd67280bc85dc283798edae88d9c8388c1997190f8420d2ea4351d6e88273d7f5236449df52ff035e276725c924a5a835144c10dc458146bbe6bb3
6
+ metadata.gz: 334d6f0f28fc4c66f5d9f5b979f334ba8a56de9ec7fac0a41409cde8be3aa14e493d6309036768a00a9c15d712fcbced4a827511211772fc9c11a5696f033e26
7
+ data.tar.gz: 459344ffa6e482fa1dab6baf1e2dd3d5249d9e12572546c3263ed7f0d4447022648647e6e3568f4b1554538b4e2db657d446d833be7410353fda8b516fcf45f2
data/.gem_release.yml CHANGED
@@ -2,4 +2,4 @@ bump:
2
2
  recurse: false
3
3
  file: 'lib/solidus_jwt/version.rb'
4
4
  message: Bump SolidusJwt to %{version}
5
- branch: true
5
+ tag: true
data/.rubocop.yml CHANGED
@@ -6,26 +6,9 @@ AllCops:
6
6
  - sandbox/**/*
7
7
  - spec/dummy/**/*
8
8
 
9
- Style/FrozenStringLiteralComment:
10
- Enabled: false
11
-
12
- Naming/PredicateName:
13
- Exclude:
14
- - app/decorators/solidus_kits/spree/stock/availability_validator_decorator.rb
15
-
16
9
  Metrics/LineLength:
17
10
  Enabled: false
18
11
 
19
- Rails/SkipsModelValidations:
20
- Exclude:
21
- - 'spec/**/*'
22
-
23
- RSpec/BeforeAfterAll:
24
- Enabled: false
25
-
26
- RSpec/ContextWording:
27
- Enabled: false
28
-
29
12
  RSpec/MultipleExpectations:
30
13
  Enabled: false
31
14
 
data/CHANGELOG.md ADDED
@@ -0,0 +1,98 @@
1
+ # Changelog
2
+
3
+ ## [v1.2.1](https://github.com/solidusio-contrib/solidus_jwt/tree/v1.2.1) (2023-01-09)
4
+
5
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_jwt/compare/v1.2.0...v1.2.1)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Bump Solidus Version in Gemspec to Allow Above 3.0 [\#35](https://github.com/solidusio-contrib/solidus_jwt/pull/35) ([cpfergus1](https://github.com/cpfergus1))
10
+ - Update to use forked solidus\_frontend when needed [\#34](https://github.com/solidusio-contrib/solidus_jwt/pull/34) ([waiting-for-dev](https://github.com/waiting-for-dev))
11
+ - relaxing dependencies for working with solidus v3 [\#33](https://github.com/solidusio-contrib/solidus_jwt/pull/33) ([iLucker93](https://github.com/iLucker93))
12
+ - relaxing solidus\_core lower than v3 dependency [\#32](https://github.com/solidusio-contrib/solidus_jwt/pull/32) ([iLucker93](https://github.com/iLucker93))
13
+
14
+ ## [v1.2.0](https://github.com/solidusio-contrib/solidus_jwt/tree/v1.2.0) (2020-06-09)
15
+
16
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_jwt/compare/v1.0.0...v1.2.0)
17
+
18
+ **Closed issues:**
19
+
20
+ - Add helper method for matching user [\#25](https://github.com/solidusio-contrib/solidus_jwt/issues/25)
21
+ - Update for solidus\_dev\_support [\#22](https://github.com/solidusio-contrib/solidus_jwt/issues/22)
22
+ - Prefer Gem::Version [\#21](https://github.com/solidusio-contrib/solidus_jwt/issues/21)
23
+
24
+ **Merged pull requests:**
25
+
26
+ - Upgrade dev environment [\#28](https://github.com/solidusio-contrib/solidus_jwt/pull/28) ([skukx](https://github.com/skukx))
27
+ - Add for jwt user method [\#26](https://github.com/solidusio-contrib/solidus_jwt/pull/26) ([skukx](https://github.com/skukx))
28
+ - update solidus\_support to 0.5.0 [\#24](https://github.com/solidusio-contrib/solidus_jwt/pull/24) ([ccarruitero](https://github.com/ccarruitero))
29
+ - 22 update gem for solidus dev support [\#23](https://github.com/solidusio-contrib/solidus_jwt/pull/23) ([skukx](https://github.com/skukx))
30
+ - Handle other Warden strategy errors in API response [\#20](https://github.com/solidusio-contrib/solidus_jwt/pull/20) ([tvdeyen](https://github.com/tvdeyen))
31
+ - Change Devise strategy base class [\#19](https://github.com/solidusio-contrib/solidus_jwt/pull/19) ([tvdeyen](https://github.com/tvdeyen))
32
+ - Translate error response [\#18](https://github.com/solidusio-contrib/solidus_jwt/pull/18) ([tvdeyen](https://github.com/tvdeyen))
33
+ - Fix specs [\#17](https://github.com/solidusio-contrib/solidus_jwt/pull/17) ([tvdeyen](https://github.com/tvdeyen))
34
+ - Fix table\_name\_prefix [\#16](https://github.com/solidusio-contrib/solidus_jwt/pull/16) ([tvdeyen](https://github.com/tvdeyen))
35
+ - Fix Solidus dependencies [\#15](https://github.com/solidusio-contrib/solidus_jwt/pull/15) ([tvdeyen](https://github.com/tvdeyen))
36
+ - Add foreign key to users [\#14](https://github.com/solidusio-contrib/solidus_jwt/pull/14) ([tvdeyen](https://github.com/tvdeyen))
37
+ - Remove asset installation [\#13](https://github.com/solidusio-contrib/solidus_jwt/pull/13) ([tvdeyen](https://github.com/tvdeyen))
38
+
39
+ ## [v1.0.0](https://github.com/solidusio-contrib/solidus_jwt/tree/v1.0.0) (2019-12-09)
40
+
41
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_jwt/compare/v1.0.0.beta2...v1.0.0)
42
+
43
+ ## [v1.0.0.beta2](https://github.com/solidusio-contrib/solidus_jwt/tree/v1.0.0.beta2) (2019-12-04)
44
+
45
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_jwt/compare/v1.0.0.beta1...v1.0.0.beta2)
46
+
47
+ **Closed issues:**
48
+
49
+ - Allow authentication through API? [\#2](https://github.com/solidusio-contrib/solidus_jwt/issues/2)
50
+ - Add Refresh Token [\#1](https://github.com/solidusio-contrib/solidus_jwt/issues/1)
51
+
52
+ ## [v1.0.0.beta1](https://github.com/solidusio-contrib/solidus_jwt/tree/v1.0.0.beta1) (2019-11-01)
53
+
54
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_jwt/compare/v0.1.0...v1.0.0.beta1)
55
+
56
+ **Merged pull requests:**
57
+
58
+ - WIP: Implement Refresh Tokens [\#5](https://github.com/solidusio-contrib/solidus_jwt/pull/5) ([skukx](https://github.com/skukx))
59
+
60
+ ## [v0.1.0](https://github.com/solidusio-contrib/solidus_jwt/tree/v0.1.0) (2019-11-01)
61
+
62
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_jwt/compare/v0.0.2...v0.1.0)
63
+
64
+ **Closed issues:**
65
+
66
+ - JWT::InvalidPayload with jwt 2.2.1 [\#9](https://github.com/solidusio-contrib/solidus_jwt/issues/9)
67
+ - Prefer using sub claim over id [\#8](https://github.com/solidusio-contrib/solidus_jwt/issues/8)
68
+ - Allow claims to be passed through [\#4](https://github.com/solidusio-contrib/solidus_jwt/issues/4)
69
+
70
+ **Merged pull requests:**
71
+
72
+ - Update jwt claims [\#11](https://github.com/solidusio-contrib/solidus_jwt/pull/11) ([skukx](https://github.com/skukx))
73
+
74
+ ## [v0.0.2](https://github.com/solidusio-contrib/solidus_jwt/tree/v0.0.2) (2019-06-18)
75
+
76
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_jwt/compare/v0.0.1...v0.0.2)
77
+
78
+ **Closed issues:**
79
+
80
+ - SQLite3::ConstraintException: UNIQUE constraint failed: spree\_users.uid [\#3](https://github.com/solidusio-contrib/solidus_jwt/issues/3)
81
+
82
+ **Merged pull requests:**
83
+
84
+ - Fix bug with iat [\#10](https://github.com/solidusio-contrib/solidus_jwt/pull/10) ([skukx](https://github.com/skukx))
85
+ - Lock sqlite3 gem version [\#7](https://github.com/solidusio-contrib/solidus_jwt/pull/7) ([mdesantis](https://github.com/mdesantis))
86
+ - Calculate 'exp' and 'iat' upon the same timestamp [\#6](https://github.com/solidusio-contrib/solidus_jwt/pull/6) ([mdesantis](https://github.com/mdesantis))
87
+
88
+ ## [v0.0.1](https://github.com/solidusio-contrib/solidus_jwt/tree/v0.0.1) (2018-11-12)
89
+
90
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_jwt/compare/v0.0.1.pre...v0.0.1)
91
+
92
+ ## [v0.0.1.pre](https://github.com/solidusio-contrib/solidus_jwt/tree/v0.0.1.pre) (2018-10-27)
93
+
94
+ [Full Changelog](https://github.com/solidusio-contrib/solidus_jwt/compare/3e4c03b72d6259529a8cab3b0def7b338dc7b026...v0.0.1.pre)
95
+
96
+
97
+
98
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Gemfile CHANGED
@@ -1,8 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
5
 
4
6
  branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
5
- gem 'solidus', github: 'solidusio/solidus', branch: branch
7
+ solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
8
+ %w[solidusio/solidus solidusio/solidus_frontend]
9
+ else
10
+ %w[solidusio/solidus] * 2
11
+ end
12
+ gem 'solidus', github: solidus_git, branch: branch
13
+ gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
6
14
 
7
15
  # Needed to help Bundler figure out how to resolve dependencies,
8
16
  # otherwise it takes forever to resolve them.
data/README.md CHANGED
@@ -111,6 +111,19 @@ You can now use the `access_token` to authentication with the
111
111
  [Solidus API](https://github.com/solidusio/solidus/tree/master/api) in place
112
112
  of the `spree_api_key`.
113
113
 
114
+ #### Matching token to a user
115
+
116
+ By default, the token matches a user using the `Spree::User.for_jwt` method. This methods
117
+ Finds a user by id using the subject claim of the token. If you want to customize how the
118
+ subject claim is interpreted you can override this method
119
+
120
+ ```ruby
121
+ def self.for_jwt(sub)
122
+ # find_by(id: sub)
123
+ find_by(my_external_id: sub)
124
+ end
125
+ ```
126
+
114
127
  ### Obtain a refresh token
115
128
 
116
129
  To refresh your access token, instead of re-authenticating you can send
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  module Spree
3
5
  module Api
@@ -16,7 +18,7 @@ module SolidusJwt
16
18
  return super if json_web_token.blank?
17
19
 
18
20
  # rubocop:disable Naming/MemoizedInstanceVariableName
19
- @current_api_user ||= ::Spree.user_class.find_by(id: json_web_token['id'])
21
+ @current_api_user ||= ::Spree.user_class.for_jwt(json_web_token['sub'] || json_web_token['id'])
20
22
  # rubocop:enable Naming/MemoizedInstanceVariableName
21
23
  end
22
24
 
@@ -1,10 +1,32 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  module Spree
3
5
  module UserDecorator
4
6
  def self.prepended(base)
7
+ base.extend ClassMethods
5
8
  base.has_many :auth_tokens, class_name: 'SolidusJwt::Token'
6
9
  end
7
10
 
11
+ module ClassMethods
12
+ ##
13
+ # Find user based on subject claim in
14
+ # our json web token
15
+ # @see https://tools.ietf.org/html/rfc7519#section-4.1.2
16
+ #
17
+ # @example get user token
18
+ # payload = SolidusJwt.decode(token).first
19
+ # user = Spree::User.for_jwt(payload['sub'])
20
+ #
21
+ # @param sub [string] The subject claim of jwt
22
+ # @return [Spree.user_class, NilClass] If a match is found, returns the user,
23
+ # otherwise, returns nil
24
+ #
25
+ def for_jwt(sub)
26
+ find_by(id: sub)
27
+ end
28
+ end
29
+
8
30
  ##
9
31
  # Generate a json web token
10
32
  # @see https://github.com/jwt/ruby-jwt
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  base_class = defined?(::ApplicationRecord) ? ::ApplicationRecord : ActiveRecord::Base
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  class Token < BaseRecord
3
5
  attr_readonly :token
data/bin/r ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ warn %{
5
+ DEPRECATION: bin/r has been replaced by bin/rails-engine, please use that
6
+ command instead.
7
+ }.strip
8
+
9
+ exec "#{__dir__}/rails-engine"
data/bin/rails CHANGED
@@ -1,18 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  # frozen_string_literal: true
4
3
 
5
- app_root = 'sandbox'
6
-
7
- unless File.exist? "#{app_root}/bin/rails"
8
- warn 'Creating the sandbox app...'
9
- Dir.chdir "#{__dir__}/.." do
10
- system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
11
- warn 'Automatic creation of the sandbox app failed'
12
- exit 1
13
- end
14
- end
4
+ if %w[g generate].include? ARGV.first
5
+ exec "#{__dir__}/rails-engine", *ARGV
6
+ else
7
+ exec "#{__dir__}/rails-sandbox", *ARGV
15
8
  end
16
-
17
- Dir.chdir app_root
18
- exec 'bin/rails', *ARGV
data/bin/rails-engine ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # This command will automatically be run when you run "rails" with Rails gems
5
+ # installed from the root of your application.
6
+
7
+ ENGINE_ROOT = File.expand_path('..', __dir__)
8
+ ENGINE_PATH = File.expand_path('../lib/solidus_jwt/engine', __dir__)
9
+
10
+ # Set up gems listed in the Gemfile.
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
12
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
13
+
14
+ require 'rails/all'
15
+ require 'rails/engine/commands'
data/bin/rails-sandbox ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ app_root = 'sandbox'
5
+
6
+ unless File.exist? "#{app_root}/bin/rails"
7
+ warn 'Creating the sandbox app...'
8
+ Dir.chdir "#{__dir__}/.." do
9
+ system "#{__dir__}/sandbox" or begin # rubocop:disable Style/AndOr
10
+ warn 'Automatic creation of the sandbox app failed'
11
+ exit 1
12
+ end
13
+ end
14
+ end
15
+
16
+ Dir.chdir app_root
17
+ exec 'bin/rails', *ARGV
data/bin/rake ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "rubygems"
5
+ require "bundler/setup"
6
+
7
+ load Gem.bin_path("rake", "rake")
data/bin/sandbox CHANGED
@@ -53,7 +53,9 @@ gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
53
53
  gem 'solidus_auth_devise', '>= 2.1.0'
54
54
  gem 'rails-i18n'
55
55
  gem 'solidus_i18n'
56
+
56
57
  gem '$extension_name', path: '..'
58
+
57
59
  group :test, :development do
58
60
  platforms :mri do
59
61
  gem 'pry-byebug'
@@ -69,6 +71,7 @@ unbundled bundle exec rails generate spree:install \
69
71
  --auto-accept \
70
72
  --user_class=Spree::User \
71
73
  --enforce_available_locales=true \
74
+ --with-authentication=false \
72
75
  $@
73
76
 
74
77
  unbundled bundle exec rails generate solidus:auth:install
@@ -78,4 +81,4 @@ echo "🚀 Sandbox app successfully created for $extension_name!"
78
81
  echo "🚀 Using $RAILSDB and Solidus $BRANCH"
79
82
  echo "🚀 Use 'export DB=[postgres|mysql|sqlite]' to control the DB adapter"
80
83
  echo "🚀 Use 'export SOLIDUS_BRANCH=<BRANCH-NAME>' to control the Solidus version"
81
- echo "🚀 This app is intended for test purposes."
84
+ echo "🚀 This app is intended for test purposes."
data/bin/sandbox_rails ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ warn %{
5
+ DEPRECATION: bin/sandbox_rails has been replaced by bin/rails-sandbox, please
6
+ use that command instead.
7
+ }.strip
8
+
9
+ exec "#{__dir__}/rails-engine"
data/config/routes.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Spree::Core::Engine.routes.draw do
2
4
  # Add your extension routes here
3
5
  post 'oauth/token', to: 'api/oauths#token'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateSolidusJwtTokens < ActiveRecord::Migration[5.2]
2
4
  def change
3
5
  create_table :solidus_jwt_tokens do |t|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class AddForeignKeyToUsersTable < ActiveRecord::Migration[5.2]
2
4
  def change
3
5
  add_foreign_key :solidus_jwt_tokens, Spree.user_class.table_name, column: :user_id, on_delete: :cascade
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Spree
2
4
  module Api
3
5
  class OauthsController < BaseController
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  module Generators
3
5
  class InstallGenerator < Rails::Generators::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  module Decodeable
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  module Encodeable
3
5
  ##
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'solidus_jwt/preferences'
2
4
 
3
5
  SolidusJwt::Config = SolidusJwt::Preferences.new
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  module DeviseStrategies
3
5
  class Base < Devise::Strategies::Authenticatable
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  module DeviseStrategies
3
5
  class Password < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  module DeviseStrategies
3
5
  class RefreshToken < Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
4
  module Distributor
3
5
  module Devise
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spree/core'
2
4
 
3
5
  module SolidusJwt
4
6
  class Engine < Rails::Engine
5
- include SolidusSupport::EngineExtensions::Decorators
7
+ include SolidusSupport::EngineExtensions
6
8
 
7
9
  isolate_namespace ::Spree
8
10
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryBot.define do
2
4
  # Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spree/preferences/configuration'
2
4
 
3
5
  module SolidusJwt
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusJwt
2
- VERSION = '1.1.0'
4
+ VERSION = '1.2.1'
3
5
  end
data/lib/solidus_jwt.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'jwt'
2
4
 
3
5
  require 'solidus_core'
data/solidus_jwt.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/solidus_jwt/version'
2
4
 
3
5
  Gem::Specification.new do |s|
@@ -9,12 +11,12 @@ Gem::Specification.new do |s|
9
11
 
10
12
  s.author = 'Taylor Scott'
11
13
  s.email = 't.skukx@gmail.com'
12
- s.homepage = 'https://github.com/skukx/solidus_jwt'
14
+ s.homepage = 'https://github.com/solidusio-contrib/solidus_jwt'
13
15
 
14
16
  s.metadata['homepage_uri'] = s.homepage
15
17
  s.metadata['source_code_uri'] = s.homepage
16
18
 
17
- s.required_ruby_version = Gem::Requirement.new('~> 2.4')
19
+ s.required_ruby_version = Gem::Requirement.new
18
20
 
19
21
  # Specify which files should be added to the gem when it is released.
20
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -28,8 +30,8 @@ Gem::Specification.new do |s|
28
30
 
29
31
  s.add_dependency 'jwt'
30
32
  s.add_dependency 'solidus_auth_devise'
31
- s.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
32
- s.add_dependency 'solidus_support', '~> 0.4.0'
33
+ s.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
34
+ s.add_dependency 'solidus_support'
33
35
 
34
36
  s.add_development_dependency 'byebug'
35
37
  s.add_development_dependency 'solidus_dev_support'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe SolidusJwt::Config do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'spree/testing_support/factories/user_factory'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'spree/testing_support/factories/user_factory'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe SolidusJwt::Preferences do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe SolidusJwt do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe SolidusJwt::Token, type: :model do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'spree/testing_support/factories/user_factory'
3
5
 
@@ -46,11 +48,11 @@ RSpec.describe 'SolidusJwt Authentication', type: :request do
46
48
  end
47
49
 
48
50
  context 'when spree api key is not allowed' do
49
- before(:all) do
51
+ before do
50
52
  SolidusJwt::Config.allow_spree_api_key = false
51
53
  end
52
54
 
53
- after(:all) do
55
+ after do
54
56
  SolidusJwt::Config.allow_spree_api_key = true
55
57
  end
56
58
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'spree/testing_support/factories/user_factory'
3
5
 
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Configure Rails Environment
2
4
  ENV['RAILS_ENV'] = 'test'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'Decodeable Examples' do
2
4
  describe 'decode' do
3
5
  let(:token) do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'Encodeable Examples' do
2
4
  describe 'encode' do
3
5
  let(:payload) { { user_id: 1 } }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_jwt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Scott
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-16 00:00:00.000000000 Z
11
+ date: 2023-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jwt
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: 2.0.0
48
48
  - - "<"
49
49
  - !ruby/object:Gem::Version
50
- version: '3'
50
+ version: '4'
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,21 +57,21 @@ dependencies:
57
57
  version: 2.0.0
58
58
  - - "<"
59
59
  - !ruby/object:Gem::Version
60
- version: '3'
60
+ version: '4'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: solidus_support
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - "~>"
65
+ - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: 0.4.0
67
+ version: '0'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - "~>"
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
- version: 0.4.0
74
+ version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: byebug
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -115,24 +115,30 @@ files:
115
115
  - ".rubocop.yml"
116
116
  - ".ruby-gemset"
117
117
  - ".ruby-version"
118
+ - CHANGELOG.md
118
119
  - Gemfile
119
120
  - LICENSE
120
121
  - README.md
121
122
  - Rakefile
122
123
  - _config.yml
123
- - app/controllers/spree/api/oauths_controller.rb
124
- - app/decorators/solidus_jwt/spree/api/base_controller_decorator.rb
125
- - app/decorators/solidus_jwt/spree/user_decorator.rb
124
+ - app/decorators/controllers/solidus_jwt/spree/api/base_controller_decorator.rb
125
+ - app/decorators/models/solidus_jwt/spree/user_decorator.rb
126
126
  - app/models/solidus_jwt/base_record.rb
127
127
  - app/models/solidus_jwt/token.rb
128
128
  - bin/console
129
+ - bin/r
129
130
  - bin/rails
131
+ - bin/rails-engine
132
+ - bin/rails-sandbox
133
+ - bin/rake
130
134
  - bin/sandbox
135
+ - bin/sandbox_rails
131
136
  - bin/setup
132
137
  - config/locales/en.yml
133
138
  - config/routes.rb
134
139
  - db/migrate/20190222220038_create_solidus_jwt_tokens.rb
135
140
  - db/migrate/20191212083655_add_foreign_key_to_users_table.rb
141
+ - lib/controllers/api/spree/api/oauths_controller.rb
136
142
  - lib/generators/solidus_jwt/install/install_generator.rb
137
143
  - lib/solidus_jwt.rb
138
144
  - lib/solidus_jwt/concerns/decodeable.rb
@@ -160,29 +166,29 @@ files:
160
166
  - spec/spec_helper.rb
161
167
  - spec/support/shared_examples/decodeable_examples.rb
162
168
  - spec/support/shared_examples/encodeable_examples.rb
163
- homepage: https://github.com/skukx/solidus_jwt
169
+ homepage: https://github.com/solidusio-contrib/solidus_jwt
164
170
  licenses:
165
171
  - BSD-3-Clause
166
172
  metadata:
167
- homepage_uri: https://github.com/skukx/solidus_jwt
168
- source_code_uri: https://github.com/skukx/solidus_jwt
169
- post_install_message:
173
+ homepage_uri: https://github.com/solidusio-contrib/solidus_jwt
174
+ source_code_uri: https://github.com/solidusio-contrib/solidus_jwt
175
+ post_install_message:
170
176
  rdoc_options: []
171
177
  require_paths:
172
178
  - lib
173
179
  required_ruby_version: !ruby/object:Gem::Requirement
174
180
  requirements:
175
- - - "~>"
181
+ - - ">="
176
182
  - !ruby/object:Gem::Version
177
- version: '2.4'
183
+ version: '0'
178
184
  required_rubygems_version: !ruby/object:Gem::Requirement
179
185
  requirements:
180
186
  - - ">="
181
187
  - !ruby/object:Gem::Version
182
188
  version: '0'
183
189
  requirements: []
184
- rubygems_version: 3.0.8
185
- signing_key:
190
+ rubygems_version: 3.3.7
191
+ signing_key:
186
192
  specification_version: 4
187
193
  summary: Add Json Web Tokens to Solidus API
188
194
  test_files: