matic-jwt 0.0.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 +7 -0
- data/.github/workflows/check.yml +126 -0
- data/.github/workflows/release.yml +48 -0
- data/.gitignore +3 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +65 -0
- data/LICENSE +21 -0
- data/README.md +73 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/matic-jwt/authenticator.rb +32 -0
- data/lib/matic-jwt/generator.rb +18 -0
- data/lib/matic-jwt/grape/helper.rb +9 -0
- data/lib/matic-jwt/grape/middleware/auth.rb +53 -0
- data/lib/matic-jwt/grape/middleware/request.rb +32 -0
- data/lib/matic-jwt/version.rb +3 -0
- data/lib/matic-jwt.rb +19 -0
- data/matic-jwt.gemspec +37 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8b624c9c52acaca45eb266a0330caad507b5c3c9703fcb2f72b5eafac1f93e0d
|
4
|
+
data.tar.gz: 02d5edd0582f0f74675b00e3bf90d0395d154d96eb970a9963af81d03cc64847
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 85712bd024305d49c75278c0a88ccb555d0549a5c8463a676a1b8a0f1b8ca9c4010f0f5a88a6e61aa8d7e0c05ff1fdfcdeec0ad14cfcc6b978cf450489e63868
|
7
|
+
data.tar.gz: e387268e6733f484bb8d5385605161258af8ec678de1955b2f4d155d2921b18fd01df1c34f2a87f2694043c51529fd84b3bf696e072864ee8373a3576ffa92eb
|
@@ -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,48 @@
|
|
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
|
+
echo "Setting version to: $VERSION"
|
31
|
+
find . -name "version.rb" -exec sed -i "s|VERSION = ['\"]0\.0\.0['\"]|VERSION = \"$VERSION\"|g" {} \;
|
32
|
+
else
|
33
|
+
echo "❌ ERROR: This workflow should only run on tag pushes, though GITHUB_REF is $GITHUB_REF"
|
34
|
+
VERSION="1.3.0"
|
35
|
+
# exit 1
|
36
|
+
fi
|
37
|
+
- name: Configure RubyGems Credentials
|
38
|
+
uses: rubygems/configure-rubygems-credentials@main
|
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
|
+
- name: Build gem
|
46
|
+
run: gem build *.gemspec
|
47
|
+
- name: Push gem
|
48
|
+
run: gem push *.gem
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
matic-jwt (0.0.0)
|
5
|
+
activesupport
|
6
|
+
jwt
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (7.1.5.1)
|
12
|
+
base64
|
13
|
+
benchmark (>= 0.3)
|
14
|
+
bigdecimal
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
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)
|
29
|
+
diff-lcs (1.3)
|
30
|
+
drb (2.2.3)
|
31
|
+
i18n (1.14.7)
|
32
|
+
concurrent-ruby (~> 1.0)
|
33
|
+
jwt (2.2.1)
|
34
|
+
logger (1.7.0)
|
35
|
+
minitest (5.25.5)
|
36
|
+
mutex_m (0.3.0)
|
37
|
+
rake (13.0.1)
|
38
|
+
rspec (3.7.0)
|
39
|
+
rspec-core (~> 3.7.0)
|
40
|
+
rspec-expectations (~> 3.7.0)
|
41
|
+
rspec-mocks (~> 3.7.0)
|
42
|
+
rspec-core (3.7.0)
|
43
|
+
rspec-support (~> 3.7.0)
|
44
|
+
rspec-expectations (3.7.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.7.0)
|
47
|
+
rspec-mocks (3.7.0)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.7.0)
|
50
|
+
rspec-support (3.7.0)
|
51
|
+
securerandom (0.4.1)
|
52
|
+
tzinfo (2.0.6)
|
53
|
+
concurrent-ruby (~> 1.0)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
bundler (~> 1.16)
|
60
|
+
matic-jwt!
|
61
|
+
rake (~> 13.0)
|
62
|
+
rspec (~> 3.0)
|
63
|
+
|
64
|
+
BUNDLED WITH
|
65
|
+
2.5.4
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Matic Insurance Services
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Matic::Jwt
|
2
|
+
|
3
|
+
Matic's implementation of JWT authentication.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'matic-jwt'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install matic-jwt
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Plain Ruby
|
24
|
+
|
25
|
+
Use `MaticJWT::Generator` to create JWT tokens or headers:
|
26
|
+
```ruby
|
27
|
+
generator = MaticJWT::Generator.new
|
28
|
+
token = generator.token_for('my_client', 'my_super_secret', additional_payload: 'test')
|
29
|
+
header = generator.authentication_header_for('my_client', 'my_super_secret', user_id: 'test@localhost.com')
|
30
|
+
```
|
31
|
+
|
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
|
+
```
|
41
|
+
|
42
|
+
Use ```:jwt_auth``` strategy and define lambda to obtain secret for by client name.
|
43
|
+
```ruby
|
44
|
+
auth :jwt_auth,
|
45
|
+
secret: -> (client_name) { ::ApiClient.find_by!(name: client_name).secret }
|
46
|
+
```
|
47
|
+
|
48
|
+
If you need to get any data from authentication payload use ::MaticJWT::Grape::Helper.
|
49
|
+
```ruby
|
50
|
+
module ApiHelper
|
51
|
+
include ::MaticJWT::Grape::Helper
|
52
|
+
|
53
|
+
def current_client
|
54
|
+
@current_client ||= ::ApiClient.find_by!(name: client_name)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def client_name
|
60
|
+
auth_payload['client_name']
|
61
|
+
end
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
## Development
|
66
|
+
|
67
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
68
|
+
|
69
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/matic-jwt.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "matic/jwt"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
module MaticJWT
|
2
|
+
class Authenticator
|
3
|
+
def initialize(header, scheme: SCHEME)
|
4
|
+
@scheme = scheme
|
5
|
+
@token = extract_token(header)
|
6
|
+
end
|
7
|
+
|
8
|
+
def client_name
|
9
|
+
payload.first['client_name']
|
10
|
+
end
|
11
|
+
|
12
|
+
def authenticate_with_secret!(secret)
|
13
|
+
JWT.decode(@token, secret, true, algorithm: ALGORITHM)
|
14
|
+
end
|
15
|
+
|
16
|
+
def payload
|
17
|
+
JWT.decode(@token, nil, false)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def extract_token(header)
|
23
|
+
token = header&.slice(@scheme.length + 1..-1)
|
24
|
+
validate_header_presence!(token)
|
25
|
+
token
|
26
|
+
end
|
27
|
+
|
28
|
+
def validate_header_presence!(token)
|
29
|
+
raise(JWT::DecodeError, 'Authorization token is incorrect') unless token&.present?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module MaticJWT
|
2
|
+
class Generator
|
3
|
+
def initialize(expiration: EXPIRATION, scheme: SCHEME)
|
4
|
+
@expiration = expiration
|
5
|
+
@scheme = scheme
|
6
|
+
end
|
7
|
+
|
8
|
+
def token_for(client_name, secret, payload = {})
|
9
|
+
jwt_payload = payload.merge(client_name: client_name, exp: @expiration.since.to_i)
|
10
|
+
JWT.encode(jwt_payload, secret, ALGORITHM)
|
11
|
+
end
|
12
|
+
|
13
|
+
def authentication_header_for(client_name, secret, payload = {})
|
14
|
+
token = token_for(client_name, secret, payload)
|
15
|
+
"#{@scheme} #{token}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module MaticJWT
|
2
|
+
module Grape
|
3
|
+
module Middleware
|
4
|
+
class Auth
|
5
|
+
def initialize(app, options)
|
6
|
+
@app = app
|
7
|
+
@secret_reader = options[:secret]
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(env)
|
11
|
+
@env = env
|
12
|
+
|
13
|
+
validate_request
|
14
|
+
decode_payload
|
15
|
+
authenticate!
|
16
|
+
continue!
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def validate_request
|
22
|
+
raise JWT::VerificationError, 'Authorization token is invalid' unless request.valid?
|
23
|
+
end
|
24
|
+
|
25
|
+
def decode_payload
|
26
|
+
@env['auth_payload'] = jwt_authenticator.payload&.first
|
27
|
+
end
|
28
|
+
|
29
|
+
def authenticate!
|
30
|
+
jwt_authenticator.authenticate_with_secret!(secret)
|
31
|
+
end
|
32
|
+
|
33
|
+
def continue!
|
34
|
+
@app.call(@env)
|
35
|
+
end
|
36
|
+
|
37
|
+
def jwt_authenticator
|
38
|
+
::MaticJWT::Authenticator.new(request.auth_token)
|
39
|
+
end
|
40
|
+
|
41
|
+
def secret
|
42
|
+
@secret_reader.call(jwt_authenticator.client_name)
|
43
|
+
end
|
44
|
+
|
45
|
+
def request
|
46
|
+
@request ||= ::MaticJWT::Grape::Middleware::Request.new(@env)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Grape::Middleware::Auth::Strategies.add(:jwt_auth, ::MaticJWT::Grape::Middleware::Auth, ->(options) { [options] })
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module MaticJWT
|
2
|
+
module Grape
|
3
|
+
module Middleware
|
4
|
+
class Request
|
5
|
+
AUTHORIZATION_KEYS = %w[
|
6
|
+
Authorization
|
7
|
+
HTTP_AUTHORIZATION
|
8
|
+
X-HTTP_AUTHORIZATION
|
9
|
+
X_HTTP_AUTHORIZATION
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
def initialize(env)
|
13
|
+
@env = env
|
14
|
+
end
|
15
|
+
|
16
|
+
def valid?
|
17
|
+
!@env[auth_key].nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def auth_token
|
21
|
+
@env[auth_key]
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def auth_key
|
27
|
+
@authorization_key ||= AUTHORIZATION_KEYS.detect { |key| @env.key?(key) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/matic-jwt.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
require 'jwt'
|
4
|
+
|
5
|
+
require 'matic-jwt/authenticator'
|
6
|
+
require 'matic-jwt/generator'
|
7
|
+
require 'matic-jwt/version'
|
8
|
+
|
9
|
+
if Gem.loaded_specs.has_key?('grape')
|
10
|
+
require 'matic-jwt/grape/helper'
|
11
|
+
require 'matic-jwt/grape/middleware/request'
|
12
|
+
require 'matic-jwt/grape/middleware/auth'
|
13
|
+
end
|
14
|
+
|
15
|
+
module MaticJWT
|
16
|
+
ALGORITHM = 'HS256'.freeze
|
17
|
+
EXPIRATION = 1.minute
|
18
|
+
SCHEME = 'Bearer'.freeze
|
19
|
+
end
|
data/matic-jwt.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'matic-jwt/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'matic-jwt'
|
8
|
+
spec.version = MaticJWT::VERSION
|
9
|
+
spec.authors = ['Yurii Danyliak']
|
10
|
+
spec.email = ['ydanyliak@getmatic.com']
|
11
|
+
|
12
|
+
spec.summary = "Matic's JWT implementation"
|
13
|
+
spec.description = 'This gem contains specific implementation of JWT authentication to be used inside of Matic products.'
|
14
|
+
spec.homepage = 'https://github.com/matic-insurance/matic-jwt-wrapper'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
20
|
+
else
|
21
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_dependency 'jwt'
|
32
|
+
spec.add_dependency 'activesupport'
|
33
|
+
|
34
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
35
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
36
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: matic-jwt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yurii Danyliak
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-07-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jwt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '13.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '13.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description: This gem contains specific implementation of JWT authentication to be
|
84
|
+
used inside of Matic products.
|
85
|
+
email:
|
86
|
+
- ydanyliak@getmatic.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".github/workflows/check.yml"
|
92
|
+
- ".github/workflows/release.yml"
|
93
|
+
- ".gitignore"
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/console
|
100
|
+
- bin/setup
|
101
|
+
- lib/matic-jwt.rb
|
102
|
+
- lib/matic-jwt/authenticator.rb
|
103
|
+
- lib/matic-jwt/generator.rb
|
104
|
+
- lib/matic-jwt/grape/helper.rb
|
105
|
+
- lib/matic-jwt/grape/middleware/auth.rb
|
106
|
+
- lib/matic-jwt/grape/middleware/request.rb
|
107
|
+
- lib/matic-jwt/version.rb
|
108
|
+
- matic-jwt.gemspec
|
109
|
+
homepage: https://github.com/matic-insurance/matic-jwt-wrapper
|
110
|
+
licenses: []
|
111
|
+
metadata:
|
112
|
+
allowed_push_host: https://rubygems.org
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
require_paths:
|
116
|
+
- lib
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
requirements: []
|
128
|
+
rubygems_version: 3.3.27
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Matic's JWT implementation
|
132
|
+
test_files: []
|