rack_jwt_bastion 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/.rubocop.yml +160 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +213 -0
- data/Rakefile +8 -0
- data/lib/rack_jwt_bastion/version.rb +5 -0
- data/lib/rack_jwt_bastion.rb +8 -0
- data/sig/rack_jwt_bastion.rbs +4 -0
- metadata +251 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c557abef3bcb2bb4e35fc955f23c1351f523d37944666bca2805b523eee8c55a
|
4
|
+
data.tar.gz: 4bd6bc3e97f53e28dab51b7b2c027969f4fdc04937a8729dc10eee4ac3c6860c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5dae1f18a5cc5797f26f7ce1a04c6897891edfaa9b6c5bf67e717ff7703718af3b0b55e99e6972074b6acf9f460bb2ad0dfc5ac686a932907c808533d5fc9b0e
|
7
|
+
data.tar.gz: 4d548159811d42719a952752d6593068d55e47bee6ac4f189b232645c62d7dd28f6756822c6e63ab58ac870a59c37f9e5d2e5edaabe03ec803112fbfa6891f30
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
plugins:
|
2
|
+
- rubocop-performance
|
3
|
+
- rubocop-minitest
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 3.1
|
7
|
+
NewCops: enable
|
8
|
+
SuggestExtensions: false
|
9
|
+
Exclude:
|
10
|
+
- 'adrs/**/*'
|
11
|
+
- 'coverage/**/*'
|
12
|
+
- '.github/**/*'
|
13
|
+
- '.vscode/**/*'
|
14
|
+
- '.history/**/*'
|
15
|
+
|
16
|
+
# Layout and Formatting
|
17
|
+
Layout/LineLength:
|
18
|
+
Max: 120
|
19
|
+
AllowedPatterns: ['\A\s*#.*\z'] # Allow long comments
|
20
|
+
|
21
|
+
Layout/MultilineMethodCallIndentation:
|
22
|
+
EnforcedStyle: indented
|
23
|
+
|
24
|
+
Layout/FirstArrayElementIndentation:
|
25
|
+
EnforcedStyle: consistent
|
26
|
+
|
27
|
+
Layout/FirstHashElementIndentation:
|
28
|
+
EnforcedStyle: consistent
|
29
|
+
|
30
|
+
# Style Guidelines
|
31
|
+
Style/Documentation:
|
32
|
+
Enabled: false # Disable for now during development
|
33
|
+
|
34
|
+
Style/StringLiterals:
|
35
|
+
EnforcedStyle: single_quotes
|
36
|
+
ConsistentQuotesInMultiline: true
|
37
|
+
|
38
|
+
Style/StringLiteralsInInterpolation:
|
39
|
+
EnforcedStyle: single_quotes
|
40
|
+
|
41
|
+
Style/FrozenStringLiteralComment:
|
42
|
+
Enabled: true
|
43
|
+
EnforcedStyle: always
|
44
|
+
|
45
|
+
Style/TrailingCommaInArguments:
|
46
|
+
EnforcedStyleForMultiline: comma
|
47
|
+
|
48
|
+
Style/TrailingCommaInArrayLiteral:
|
49
|
+
EnforcedStyleForMultiline: comma
|
50
|
+
|
51
|
+
Style/TrailingCommaInHashLiteral:
|
52
|
+
EnforcedStyleForMultiline: comma
|
53
|
+
|
54
|
+
Style/HashSyntax:
|
55
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
56
|
+
|
57
|
+
Style/Lambda:
|
58
|
+
EnforcedStyle: literal
|
59
|
+
|
60
|
+
Style/ClassAndModuleChildren:
|
61
|
+
Enabled: false # Allow both compact and nested styles
|
62
|
+
|
63
|
+
Style/NumericLiterals:
|
64
|
+
MinDigits: 6
|
65
|
+
|
66
|
+
Style/SymbolArray:
|
67
|
+
EnforcedStyle: brackets
|
68
|
+
|
69
|
+
Style/WordArray:
|
70
|
+
EnforcedStyle: brackets
|
71
|
+
|
72
|
+
# Naming Conventions
|
73
|
+
Naming/VariableNumber:
|
74
|
+
EnforcedStyle: snake_case
|
75
|
+
|
76
|
+
Naming/PredicatePrefix:
|
77
|
+
ForbiddenPrefixes:
|
78
|
+
- is_
|
79
|
+
|
80
|
+
# Metrics and Complexity
|
81
|
+
Metrics/BlockLength:
|
82
|
+
Exclude:
|
83
|
+
- 'spec/**/*'
|
84
|
+
- 'test/**/*'
|
85
|
+
- 'lib/tasks/**/*'
|
86
|
+
- 'config/**/*'
|
87
|
+
|
88
|
+
Metrics/ModuleLength:
|
89
|
+
Max: 200
|
90
|
+
Exclude:
|
91
|
+
- 'spec/**/*'
|
92
|
+
- 'test/**/*'
|
93
|
+
|
94
|
+
Metrics/ClassLength:
|
95
|
+
Max: 150
|
96
|
+
Exclude:
|
97
|
+
- 'spec/**/*'
|
98
|
+
- 'test/**/*'
|
99
|
+
|
100
|
+
Metrics/MethodLength:
|
101
|
+
Max: 20
|
102
|
+
Exclude:
|
103
|
+
- 'spec/**/*'
|
104
|
+
- 'test/**/*'
|
105
|
+
|
106
|
+
Metrics/AbcSize:
|
107
|
+
Max: 20
|
108
|
+
Exclude:
|
109
|
+
- 'spec/**/*'
|
110
|
+
- 'test/**/*'
|
111
|
+
|
112
|
+
Metrics/CyclomaticComplexity:
|
113
|
+
Max: 8
|
114
|
+
|
115
|
+
Metrics/PerceivedComplexity:
|
116
|
+
Max: 8
|
117
|
+
|
118
|
+
# Performance Rules
|
119
|
+
Performance/CollectionLiteralInLoop:
|
120
|
+
Enabled: true
|
121
|
+
|
122
|
+
Performance/StringReplacement:
|
123
|
+
Enabled: true
|
124
|
+
|
125
|
+
Performance/UnfreezeString:
|
126
|
+
Enabled: true
|
127
|
+
|
128
|
+
# Security Rules
|
129
|
+
Security/Open:
|
130
|
+
Enabled: true
|
131
|
+
|
132
|
+
Security/YAMLLoad:
|
133
|
+
Enabled: true
|
134
|
+
|
135
|
+
Security/JSONLoad:
|
136
|
+
Enabled: true
|
137
|
+
|
138
|
+
# Lint Rules
|
139
|
+
Lint/AmbiguousBlockAssociation:
|
140
|
+
Exclude:
|
141
|
+
- 'test/**/*'
|
142
|
+
|
143
|
+
Lint/SuppressedException:
|
144
|
+
AllowComments: true
|
145
|
+
|
146
|
+
# Minitest-specific Rules
|
147
|
+
Minitest/MultipleAssertions:
|
148
|
+
Enabled: false # Allow multiple assertions in tests
|
149
|
+
|
150
|
+
Minitest/AssertTruthy:
|
151
|
+
Enabled: true
|
152
|
+
|
153
|
+
Minitest/AssertWithExpectedArgument:
|
154
|
+
Enabled: true
|
155
|
+
|
156
|
+
Minitest/RefuteFalse:
|
157
|
+
Enabled: true
|
158
|
+
|
159
|
+
Minitest/RefuteNil:
|
160
|
+
Enabled: true
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
10
|
+
identity and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
26
|
+
community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
31
|
+
any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
35
|
+
without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official email address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
[INSERT CONTACT METHOD].
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
+
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
127
|
+
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2025 Ken C. Demanawa
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
# Rack JWT Bastion
|
2
|
+
|
3
|
+
JWT authentication middleware for multi-tenant Rack applications.
|
4
|
+
|
5
|
+
**Note: This is version 0.0.0 - a placeholder release to reserve the gem name. Implementation is in progress.**
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
- JWT token validation with configurable algorithms
|
10
|
+
- Multi-tenant support with company group validation
|
11
|
+
- Subdomain-based tenant isolation
|
12
|
+
- Company slug access control
|
13
|
+
- Configurable path exclusions for public endpoints
|
14
|
+
- Custom payload validation
|
15
|
+
- Debug mode for development
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'rack_jwt_bastion'
|
23
|
+
```
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
bundle install
|
29
|
+
```
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
```bash
|
34
|
+
gem install rack_jwt_bastion
|
35
|
+
```
|
36
|
+
|
37
|
+
## Quick Start
|
38
|
+
|
39
|
+
### Rails Application
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
# config/application.rb
|
43
|
+
config.middleware.insert_before 0, RackJwtBastion::Middleware, {
|
44
|
+
jwt_secret: ENV['JWT_SECRET'],
|
45
|
+
company_header_name: 'X-Company-Group-Id',
|
46
|
+
skip_paths: ['/api/v1/login', '/api/v1/refresh', '/health']
|
47
|
+
}
|
48
|
+
```
|
49
|
+
|
50
|
+
### Sinatra Application
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
require 'rack_jwt_bastion'
|
54
|
+
|
55
|
+
use RackJwtBastion::Middleware, {
|
56
|
+
jwt_secret: ENV['JWT_SECRET'],
|
57
|
+
company_header_name: 'X-Company-Group-Id',
|
58
|
+
skip_paths: ['/login', '/health']
|
59
|
+
}
|
60
|
+
```
|
61
|
+
|
62
|
+
### Pure Rack Application
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
require 'rack_jwt_bastion'
|
66
|
+
|
67
|
+
app = Rack::Builder.new do
|
68
|
+
use RackJwtBastion::Middleware, {
|
69
|
+
jwt_secret: ENV['JWT_SECRET'],
|
70
|
+
validate_subdomain: true,
|
71
|
+
validate_company_slug: true
|
72
|
+
}
|
73
|
+
|
74
|
+
run YourApp.new
|
75
|
+
end
|
76
|
+
```
|
77
|
+
|
78
|
+
## Configuration Options
|
79
|
+
|
80
|
+
### Basic Configuration
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
RackJwtBastion::Middleware.new(app, {
|
84
|
+
# JWT Settings (Required)
|
85
|
+
jwt_secret: ENV['JWT_SECRET'],
|
86
|
+
jwt_algorithm: 'HS256', # Default: 'HS256'
|
87
|
+
|
88
|
+
# Multi-Tenant Settings
|
89
|
+
company_header_name: 'X-Company-Group-Id', # Default: 'X-Company-Group-Id'
|
90
|
+
validate_subdomain: true, # Default: false
|
91
|
+
validate_company_slug: true, # Default: false
|
92
|
+
|
93
|
+
# Path Configuration
|
94
|
+
skip_paths: ['/health', '/api/v1/login', '/api/v1/refresh'],
|
95
|
+
company_slug_pattern: /^\/api\/v1\/([^\/]+)\//, # Default pattern
|
96
|
+
|
97
|
+
# Response Customization
|
98
|
+
unauthorized_response: { error: 'Authentication required' },
|
99
|
+
forbidden_response: { error: 'Access denied' },
|
100
|
+
|
101
|
+
# Debugging
|
102
|
+
debug_mode: Rails.env.development? # Default: false
|
103
|
+
})
|
104
|
+
```
|
105
|
+
|
106
|
+
### Advanced Configuration
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
RackJwtBastion::Middleware.new(app, {
|
110
|
+
jwt_secret: ENV['JWT_SECRET'],
|
111
|
+
|
112
|
+
# Custom Payload Validation
|
113
|
+
custom_payload_validator: ->(payload, request) {
|
114
|
+
# Return true if valid, false if invalid
|
115
|
+
payload['role'] == 'admin' || payload['permissions'].include?('read')
|
116
|
+
},
|
117
|
+
|
118
|
+
# Flexible Payload Mapping
|
119
|
+
payload_mapping: {
|
120
|
+
user_id: :sub, # Map 'sub' claim to user_id
|
121
|
+
company_group_id: :company_id, # Map 'company_id' claim
|
122
|
+
company_group_domain: :domain, # Map 'domain' claim
|
123
|
+
company_slugs: :accessible_companies # Map array of accessible companies
|
124
|
+
},
|
125
|
+
|
126
|
+
# Custom Tenant Extraction
|
127
|
+
tenant_strategy: :custom,
|
128
|
+
tenant_extractor: ->(request) {
|
129
|
+
# Extract tenant from custom header or logic
|
130
|
+
request.get_header('HTTP_X_TENANT_ID')
|
131
|
+
}
|
132
|
+
})
|
133
|
+
```
|
134
|
+
|
135
|
+
## Multi-Tenant Support
|
136
|
+
|
137
|
+
Rack JWT Bastion provides multiple strategies for multi-tenant authentication:
|
138
|
+
|
139
|
+
### Subdomain Validation
|
140
|
+
```ruby
|
141
|
+
# Validates that the JWT's domain matches the request subdomain
|
142
|
+
config.validate_subdomain = true
|
143
|
+
```
|
144
|
+
|
145
|
+
### Company Slug Validation
|
146
|
+
```ruby
|
147
|
+
# Validates that the requested company slug is accessible to the user
|
148
|
+
config.validate_company_slug = true
|
149
|
+
config.company_slug_pattern = /^\/api\/v1\/([^\/]+)\//
|
150
|
+
```
|
151
|
+
|
152
|
+
### Header-Based Validation
|
153
|
+
```ruby
|
154
|
+
# Validates the X-Company-Group-Id header against JWT payload
|
155
|
+
config.company_header_name = 'X-Company-Group-Id'
|
156
|
+
```
|
157
|
+
|
158
|
+
## JWT Payload Structure
|
159
|
+
|
160
|
+
The middleware expects JWT payloads with the following structure:
|
161
|
+
|
162
|
+
```json
|
163
|
+
{
|
164
|
+
"user_id": 12345,
|
165
|
+
"company_group_id": 67890,
|
166
|
+
"company_group_domain": "acme.example.com",
|
167
|
+
"company_slugs": ["acme", "acme-corp"],
|
168
|
+
"roles": ["admin", "user"],
|
169
|
+
"exp": 1640995200,
|
170
|
+
"iat": 1640991600
|
171
|
+
}
|
172
|
+
```
|
173
|
+
|
174
|
+
You can customize the payload mapping using the `payload_mapping` configuration option.
|
175
|
+
|
176
|
+
## Security Features
|
177
|
+
|
178
|
+
- JWT signature verification
|
179
|
+
- Token expiration validation
|
180
|
+
- Company/tenant access control
|
181
|
+
- Subdomain validation
|
182
|
+
- Request path filtering for public endpoints
|
183
|
+
|
184
|
+
## Performance
|
185
|
+
|
186
|
+
- Skip paths are checked before JWT processing
|
187
|
+
- Low memory footprint
|
188
|
+
- Compatible with JWT caching strategies
|
189
|
+
|
190
|
+
## Error Handling
|
191
|
+
|
192
|
+
The middleware returns appropriate HTTP status codes:
|
193
|
+
|
194
|
+
- **401 Unauthorized** - Missing, invalid, or expired JWT
|
195
|
+
- **403 Forbidden** - Valid JWT but insufficient permissions/access
|
196
|
+
|
197
|
+
## Development
|
198
|
+
|
199
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
200
|
+
|
201
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
202
|
+
|
203
|
+
## Contributing
|
204
|
+
|
205
|
+
Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](CODE_OF_CONDUCT.md).
|
206
|
+
|
207
|
+
## License
|
208
|
+
|
209
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
210
|
+
|
211
|
+
## Code of Conduct
|
212
|
+
|
213
|
+
Everyone interacting in the Rack JWT Bastion project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
metadata
ADDED
@@ -0,0 +1,251 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack_jwt_bastion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ken C. Demanawa
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-08-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.25'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.25'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mocha
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: vcr
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '6.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '6.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.79'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.79'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.38.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.38.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop-performance
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.25'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.25'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.7.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.7.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.22.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.22.0
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rake
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '13.3'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '13.3'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: irb
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1.15'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1.15'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: yard
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.9.37
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.9.37
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: kramdown
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '2.5'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '2.5'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: jwt
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '2.7'
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '2.7'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rack
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '2.0'
|
202
|
+
type: :runtime
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '2.0'
|
209
|
+
description: JWT authentication middleware with multi-tenant support, company validation,
|
210
|
+
and subdomain isolation.
|
211
|
+
email:
|
212
|
+
- kenneth.c.demanawa@gmail.com
|
213
|
+
executables: []
|
214
|
+
extensions: []
|
215
|
+
extra_rdoc_files: []
|
216
|
+
files:
|
217
|
+
- ".rubocop.yml"
|
218
|
+
- CODE_OF_CONDUCT.md
|
219
|
+
- LICENSE.txt
|
220
|
+
- README.md
|
221
|
+
- Rakefile
|
222
|
+
- lib/rack_jwt_bastion.rb
|
223
|
+
- lib/rack_jwt_bastion/version.rb
|
224
|
+
- sig/rack_jwt_bastion.rbs
|
225
|
+
homepage: https://github.com/kendemanawa/rack_jwt_bastion
|
226
|
+
licenses:
|
227
|
+
- MIT
|
228
|
+
metadata:
|
229
|
+
allowed_push_host: https://rubygems.org
|
230
|
+
homepage_uri: https://github.com/kendemanawa/rack_jwt_bastion
|
231
|
+
source_code_uri: https://github.com/kendemanawa/rack_jwt_bastion
|
232
|
+
post_install_message:
|
233
|
+
rdoc_options: []
|
234
|
+
require_paths:
|
235
|
+
- lib
|
236
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
237
|
+
requirements:
|
238
|
+
- - ">="
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: 3.2.0
|
241
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
242
|
+
requirements:
|
243
|
+
- - ">="
|
244
|
+
- !ruby/object:Gem::Version
|
245
|
+
version: '0'
|
246
|
+
requirements: []
|
247
|
+
rubygems_version: 3.3.27
|
248
|
+
signing_key:
|
249
|
+
specification_version: 4
|
250
|
+
summary: JWT authentication middleware for multi-tenant Rack applications
|
251
|
+
test_files: []
|