matic-jwt 1.2.1 → 1.3.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 +4 -4
- data/.github/workflows/check.yml +126 -0
- data/.github/workflows/release.yml +42 -0
- data/Gemfile.lock +26 -13
- data/README.md +17 -9
- data/lib/matic-jwt/grape/middleware/request.rb +6 -1
- data/lib/matic-jwt/version.rb +1 -1
- data/lib/matic-jwt.rb +2 -1
- metadata +8 -7
- data/.github/workflows/main.yml +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94c73d0e6a6c70bde758e9ab351d6ac08e75de575d20fb9d0c3b8cc98db4af02
|
4
|
+
data.tar.gz: f2c20ab9beb645806a5ad038815132ce8997cb8dcb7003e7921e7b2fd41944f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 043f8ac95959ec08a79f626a94893bf47824626b8665bdf86c1890d300b6fa9c8e1ac2a9da325b891ff07e437e857006ba1d5c3e70dc0d34676d183435f5df45
|
7
|
+
data.tar.gz: 0c6d1a5a83b667b11bc02126240490bef319e7e7b80efe25f10e46de0911d6952efc5d321a81fa6c1221dfd5e4c617ff35051f01e6a89f4fb293934c61b8ee4c
|
@@ -0,0 +1,126 @@
|
|
1
|
+
name: Check
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches: [ "master" ]
|
5
|
+
pull_request:
|
6
|
+
branches: [ "master" ]
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
check:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
ruby: [ '3.1', '3.4' ]
|
14
|
+
steps:
|
15
|
+
- name: Checkout
|
16
|
+
uses: actions/checkout@v4
|
17
|
+
|
18
|
+
- name: Set up Ruby
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
bundler-cache: true
|
23
|
+
|
24
|
+
- name: Run specs
|
25
|
+
env:
|
26
|
+
COVERAGE: true
|
27
|
+
run: bundle exec rspec
|
28
|
+
|
29
|
+
# release:
|
30
|
+
# runs-on: ubuntu-latest
|
31
|
+
# steps:
|
32
|
+
# - name: Checkout
|
33
|
+
# uses: actions/checkout@v4
|
34
|
+
# - name: Set up Ruby
|
35
|
+
# uses: ruby/setup-ruby@v1
|
36
|
+
# with:
|
37
|
+
# ruby-version: 3.1
|
38
|
+
# bundler-cache: true
|
39
|
+
# # - name: Set up credentials
|
40
|
+
# # run: |
|
41
|
+
# # mkdir -p $HOME/.gem
|
42
|
+
# # touch $HOME/.gem/credentials
|
43
|
+
# # chmod 0600 $HOME/.gem/credentials
|
44
|
+
# # printf -- "---\n:rubygems_api_key: ${{secrets.RUBYGEMS_AUTH_TOKEN}}\n" > $HOME/.gem/credentials
|
45
|
+
|
46
|
+
# - name: Get version
|
47
|
+
# run: echo "${GITHUB_REF/refs\/tags\//}" > release.tag
|
48
|
+
# - name: Set version
|
49
|
+
# run: sed -i "s/0.0.0/$(<release.tag)/g" $(find . -name "version.rb")
|
50
|
+
|
51
|
+
# - name: Build gem
|
52
|
+
# run: gem build *.gemspec
|
53
|
+
# # - name: Push gem
|
54
|
+
# # run: gem push *.gem
|
55
|
+
|
56
|
+
|
57
|
+
# # version: 2.1
|
58
|
+
|
59
|
+
# # orbs:
|
60
|
+
# # ci: matic/orb-common@0.3
|
61
|
+
# # ruby: circleci/ruby@2.5.3
|
62
|
+
|
63
|
+
|
64
|
+
# # release:
|
65
|
+
# # parameters:
|
66
|
+
# # tag:
|
67
|
+
# # type: string
|
68
|
+
# # default: "default-tag"
|
69
|
+
# # docker:
|
70
|
+
# # - image: cimg/ruby:3.1.4
|
71
|
+
# # environment:
|
72
|
+
# # RELEASE_TAG: << parameters.tag >>
|
73
|
+
# # steps:
|
74
|
+
# # - run:
|
75
|
+
# # name: Checkout code via HTTPS
|
76
|
+
# # command: |
|
77
|
+
# # git clone https://${GITHUB_TOKEN}@github.com/matic-insurance/matic-jwt-wrapper.git .
|
78
|
+
# # git checkout ${RELEASE_TAG}
|
79
|
+
# # - ruby/install-deps
|
80
|
+
# # - run:
|
81
|
+
# # name: Set up credentials
|
82
|
+
# # command: |
|
83
|
+
# # mkdir -p $HOME/.gem
|
84
|
+
# # echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" >> ~/.gem/credentials
|
85
|
+
# # chmod 0600 $HOME/.gem/credentials
|
86
|
+
# # - run:
|
87
|
+
# # name: Debug credentials
|
88
|
+
# # command: |
|
89
|
+
# # echo "API key length: ${#RUBYGEMS_API_KEY}"
|
90
|
+
# # echo "Credentials file exists: $(ls -la $HOME/.gem/credentials || echo 'NOT FOUND')"
|
91
|
+
# # echo "Testing API key with current gem..."
|
92
|
+
# # curl -f -H "Authorization: $RUBYGEMS_API_KEY" https://rubygems.org/api/v1/gems/matic-jwt-wrapper.json && echo "API key can access gem" || echo "API key cannot access gem"
|
93
|
+
# # - run:
|
94
|
+
# # name: Set version
|
95
|
+
# # command: sed -i "s/[[:digit:]].[[:digit:]].[[:digit:]]/${RELEASE_TAG}/g" $(find . -name "version.rb")
|
96
|
+
# # - run:
|
97
|
+
# # name: Build gem
|
98
|
+
# # command: gem build *.gemspec
|
99
|
+
# # - run:
|
100
|
+
# # name: Push gem
|
101
|
+
# # command: gem push *.gem
|
102
|
+
|
103
|
+
# # workflows:
|
104
|
+
|
105
|
+
# # matic-jwt-wrapper.build-pull-request:
|
106
|
+
# # when:
|
107
|
+
# # not:
|
108
|
+
# # equal: [ master, << pipeline.git.branch >> ]
|
109
|
+
# # jobs:
|
110
|
+
|
111
|
+
# # - release:
|
112
|
+
# # tag: "1.3.0"
|
113
|
+
# # context: gem-publishing
|
114
|
+
|
115
|
+
|
116
|
+
# # matic-jwt-wrapper.release:
|
117
|
+
# # jobs:
|
118
|
+
|
119
|
+
# # - release:
|
120
|
+
# # tag: << pipeline.git.tag >>
|
121
|
+
# # context: gem-publishing
|
122
|
+
# # filters:
|
123
|
+
# # branches:
|
124
|
+
# # ignore: /.*/
|
125
|
+
# # tags:
|
126
|
+
# # only: /\d\.\d\.\d/ # It should be [digin dot digit dot digit] format
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Release
|
2
|
+
on:
|
3
|
+
|
4
|
+
# push:
|
5
|
+
# tags:
|
6
|
+
# - '*.*.*'
|
7
|
+
push:
|
8
|
+
branches: [ "master" ]
|
9
|
+
pull_request:
|
10
|
+
branches: [ "master" ]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
release:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
permissions:
|
16
|
+
id-token: write
|
17
|
+
contents: read
|
18
|
+
steps:
|
19
|
+
- name: Checkout
|
20
|
+
uses: actions/checkout@v4
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: 3.1
|
25
|
+
bundler-cache: true
|
26
|
+
- name: Set version
|
27
|
+
run: |
|
28
|
+
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
29
|
+
VERSION=${GITHUB_REF#refs/tags/}
|
30
|
+
else
|
31
|
+
echo "❌ ERROR: This workflow should only run on tag pushes, though GITHUB_REF is $GITHUB_REF"
|
32
|
+
VERSION="1.3.0"
|
33
|
+
# exit 1
|
34
|
+
fi
|
35
|
+
echo "Setting version to: $VERSION"
|
36
|
+
find . -name "version.rb" -exec sed -i "s|VERSION = ['\"]0\.0\.0['\"]|VERSION = \"$VERSION\"|g" {} \;
|
37
|
+
- name: Configure RubyGems Credentials
|
38
|
+
uses: rubygems/configure-rubygems-credentials@main
|
39
|
+
- name: Build Gem
|
40
|
+
run: gem build *.gemspec
|
41
|
+
- name: Push gem
|
42
|
+
run: gem push *.gem
|
data/Gemfile.lock
CHANGED
@@ -8,18 +8,32 @@ PATH
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (
|
11
|
+
activesupport (7.1.5.1)
|
12
|
+
base64
|
13
|
+
benchmark (>= 0.3)
|
14
|
+
bigdecimal
|
12
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
connection_pool (>= 2.2.5)
|
17
|
+
drb
|
18
|
+
i18n (>= 1.6, < 2)
|
19
|
+
logger (>= 1.4.2)
|
20
|
+
minitest (>= 5.1)
|
21
|
+
mutex_m
|
22
|
+
securerandom (>= 0.3)
|
23
|
+
tzinfo (~> 2.0)
|
24
|
+
base64 (0.3.0)
|
25
|
+
benchmark (0.4.1)
|
26
|
+
bigdecimal (3.2.0)
|
27
|
+
concurrent-ruby (1.3.5)
|
28
|
+
connection_pool (2.5.3)
|
18
29
|
diff-lcs (1.3)
|
19
|
-
|
30
|
+
drb (2.2.3)
|
31
|
+
i18n (1.14.7)
|
20
32
|
concurrent-ruby (~> 1.0)
|
21
33
|
jwt (2.2.1)
|
22
|
-
|
34
|
+
logger (1.7.0)
|
35
|
+
minitest (5.25.5)
|
36
|
+
mutex_m (0.3.0)
|
23
37
|
rake (13.0.1)
|
24
38
|
rspec (3.7.0)
|
25
39
|
rspec-core (~> 3.7.0)
|
@@ -34,10 +48,9 @@ GEM
|
|
34
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
49
|
rspec-support (~> 3.7.0)
|
36
50
|
rspec-support (3.7.0)
|
37
|
-
|
38
|
-
tzinfo (
|
39
|
-
|
40
|
-
zeitwerk (2.3.0)
|
51
|
+
securerandom (0.4.1)
|
52
|
+
tzinfo (2.0.6)
|
53
|
+
concurrent-ruby (~> 1.0)
|
41
54
|
|
42
55
|
PLATFORMS
|
43
56
|
ruby
|
@@ -49,4 +62,4 @@ DEPENDENCIES
|
|
49
62
|
rspec (~> 3.0)
|
50
63
|
|
51
64
|
BUNDLED WITH
|
52
|
-
|
65
|
+
2.5.4
|
data/README.md
CHANGED
@@ -27,31 +27,39 @@ Use `MaticJWT::Generator` to create JWT tokens or headers:
|
|
27
27
|
generator = MaticJWT::Generator.new
|
28
28
|
token = generator.token_for('my_client', 'my_super_secret', additional_payload: 'test')
|
29
29
|
header = generator.authentication_header_for('my_client', 'my_super_secret', user_id: 'test@localhost.com')
|
30
|
-
```
|
30
|
+
```
|
31
31
|
|
32
32
|
### With Grape
|
33
|
+
Register `jwt_auth` strategy
|
34
|
+
```ruby
|
35
|
+
Grape::Middleware::Auth::Strategies.add(
|
36
|
+
:jwt_auth,
|
37
|
+
MaticJWT::Grape::Middleware::Auth,
|
38
|
+
->(options) { [options] }
|
39
|
+
)
|
40
|
+
```
|
33
41
|
|
34
|
-
Use ```:jwt_auth``` strategy and
|
42
|
+
Use ```:jwt_auth``` strategy and define lambda to obtain secret for by client name.
|
35
43
|
```ruby
|
36
|
-
auth :jwt_auth,
|
37
|
-
|
38
|
-
}
|
44
|
+
auth :jwt_auth,
|
45
|
+
secret: -> (client_name) { ::ApiClient.find_by!(name: client_name).secret }
|
39
46
|
```
|
47
|
+
|
40
48
|
If you need to get any data from authentication payload use ::MaticJWT::Grape::Helper.
|
41
49
|
```ruby
|
42
50
|
module ApiHelper
|
43
51
|
include ::MaticJWT::Grape::Helper
|
44
|
-
|
52
|
+
|
45
53
|
def current_client
|
46
54
|
@current_client ||= ::ApiClient.find_by!(name: client_name)
|
47
55
|
end
|
48
|
-
|
56
|
+
|
49
57
|
private
|
50
|
-
|
58
|
+
|
51
59
|
def client_name
|
52
60
|
auth_payload['client_name']
|
53
61
|
end
|
54
|
-
end
|
62
|
+
end
|
55
63
|
```
|
56
64
|
|
57
65
|
## Development
|
@@ -2,7 +2,12 @@ module MaticJWT
|
|
2
2
|
module Grape
|
3
3
|
module Middleware
|
4
4
|
class Request
|
5
|
-
AUTHORIZATION_KEYS = %w[
|
5
|
+
AUTHORIZATION_KEYS = %w[
|
6
|
+
Authorization
|
7
|
+
HTTP_AUTHORIZATION
|
8
|
+
X-HTTP_AUTHORIZATION
|
9
|
+
X_HTTP_AUTHORIZATION
|
10
|
+
].freeze
|
6
11
|
|
7
12
|
def initialize(env)
|
8
13
|
@env = env
|
data/lib/matic-jwt/version.rb
CHANGED
data/lib/matic-jwt.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matic-jwt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yurii Danyliak
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -88,7 +88,8 @@ executables: []
|
|
88
88
|
extensions: []
|
89
89
|
extra_rdoc_files: []
|
90
90
|
files:
|
91
|
-
- ".github/workflows/
|
91
|
+
- ".github/workflows/check.yml"
|
92
|
+
- ".github/workflows/release.yml"
|
92
93
|
- ".gitignore"
|
93
94
|
- Gemfile
|
94
95
|
- Gemfile.lock
|
@@ -109,7 +110,7 @@ homepage: https://github.com/matic-insurance/matic-jwt-wrapper
|
|
109
110
|
licenses: []
|
110
111
|
metadata:
|
111
112
|
allowed_push_host: https://rubygems.org
|
112
|
-
post_install_message:
|
113
|
+
post_install_message:
|
113
114
|
rdoc_options: []
|
114
115
|
require_paths:
|
115
116
|
- lib
|
@@ -124,8 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
125
|
- !ruby/object:Gem::Version
|
125
126
|
version: '0'
|
126
127
|
requirements: []
|
127
|
-
rubygems_version: 3.
|
128
|
-
signing_key:
|
128
|
+
rubygems_version: 3.3.27
|
129
|
+
signing_key:
|
129
130
|
specification_version: 4
|
130
131
|
summary: Matic's JWT implementation
|
131
132
|
test_files: []
|
data/.github/workflows/main.yml
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
name: ci
|
2
|
-
on:
|
3
|
-
push:
|
4
|
-
branches:
|
5
|
-
- master
|
6
|
-
pull_request:
|
7
|
-
branches:
|
8
|
-
- master
|
9
|
-
release:
|
10
|
-
types: [published]
|
11
|
-
|
12
|
-
jobs:
|
13
|
-
build:
|
14
|
-
runs-on: ubuntu-latest
|
15
|
-
strategy:
|
16
|
-
matrix:
|
17
|
-
ruby: [ '2.5.x', '2.6.x' ]
|
18
|
-
steps:
|
19
|
-
- name: Checkout
|
20
|
-
uses: actions/checkout@v1
|
21
|
-
- name: Cache dependencies
|
22
|
-
uses: actions/cache@v1
|
23
|
-
with:
|
24
|
-
path: vendor/bundle
|
25
|
-
key: ${{ runner.OS }}-ruby-${{ matrix.ruby }}
|
26
|
-
restore-keys: ${{ runner.OS }}-
|
27
|
-
|
28
|
-
- name: Set up Ruby
|
29
|
-
uses: actions/setup-ruby@v1
|
30
|
-
with:
|
31
|
-
ruby-version: ${{ matrix.ruby }}
|
32
|
-
- name: Set up Bundler
|
33
|
-
run: gem install bundler:1.14.5
|
34
|
-
- name: Set up Dependencies
|
35
|
-
run: bundle install --path vendor/bundle
|
36
|
-
- name: Run specs
|
37
|
-
run: bundle exec rspec
|
38
|
-
|
39
|
-
release:
|
40
|
-
runs-on: ubuntu-latest
|
41
|
-
needs: build
|
42
|
-
if: github.event_name == 'release' && github.event.action == 'published'
|
43
|
-
steps:
|
44
|
-
- name: Checkout
|
45
|
-
uses: actions/checkout@v1
|
46
|
-
|
47
|
-
- name: Set up Ruby
|
48
|
-
uses: actions/setup-ruby@v1
|
49
|
-
with:
|
50
|
-
ruby-version: 2.6.x
|
51
|
-
- name: Set up Bundler
|
52
|
-
run: gem install bundler:1.17.3
|
53
|
-
- name: Set up credentials
|
54
|
-
run: |
|
55
|
-
mkdir -p $HOME/.gem
|
56
|
-
touch $HOME/.gem/credentials
|
57
|
-
chmod 0600 $HOME/.gem/credentials
|
58
|
-
printf -- "---\n:rubygems_api_key: ${{secrets.RUBYGEMS_AUTH_TOKEN}}\n" > $HOME/.gem/credentials
|
59
|
-
|
60
|
-
- name: Get version
|
61
|
-
run: echo "${GITHUB_REF/refs\/tags\//}" > release.tag
|
62
|
-
- name: Set version
|
63
|
-
run: sed -i "s/0.0.0/$(<release.tag)/g" */**/version.rb
|
64
|
-
|
65
|
-
- name: Build gem
|
66
|
-
run: gem build *.gemspec
|
67
|
-
- name: Push gem
|
68
|
-
run: gem push *.gem
|