solidus_jwt 1.2.0 → 1.2.2
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/.circleci/config.yml +50 -12
- data/.gem_release.yml +1 -1
- data/.rubocop.yml +1 -12
- data/.ruby-version +1 -1
- data/CHANGELOG.md +3 -0
- data/Gemfile +3 -1
- data/OLD_CHANGELOG.md +98 -0
- data/README.md +1 -1
- data/Rakefile +2 -1
- data/bin/rails-sandbox +1 -1
- data/bin/sandbox +1 -1
- data/lib/generators/solidus_jwt/install/install_generator.rb +2 -1
- data/lib/solidus_jwt/concerns/encodeable.rb +2 -1
- data/lib/solidus_jwt/{factories.rb → testing_support/factories.rb} +2 -1
- data/lib/solidus_jwt/version.rb +1 -1
- data/solidus_jwt.gemspec +5 -4
- data/spec/lib/solidus_jwt/devise_strategies/password_spec.rb +3 -5
- data/spec/lib/solidus_jwt/devise_strategies/refresh_token_spec.rb +2 -5
- data/spec/models/solidus_jwt/token_spec.rb +5 -3
- data/spec/requests/spree/api/json_web_tokens_spec.rb +4 -3
- data/spec/requests/spree/api/oauths_spec.rb +38 -27
- data/spec/spec_helper.rb +6 -4
- data/spec/support/shared_examples/decodeable_examples.rb +6 -4
- data/spec/support/shared_examples/encodeable_examples.rb +10 -6
- metadata +21 -22
- data/spec/lib/solidus_jwt/concerns/decodeable_spec.rb +0 -0
- data/spec/lib/solidus_jwt/concerns/encodeable_spec.rb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6af9d598ef8f7e34ec1c8bd219e16cddb9cd55fae9f2e4192b2b037c6d0aa75c
|
|
4
|
+
data.tar.gz: ba3c51213c6469e50891cb8d47e0ee6e61e71ded0093f2be18db249e11be2f89
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 00a30974bb6b3e9f09e96835b5433fa44d5007257643aad387b4de50bbc17be4d7531ca38e4326f54fc3c0172108f62eb7f195735709e52cdb7eb827631d51af
|
|
7
|
+
data.tar.gz: 2a199b684fe99e7cc8c0ffe722ef3215f2afbcf2527d8c89db6e86c3ac8e5ed5ebcddc73d62dcc55c6d41f4a9f66818e5d0fabf619a42b4e74f88cadc4e8d9b4
|
data/.circleci/config.yml
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
|
|
3
3
|
orbs:
|
|
4
|
+
# Required for feature specs.
|
|
5
|
+
browser-tools: circleci/browser-tools@1.1
|
|
6
|
+
|
|
4
7
|
# Always take the latest version of the orb, this allows us to
|
|
5
8
|
# run specs against Solidus supported versions only without the need
|
|
6
9
|
# to change this configuration every time a Solidus version is released
|
|
@@ -8,28 +11,63 @@ orbs:
|
|
|
8
11
|
solidusio_extensions: solidusio/extensions@volatile
|
|
9
12
|
|
|
10
13
|
jobs:
|
|
11
|
-
run-specs
|
|
12
|
-
|
|
14
|
+
run-specs:
|
|
15
|
+
parameters:
|
|
16
|
+
solidus:
|
|
17
|
+
type: string
|
|
18
|
+
default: main
|
|
19
|
+
db:
|
|
20
|
+
type: string
|
|
21
|
+
default: "postgres"
|
|
22
|
+
ruby:
|
|
23
|
+
type: string
|
|
24
|
+
default: "3.2"
|
|
25
|
+
executor:
|
|
26
|
+
name: solidusio_extensions/<< parameters.db >>
|
|
27
|
+
ruby_version: << parameters.ruby >>
|
|
13
28
|
steps:
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
29
|
+
- checkout
|
|
30
|
+
- browser-tools/install-chrome
|
|
31
|
+
- solidusio_extensions/run-tests-solidus-<< parameters.solidus >>
|
|
32
|
+
|
|
33
|
+
lint-code:
|
|
34
|
+
executor:
|
|
35
|
+
name: solidusio_extensions/sqlite
|
|
36
|
+
ruby_version: "3.0"
|
|
17
37
|
steps:
|
|
18
|
-
- solidusio_extensions/
|
|
38
|
+
- solidusio_extensions/lint-code
|
|
19
39
|
|
|
20
40
|
workflows:
|
|
21
41
|
"Run specs on supported Solidus versions":
|
|
22
42
|
jobs:
|
|
23
|
-
- run-specs
|
|
24
|
-
|
|
25
|
-
|
|
43
|
+
- run-specs:
|
|
44
|
+
name: &name "run-specs-solidus-<< matrix.solidus >>-ruby-<< matrix.ruby >>-db-<< matrix.db >>"
|
|
45
|
+
matrix:
|
|
46
|
+
parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
|
|
47
|
+
- run-specs:
|
|
48
|
+
name: *name
|
|
49
|
+
matrix:
|
|
50
|
+
parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
|
|
51
|
+
- run-specs:
|
|
52
|
+
name: *name
|
|
53
|
+
matrix:
|
|
54
|
+
parameters: { solidus: ["older"], ruby: ["3.0"], db: ["sqlite"] }
|
|
55
|
+
- lint-code
|
|
56
|
+
|
|
57
|
+
"Weekly run specs against main":
|
|
26
58
|
triggers:
|
|
27
59
|
- schedule:
|
|
28
60
|
cron: "0 0 * * 4" # every Thursday
|
|
29
61
|
filters:
|
|
30
62
|
branches:
|
|
31
63
|
only:
|
|
32
|
-
-
|
|
64
|
+
- main
|
|
33
65
|
jobs:
|
|
34
|
-
- run-specs
|
|
35
|
-
|
|
66
|
+
- run-specs:
|
|
67
|
+
name: *name
|
|
68
|
+
matrix:
|
|
69
|
+
parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] }
|
|
70
|
+
- run-specs:
|
|
71
|
+
name: *name
|
|
72
|
+
matrix:
|
|
73
|
+
parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] }
|
data/.gem_release.yml
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -2,15 +2,4 @@ require:
|
|
|
2
2
|
- solidus_dev_support/rubocop
|
|
3
3
|
|
|
4
4
|
AllCops:
|
|
5
|
-
|
|
6
|
-
- sandbox/**/*
|
|
7
|
-
- spec/dummy/**/*
|
|
8
|
-
|
|
9
|
-
Metrics/LineLength:
|
|
10
|
-
Enabled: false
|
|
11
|
-
|
|
12
|
-
RSpec/MultipleExpectations:
|
|
13
|
-
Enabled: false
|
|
14
|
-
|
|
15
|
-
RSpec/NestedGroups:
|
|
16
|
-
Enabled: false
|
|
5
|
+
NewCops: disable
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3.1.2
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
source 'https://rubygems.org'
|
|
4
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
5
5
|
|
|
6
|
-
branch = ENV.fetch('SOLIDUS_BRANCH', '
|
|
6
|
+
branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
|
|
7
|
+
|
|
7
8
|
gem 'solidus', github: 'solidusio/solidus', branch: branch
|
|
9
|
+
gem 'solidus_frontend', github: 'solidusio/solidus_frontend', branch: branch > 'v3.4' ? 'v3.4' : branch
|
|
8
10
|
|
|
9
11
|
# Needed to help Bundler figure out how to resolve dependencies,
|
|
10
12
|
# otherwise it takes forever to resolve them.
|
data/OLD_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/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
SolidusJwt
|
|
2
2
|
==========
|
|
3
3
|
|
|
4
|
-
[](https://circleci.com/gh/solidusio-contrib/solidus_jwt)
|
|
5
5
|
[](https://badge.fury.io/rb/solidus_jwt)
|
|
6
6
|
|
|
7
7
|
This gem gives [Solidus](https://github.com/solidusio/solidus) stores the ability to authenticate API requests with
|
data/Rakefile
CHANGED
data/bin/rails-sandbox
CHANGED
|
@@ -6,7 +6,7 @@ app_root = 'sandbox'
|
|
|
6
6
|
unless File.exist? "#{app_root}/bin/rails"
|
|
7
7
|
warn 'Creating the sandbox app...'
|
|
8
8
|
Dir.chdir "#{__dir__}/.." do
|
|
9
|
-
system "#{__dir__}/sandbox" or begin
|
|
9
|
+
system "#{__dir__}/sandbox" or begin
|
|
10
10
|
warn 'Automatic creation of the sandbox app failed'
|
|
11
11
|
exit 1
|
|
12
12
|
end
|
data/bin/sandbox
CHANGED
|
@@ -10,7 +10,8 @@ module SolidusJwt
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def run_migrations
|
|
13
|
-
run_migrations = options[:auto_run_migrations] ||
|
|
13
|
+
run_migrations = options[:auto_run_migrations] ||
|
|
14
|
+
['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
|
|
14
15
|
if run_migrations
|
|
15
16
|
run 'bundle exec rake db:migrate'
|
|
16
17
|
else
|
|
@@ -14,7 +14,8 @@ module SolidusJwt
|
|
|
14
14
|
# }
|
|
15
15
|
#
|
|
16
16
|
# SolidusJwt.encode payload: payload
|
|
17
|
-
# #=> 'eyJhbGciOiJIUzI1NiJ9.
|
|
17
|
+
# #=> 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlhdCI6MTU4NDEzMjExOCwiZXhwIj
|
|
18
|
+
# oxNTg0MTM1NzE4LCJpc3MiOiJzb2xpZHVzIn0.OKZOGlawx435GdgKp2AGD8SKxW7sqn0h-Ef2qdVSxqQ'
|
|
18
19
|
#
|
|
19
20
|
# @param payload [Hash] Attributes to place within the jwt
|
|
20
21
|
# @param expires_in [Integer] How long until token expires in Seconds (*Optional*).
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
FactoryBot.define do
|
|
4
|
-
# Define your Spree extensions Factories within this file to enable applications,
|
|
4
|
+
# Define your Spree extensions Factories within this file to enable applications,
|
|
5
|
+
# and other extensions to use and override them.
|
|
5
6
|
#
|
|
6
7
|
# Example adding this to your spec_helper will load these Factories for use:
|
|
7
8
|
# require 'solidus_jwt/factories'
|
data/lib/solidus_jwt/version.rb
CHANGED
data/solidus_jwt.gemspec
CHANGED
|
@@ -11,12 +11,13 @@ Gem::Specification.new do |s|
|
|
|
11
11
|
|
|
12
12
|
s.author = 'Taylor Scott'
|
|
13
13
|
s.email = 't.skukx@gmail.com'
|
|
14
|
-
s.homepage = 'https://github.com/
|
|
14
|
+
s.homepage = 'https://github.com/solidusio-contrib/solidus_jwt'
|
|
15
15
|
|
|
16
16
|
s.metadata['homepage_uri'] = s.homepage
|
|
17
17
|
s.metadata['source_code_uri'] = s.homepage
|
|
18
|
+
s.metadata['changelog_uri'] = 'https://github.com/solidusio/solidus_jwt/releases'
|
|
18
19
|
|
|
19
|
-
s.required_ruby_version = Gem::Requirement.new('
|
|
20
|
+
s.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
|
20
21
|
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
@@ -30,8 +31,8 @@ Gem::Specification.new do |s|
|
|
|
30
31
|
|
|
31
32
|
s.add_dependency 'jwt'
|
|
32
33
|
s.add_dependency 'solidus_auth_devise'
|
|
33
|
-
s.add_dependency 'solidus_core', ['>= 2.0.0', '<
|
|
34
|
-
s.add_dependency 'solidus_support'
|
|
34
|
+
s.add_dependency 'solidus_core', ['>= 2.0.0', '< 5']
|
|
35
|
+
s.add_dependency 'solidus_support'
|
|
35
36
|
|
|
36
37
|
s.add_development_dependency 'byebug'
|
|
37
38
|
s.add_development_dependency 'solidus_dev_support'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
|
-
require 'spree/testing_support/factories/user_factory'
|
|
5
4
|
|
|
6
5
|
RSpec.describe SolidusJwt::DeviseStrategies::Password do
|
|
7
6
|
let(:request) { instance_double('ActionController::Request') }
|
|
@@ -10,14 +9,13 @@ RSpec.describe SolidusJwt::DeviseStrategies::Password do
|
|
|
10
9
|
let(:params) do
|
|
11
10
|
{
|
|
12
11
|
username: user.email,
|
|
13
|
-
password:
|
|
12
|
+
password: 'secret',
|
|
14
13
|
grant_type: 'password'
|
|
15
14
|
}
|
|
16
15
|
end
|
|
17
16
|
|
|
18
17
|
let(:headers) { {} }
|
|
19
|
-
let(:user) { FactoryBot.create(:user, password:
|
|
20
|
-
let(:password) { 'secret' }
|
|
18
|
+
let(:user) { FactoryBot.create(:user, password: 'secret') }
|
|
21
19
|
|
|
22
20
|
before do
|
|
23
21
|
allow(request).to receive(:headers).and_return(:headers)
|
|
@@ -60,7 +58,7 @@ RSpec.describe SolidusJwt::DeviseStrategies::Password do
|
|
|
60
58
|
{
|
|
61
59
|
username: user.email,
|
|
62
60
|
password: 'invalid',
|
|
63
|
-
grant_type:
|
|
61
|
+
grant_type: 'secret'
|
|
64
62
|
}
|
|
65
63
|
end
|
|
66
64
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
|
-
require 'spree/testing_support/factories/user_factory'
|
|
5
4
|
|
|
6
5
|
RSpec.describe SolidusJwt::DeviseStrategies::RefreshToken do
|
|
7
6
|
let(:request) { instance_double('ActionController::Request') }
|
|
@@ -14,13 +13,11 @@ RSpec.describe SolidusJwt::DeviseStrategies::RefreshToken do
|
|
|
14
13
|
}
|
|
15
14
|
end
|
|
16
15
|
|
|
17
|
-
let(:
|
|
18
|
-
let(:user) { FactoryBot.create(:user, password: password) }
|
|
19
|
-
let(:password) { 'secret' }
|
|
16
|
+
let(:user) { FactoryBot.create(:user, password: 'secret') }
|
|
20
17
|
let(:token) { user.auth_tokens.create! }
|
|
21
18
|
|
|
22
19
|
before do
|
|
23
|
-
allow(request).to receive(:headers).and_return(
|
|
20
|
+
allow(request).to receive(:headers).and_return({})
|
|
24
21
|
|
|
25
22
|
allow(strategy).to receive(:request).and_return(request)
|
|
26
23
|
allow(strategy).to receive(:params).and_return(params)
|
|
@@ -15,9 +15,11 @@ RSpec.describe SolidusJwt::Token, type: :model do
|
|
|
15
15
|
let(:instance) { FactoryBot.build(:token, token: nil) }
|
|
16
16
|
|
|
17
17
|
it 'generates one automatically' do
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
aggregate_failures do
|
|
19
|
+
expect(instance.token).to be_nil
|
|
20
|
+
instance.save
|
|
21
|
+
expect(instance.token).to be_present
|
|
22
|
+
end
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
|
-
require 'spree/testing_support/factories/user_factory'
|
|
5
4
|
|
|
6
5
|
RSpec.describe 'SolidusJwt Authentication', type: :request do
|
|
7
6
|
let(:params) do
|
|
@@ -22,8 +21,10 @@ RSpec.describe 'SolidusJwt Authentication', type: :request do
|
|
|
22
21
|
it 'renders invalid_api_key' do
|
|
23
22
|
get spree.api_user_path(user.id), params: params
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
aggregate_failures do
|
|
25
|
+
expect(response.status).to be(401)
|
|
26
|
+
expect(response.body).to include('Invalid API key')
|
|
27
|
+
end
|
|
27
28
|
end
|
|
28
29
|
end
|
|
29
30
|
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
|
-
require 'spree/testing_support/factories/user_factory'
|
|
5
4
|
|
|
6
5
|
RSpec.describe 'Token Retrieval', type: :request do
|
|
7
6
|
let(:user) { FactoryBot.create(:user, password: 'password') }
|
|
8
7
|
|
|
9
8
|
describe '/api/token' do
|
|
10
9
|
context 'when username and password are provided' do
|
|
11
|
-
context 'when success' do
|
|
10
|
+
context 'when success' do # rubocop:disable RSpec/NestedGroups
|
|
12
11
|
before do
|
|
13
12
|
post '/oauth/token', params: { username: user.email, password: 'password', grant_type: 'password' }
|
|
14
13
|
end
|
|
@@ -20,39 +19,45 @@ RSpec.describe 'Token Retrieval', type: :request do
|
|
|
20
19
|
it 'responds with access_token and refresh_token' do
|
|
21
20
|
json = JSON.parse(response.body)
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
aggregate_failures do
|
|
23
|
+
expect(json).to have_key('access_token')
|
|
24
|
+
expect(json).to have_key('refresh_token')
|
|
25
|
+
end
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
28
|
|
|
28
|
-
context 'when warden failure' do
|
|
29
|
+
context 'when warden failure' do # rubocop:disable RSpec/NestedGroups
|
|
29
30
|
def send_request
|
|
30
31
|
post '/oauth/token', params: { username: user.email, password: 'password', grant_type: 'password' }
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
it 'responds with status 401' do
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
aggregate_failures do
|
|
36
|
+
expect_any_instance_of(Spree::Api::OauthsController).to receive(:try_authenticate_user) do # rubocop:disable RSpec/AnyInstance
|
|
37
|
+
throw(:warden, scope: :spree_user, message: :locked)
|
|
38
|
+
end
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
send_request
|
|
41
|
+
expect(response).to have_http_status(:unauthorized)
|
|
42
|
+
end
|
|
40
43
|
end
|
|
41
44
|
|
|
42
45
|
it 'responds with translated Devise error message' do
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
aggregate_failures do
|
|
47
|
+
expect_any_instance_of(Spree::Api::OauthsController).to receive(:try_authenticate_user) do # rubocop:disable RSpec/AnyInstance
|
|
48
|
+
throw(:warden, scope: :spree_user, message: :locked)
|
|
49
|
+
end
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
send_request
|
|
52
|
+
json = JSON.parse(response.body)
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
expect(json).to have_key('error')
|
|
55
|
+
expect(json['error']).to eq('Your account is locked.')
|
|
56
|
+
end
|
|
52
57
|
end
|
|
53
58
|
end
|
|
54
59
|
|
|
55
|
-
context 'when invalid password' do
|
|
60
|
+
context 'when invalid password' do # rubocop:disable RSpec/NestedGroups
|
|
56
61
|
def send_request
|
|
57
62
|
post '/oauth/token', params: { username: user.email, password: 'invalid', grant_type: 'password' }
|
|
58
63
|
end
|
|
@@ -67,11 +72,13 @@ RSpec.describe 'Token Retrieval', type: :request do
|
|
|
67
72
|
|
|
68
73
|
json = JSON.parse(response.body)
|
|
69
74
|
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
aggregate_failures do
|
|
76
|
+
expect(json).to have_key('error')
|
|
77
|
+
expect(json['error']).to eq('invalid username or password')
|
|
78
|
+
end
|
|
72
79
|
end
|
|
73
80
|
|
|
74
|
-
context 'with error message translation' do
|
|
81
|
+
context 'with error message translation' do # rubocop:disable RSpec/NestedGroups
|
|
75
82
|
before do
|
|
76
83
|
allow(I18n).to receive(:t).with(:invalid_credentials, scope: 'solidus_jwt').and_return('Wrong token!')
|
|
77
84
|
end
|
|
@@ -81,8 +88,10 @@ RSpec.describe 'Token Retrieval', type: :request do
|
|
|
81
88
|
|
|
82
89
|
json = JSON.parse(response.body)
|
|
83
90
|
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
aggregate_failures do
|
|
92
|
+
expect(json).to have_key('error')
|
|
93
|
+
expect(json['error']).to eq('Wrong token!')
|
|
94
|
+
end
|
|
86
95
|
end
|
|
87
96
|
end
|
|
88
97
|
end
|
|
@@ -91,7 +100,7 @@ RSpec.describe 'Token Retrieval', type: :request do
|
|
|
91
100
|
context 'when refresh token provided' do
|
|
92
101
|
let(:refresh_token) { user.auth_tokens.create! }
|
|
93
102
|
|
|
94
|
-
context 'when success' do
|
|
103
|
+
context 'when success' do # rubocop:disable RSpec/NestedGroups
|
|
95
104
|
before do
|
|
96
105
|
post '/oauth/token', params: { refresh_token: refresh_token.token, grant_type: 'refresh_token' }
|
|
97
106
|
end
|
|
@@ -103,12 +112,14 @@ RSpec.describe 'Token Retrieval', type: :request do
|
|
|
103
112
|
it 'responds with access_token and refresh_token' do
|
|
104
113
|
json = JSON.parse(response.body)
|
|
105
114
|
|
|
106
|
-
|
|
107
|
-
|
|
115
|
+
aggregate_failures do
|
|
116
|
+
expect(json).to have_key('access_token')
|
|
117
|
+
expect(json).to have_key('refresh_token')
|
|
118
|
+
end
|
|
108
119
|
end
|
|
109
120
|
end
|
|
110
121
|
|
|
111
|
-
context 'when failure' do
|
|
122
|
+
context 'when failure' do # rubocop:disable RSpec/NestedGroups
|
|
112
123
|
before do
|
|
113
124
|
post '/oauth/token', params: { refresh_token: 'invalid', grant_type: 'refresh_token' }
|
|
114
125
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -8,17 +8,19 @@ require 'byebug'
|
|
|
8
8
|
# Run Coverage report
|
|
9
9
|
require 'solidus_dev_support/rspec/coverage'
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
dummy_env = "#{__dir__}/dummy/config/environment.rb"
|
|
12
|
+
system 'bin/rake extension:test_app' unless File.exist? dummy_env
|
|
13
|
+
require dummy_env
|
|
12
14
|
|
|
13
15
|
# Requires factories and other useful helpers defined in spree_core.
|
|
14
16
|
require 'solidus_dev_support/rspec/feature_helper'
|
|
15
17
|
|
|
16
18
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
17
19
|
# in spec/support/ and its subdirectories.
|
|
18
|
-
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
|
20
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f }
|
|
19
21
|
|
|
20
|
-
# Requires factories defined in lib/solidus_jwt/factories.rb
|
|
21
|
-
|
|
22
|
+
# Requires factories defined in lib/solidus_jwt/testing_support/factories.rb
|
|
23
|
+
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusJwt::Engine)
|
|
22
24
|
|
|
23
25
|
RSpec.configure do |config|
|
|
24
26
|
config.infer_spec_type_from_file_location!
|
|
@@ -14,10 +14,12 @@ RSpec.shared_examples 'Decodeable Examples' do
|
|
|
14
14
|
|
|
15
15
|
decoded_token = subject.decode(token)
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
aggregate_failures do
|
|
18
|
+
expect(JWT).to have_received(:decode).with(token, SolidusJwt::Config.jwt_secret,
|
|
19
|
+
true, hash_including(algorithm: SolidusJwt::Config.jwt_algorithm))
|
|
20
|
+
expect(decoded_token).to be_kind_of(Array)
|
|
21
|
+
expect(decoded_token.first).to include(payload.as_json)
|
|
22
|
+
end
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
end
|
|
@@ -9,9 +9,11 @@ RSpec.shared_examples 'Encodeable Examples' do
|
|
|
9
9
|
|
|
10
10
|
token = subject.encode(payload: payload)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
aggregate_failures do
|
|
13
|
+
expect(JWT).to have_received(:encode).with(hash_including('iat', 'user_id' => 1),
|
|
14
|
+
SolidusJwt::Config.jwt_secret, SolidusJwt::Config.jwt_algorithm)
|
|
15
|
+
expect(token).to be_kind_of String
|
|
16
|
+
end
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
context 'when expiration is passed in' do
|
|
@@ -20,9 +22,11 @@ RSpec.shared_examples 'Encodeable Examples' do
|
|
|
20
22
|
|
|
21
23
|
token = subject.encode(payload: payload, expires_in: 60)
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
aggregate_failures do
|
|
26
|
+
expect(JWT).to have_received(:encode).with(hash_including('iat', 'exp', 'user_id' => 1),
|
|
27
|
+
SolidusJwt::Config.jwt_secret, SolidusJwt::Config.jwt_algorithm)
|
|
28
|
+
expect(token).to be_kind_of String
|
|
29
|
+
end
|
|
26
30
|
end
|
|
27
31
|
end
|
|
28
32
|
end
|
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.2.
|
|
4
|
+
version: 1.2.2
|
|
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:
|
|
11
|
+
date: 2023-05-24 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: '
|
|
50
|
+
version: '5'
|
|
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: '
|
|
60
|
+
version: '5'
|
|
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
|
|
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
|
|
74
|
+
version: '0'
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
76
|
name: byebug
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -115,8 +115,10 @@ files:
|
|
|
115
115
|
- ".rubocop.yml"
|
|
116
116
|
- ".ruby-gemset"
|
|
117
117
|
- ".ruby-version"
|
|
118
|
+
- CHANGELOG.md
|
|
118
119
|
- Gemfile
|
|
119
120
|
- LICENSE
|
|
121
|
+
- OLD_CHANGELOG.md
|
|
120
122
|
- README.md
|
|
121
123
|
- Rakefile
|
|
122
124
|
- _config.yml
|
|
@@ -148,12 +150,10 @@ files:
|
|
|
148
150
|
- lib/solidus_jwt/devise_strategies/refresh_token.rb
|
|
149
151
|
- lib/solidus_jwt/distributor/devise.rb
|
|
150
152
|
- lib/solidus_jwt/engine.rb
|
|
151
|
-
- lib/solidus_jwt/factories.rb
|
|
152
153
|
- lib/solidus_jwt/preferences.rb
|
|
154
|
+
- lib/solidus_jwt/testing_support/factories.rb
|
|
153
155
|
- lib/solidus_jwt/version.rb
|
|
154
156
|
- solidus_jwt.gemspec
|
|
155
|
-
- spec/lib/solidus_jwt/concerns/decodeable_spec.rb
|
|
156
|
-
- spec/lib/solidus_jwt/concerns/encodeable_spec.rb
|
|
157
157
|
- spec/lib/solidus_jwt/config_spec.rb
|
|
158
158
|
- spec/lib/solidus_jwt/devise_strategies/password_spec.rb
|
|
159
159
|
- spec/lib/solidus_jwt/devise_strategies/refresh_token_spec.rb
|
|
@@ -165,34 +165,33 @@ files:
|
|
|
165
165
|
- spec/spec_helper.rb
|
|
166
166
|
- spec/support/shared_examples/decodeable_examples.rb
|
|
167
167
|
- spec/support/shared_examples/encodeable_examples.rb
|
|
168
|
-
homepage: https://github.com/
|
|
168
|
+
homepage: https://github.com/solidusio-contrib/solidus_jwt
|
|
169
169
|
licenses:
|
|
170
170
|
- BSD-3-Clause
|
|
171
171
|
metadata:
|
|
172
|
-
homepage_uri: https://github.com/
|
|
173
|
-
source_code_uri: https://github.com/
|
|
174
|
-
|
|
172
|
+
homepage_uri: https://github.com/solidusio-contrib/solidus_jwt
|
|
173
|
+
source_code_uri: https://github.com/solidusio-contrib/solidus_jwt
|
|
174
|
+
changelog_uri: https://github.com/solidusio/solidus_jwt/releases
|
|
175
|
+
post_install_message:
|
|
175
176
|
rdoc_options: []
|
|
176
177
|
require_paths:
|
|
177
178
|
- lib
|
|
178
179
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
180
|
requirements:
|
|
180
|
-
- - "
|
|
181
|
+
- - ">="
|
|
181
182
|
- !ruby/object:Gem::Version
|
|
182
|
-
version:
|
|
183
|
+
version: 2.5.0
|
|
183
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
185
|
requirements:
|
|
185
186
|
- - ">="
|
|
186
187
|
- !ruby/object:Gem::Version
|
|
187
188
|
version: '0'
|
|
188
189
|
requirements: []
|
|
189
|
-
rubygems_version: 3.
|
|
190
|
-
signing_key:
|
|
190
|
+
rubygems_version: 3.3.7
|
|
191
|
+
signing_key:
|
|
191
192
|
specification_version: 4
|
|
192
193
|
summary: Add Json Web Tokens to Solidus API
|
|
193
194
|
test_files:
|
|
194
|
-
- spec/lib/solidus_jwt/concerns/decodeable_spec.rb
|
|
195
|
-
- spec/lib/solidus_jwt/concerns/encodeable_spec.rb
|
|
196
195
|
- spec/lib/solidus_jwt/config_spec.rb
|
|
197
196
|
- spec/lib/solidus_jwt/devise_strategies/password_spec.rb
|
|
198
197
|
- spec/lib/solidus_jwt/devise_strategies/refresh_token_spec.rb
|
|
File without changes
|
|
File without changes
|