rack_jwt_aegis 0.0.0 โ 1.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 +4 -4
- data/.rubocop.yml +9 -0
- data/.yard/yard_gfm_config.rb +21 -0
- data/.yardopts +16 -0
- data/CHANGELOG.md +204 -0
- data/README.md +339 -45
- data/Rakefile +52 -0
- data/bin/console +11 -0
- data/bin/docs +20 -0
- data/bin/setup +8 -0
- data/exe/rack_jwt_aegis +235 -0
- data/lib/rack_jwt_aegis/configuration.rb +205 -44
- data/lib/rack_jwt_aegis/jwt_validator.rb +56 -14
- data/lib/rack_jwt_aegis/middleware.rb +72 -2
- data/lib/rack_jwt_aegis/multi_tenant_validator.rb +43 -18
- data/lib/rack_jwt_aegis/rbac_manager.rb +323 -76
- data/lib/rack_jwt_aegis/request_context.rb +64 -23
- data/lib/rack_jwt_aegis/version.rb +1 -1
- data/lib/rack_jwt_aegis.rb +36 -1
- metadata +24 -13
- data/examples/basic_usage.rb +0 -85
- /data/sig/{rack_jwt_bastion.rbs โ rack_jwt_aegis.rbs} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 775e606ab0475ef440f8d5e0b0cf4fa7834fdcadb9565c6123197437103b2e1f
|
4
|
+
data.tar.gz: 8dbf8f35c54e16ee86cc31b07a24d8ced023d7aa7684a3f1841cc811ceeb7c97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 758002b6d87d06d508eb2a548970ef81a16690db287362054927d4833c1200ded1f179fd573f505201d0d10204a9345bbc9f97c83af4c557757a3b39ed6eee8a
|
7
|
+
data.tar.gz: cfa522bc3373b26e1180507d04808132e4a3ea8aabfb4ac2a1661b62ec4953fc5014b93a89df9ae2d46f9c4af5b89893c298db7c37a9680d1f82bae1608e75ac
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
plugins:
|
2
2
|
- rubocop-performance
|
3
3
|
- rubocop-minitest
|
4
|
+
- rubocop-rake
|
4
5
|
|
5
6
|
AllCops:
|
6
7
|
TargetRubyVersion: 3.2
|
@@ -12,6 +13,7 @@ AllCops:
|
|
12
13
|
- '.github/**/*'
|
13
14
|
- '.vscode/**/*'
|
14
15
|
- '.history/**/*'
|
16
|
+
- 'examples/**/*'
|
15
17
|
|
16
18
|
# Layout and Formatting
|
17
19
|
Layout/LineLength:
|
@@ -84,6 +86,7 @@ Metrics/BlockLength:
|
|
84
86
|
- 'test/**/*'
|
85
87
|
- 'lib/tasks/**/*'
|
86
88
|
- 'config/**/*'
|
89
|
+
- 'rack_jwt_aegis.gemspec'
|
87
90
|
|
88
91
|
Metrics/ModuleLength:
|
89
92
|
Max: 200
|
@@ -92,28 +95,34 @@ Metrics/ModuleLength:
|
|
92
95
|
- 'test/**/*'
|
93
96
|
|
94
97
|
Metrics/ClassLength:
|
98
|
+
Enabled: false
|
95
99
|
Max: 150
|
96
100
|
Exclude:
|
97
101
|
- 'spec/**/*'
|
98
102
|
- 'test/**/*'
|
103
|
+
- 'bin/**/*'
|
99
104
|
|
100
105
|
Metrics/MethodLength:
|
101
106
|
Max: 20
|
107
|
+
Enabled: false
|
102
108
|
Exclude:
|
103
109
|
- 'spec/**/*'
|
104
110
|
- 'test/**/*'
|
105
111
|
|
106
112
|
Metrics/AbcSize:
|
107
113
|
Max: 20
|
114
|
+
Enabled: false
|
108
115
|
Exclude:
|
109
116
|
- 'spec/**/*'
|
110
117
|
- 'test/**/*'
|
111
118
|
|
112
119
|
Metrics/CyclomaticComplexity:
|
113
120
|
Max: 8
|
121
|
+
Enabled: false
|
114
122
|
|
115
123
|
Metrics/PerceivedComplexity:
|
116
124
|
Max: 8
|
125
|
+
Enabled: false
|
117
126
|
|
118
127
|
# Performance Rules
|
119
128
|
Performance/CollectionLiteralInLoop:
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Custom YARD configuration for GitHub Flavored Markdown support
|
4
|
+
#
|
5
|
+
# This configuration ensures the kramdown-parser-gfm gem is available for
|
6
|
+
# proper rendering of fenced code blocks (```language) in YARD documentation.
|
7
|
+
#
|
8
|
+
# The actual GFM parsing integration is handled by YARD when kramdown is
|
9
|
+
# configured with the GFM input parser.
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'kramdown'
|
13
|
+
require 'kramdown-parser-gfm'
|
14
|
+
|
15
|
+
# Ensure GFM parser is available - YARD will use it automatically
|
16
|
+
# when kramdown processes markdown with input: 'GFM'
|
17
|
+
|
18
|
+
rescue LoadError => e
|
19
|
+
# Fallback gracefully if GFM parser is not available
|
20
|
+
puts "Warning: kramdown-parser-gfm not available, fenced code blocks may not render properly: #{e.message}"
|
21
|
+
end
|
data/.yardopts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
--output-dir doc
|
2
|
+
--readme README.md
|
3
|
+
--markup-provider=kramdown
|
4
|
+
--markup=markdown
|
5
|
+
--main README.md
|
6
|
+
--protected
|
7
|
+
--private
|
8
|
+
--no-private
|
9
|
+
--title "RackJwtAegis API Documentation"
|
10
|
+
--charset utf-8
|
11
|
+
lib/**/*.rb
|
12
|
+
-
|
13
|
+
README.md
|
14
|
+
LICENSE.txt
|
15
|
+
CODE_OF_CONDUCT.md
|
16
|
+
adrs/architecture.md
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [1.0.0] - 2025-08-13
|
9
|
+
|
10
|
+
### ๐ Initial Release
|
11
|
+
|
12
|
+
This is the first stable release of Rack JWT Aegis, a JWT authentication middleware for hierarchical multi-tenant Rack applications.
|
13
|
+
|
14
|
+
### โจ Added
|
15
|
+
|
16
|
+
#### Core Authentication Features
|
17
|
+
|
18
|
+
- **JWT Token Validation** with configurable algorithms (HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512)
|
19
|
+
- **Multi-Tenant Support** with 2-level hierarchy (Company-Group โ Company, Organization โ Department, etc.)
|
20
|
+
- **Subdomain-based Tenant Isolation** for top-level tenants
|
21
|
+
- **URL Pathname Slug Access Control** for sub-level tenants with regex pattern support
|
22
|
+
- **Configurable Path Exclusions** for public endpoints with flexible pattern matching
|
23
|
+
- **Custom Payload Validation** with user-defined validation logic
|
24
|
+
- **Request Context Access** with convenient helper methods for accessing JWT payload data
|
25
|
+
|
26
|
+
#### RBAC (Role-Based Access Control)
|
27
|
+
|
28
|
+
- **Fine-grained Permission System** with resource:method format (e.g., `users:get`, `reports:post`)
|
29
|
+
- **Wildcard Method Support** (e.g., `admin/*` for all methods)
|
30
|
+
- **Regex Pattern Matching** for dynamic resource paths (e.g., `%r{users/\d+}:put`)
|
31
|
+
- **Multi-tier Caching** for performance optimization
|
32
|
+
- **Cache Write Control** with zero-trust mode support
|
33
|
+
- **Permission Cache TTL** with configurable expiration
|
34
|
+
- **Debug Mode** with comprehensive logging
|
35
|
+
|
36
|
+
#### Caching System
|
37
|
+
|
38
|
+
- **Multiple Cache Adapters**:
|
39
|
+
- Memory adapter (built-in, thread-safe)
|
40
|
+
- Redis adapter with connection pooling
|
41
|
+
- Memcached adapter with Dalli integration
|
42
|
+
- SolidCache adapter for Rails 8+ applications
|
43
|
+
- **Intelligent Cache Invalidation** based on RBAC updates
|
44
|
+
- **Performance Optimization** with counter caches and eager loading
|
45
|
+
- **Error Handling** with graceful fallback and retry logic
|
46
|
+
|
47
|
+
#### CLI Tool
|
48
|
+
|
49
|
+
- **JWT Secret Generation** with multiple formats (plain, base64, environment variable)
|
50
|
+
- **Batch Secret Generation** for multiple environments
|
51
|
+
- **Secure Random Generation** using cryptographically secure methods
|
52
|
+
|
53
|
+
#### Configuration & Validation
|
54
|
+
|
55
|
+
- **Flexible Configuration** with sensible defaults
|
56
|
+
- **Multi-tenant Validation** with header-based and URL-based strategies
|
57
|
+
- **Custom Validation Hooks** for business-specific requirements
|
58
|
+
- **Debug Mode** for development and troubleshooting
|
59
|
+
|
60
|
+
#### Developer Experience
|
61
|
+
|
62
|
+
- **Comprehensive Documentation** with YARD-generated API docs
|
63
|
+
- **GitHub Pages Integration** with automatic deployment
|
64
|
+
- **High Test Coverage** (97.8% line coverage, 86.6% branch coverage)
|
65
|
+
- **RuboCop Integration** with style enforcement
|
66
|
+
- **Code Examples** for common use cases
|
67
|
+
|
68
|
+
### ๐๏ธ Technical Implementation
|
69
|
+
|
70
|
+
#### Architecture
|
71
|
+
|
72
|
+
- **Modular Design** with clear separation of concerns
|
73
|
+
- **Rack Middleware** integration for framework independence
|
74
|
+
- **Thread-safe Operations** for concurrent request handling
|
75
|
+
- **Memory Efficient** with optimized data structures
|
76
|
+
- **Error Boundary** with proper exception handling
|
77
|
+
|
78
|
+
#### Testing & Quality
|
79
|
+
|
80
|
+
- **Comprehensive Test Suite** with Minitest framework
|
81
|
+
- **Mock Integration** with Mocha for reliable testing
|
82
|
+
- **Cache Adapter Testing** with actual Redis and Dalli gems
|
83
|
+
- **Edge Case Coverage** for error handling and validation paths
|
84
|
+
- **Performance Testing** for cache operations and memory usage
|
85
|
+
|
86
|
+
#### Documentation & Workflows
|
87
|
+
|
88
|
+
- **GitHub Actions CI/CD** with multi-Ruby version testing
|
89
|
+
- **Automated Documentation Deployment** to GitHub Pages
|
90
|
+
- **Workflow Dispatch** for manual deployments
|
91
|
+
- **Coverage Reporting** with SimpleCov integration
|
92
|
+
- **Code Quality Checks** with RuboCop and documentation coverage
|
93
|
+
|
94
|
+
### ๐ง Configuration Examples
|
95
|
+
|
96
|
+
#### Basic JWT Authentication
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
use RackJwtAegis::Middleware, {
|
100
|
+
jwt_secret: ENV['JWT_SECRET'],
|
101
|
+
jwt_algorithm: 'HS256'
|
102
|
+
}
|
103
|
+
```
|
104
|
+
|
105
|
+
#### Multi-tenant with RBAC
|
106
|
+
|
107
|
+
```ruby
|
108
|
+
use RackJwtAegis::Middleware, {
|
109
|
+
jwt_secret: ENV['JWT_SECRET'],
|
110
|
+
multi_tenant_enabled: true,
|
111
|
+
subdomain_validation_enabled: true,
|
112
|
+
rbac_enabled: true,
|
113
|
+
rbac_cache_store: :redis,
|
114
|
+
debug_mode: Rails.env.development?
|
115
|
+
}
|
116
|
+
```
|
117
|
+
|
118
|
+
#### Enterprise Configuration
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
use RackJwtAegis::Middleware, {
|
122
|
+
jwt_secret: ENV['JWT_SECRET'],
|
123
|
+
jwt_algorithm: 'RS256',
|
124
|
+
multi_tenant_enabled: true,
|
125
|
+
subdomain_validation_enabled: true,
|
126
|
+
pathname_slug_pattern: /^\/api\/v1\/([^\/]+)\//,
|
127
|
+
rbac_enabled: true,
|
128
|
+
rbac_cache_store: :redis,
|
129
|
+
permission_cache_store: :memory,
|
130
|
+
user_permissions_ttl: 300,
|
131
|
+
cache_write_enabled: true,
|
132
|
+
skip_paths: [/^\/health/, /^\/metrics/, /^\/api\/public/],
|
133
|
+
custom_payload_validation: ->(payload) { payload['active'] == true },
|
134
|
+
debug_mode: false
|
135
|
+
}
|
136
|
+
```
|
137
|
+
|
138
|
+
### ๐ Documentation
|
139
|
+
|
140
|
+
- **Online Documentation**: Auto-deployed to GitHub Pages
|
141
|
+
- **API Reference**: Complete YARD documentation for all classes and methods
|
142
|
+
- **Usage Examples**: Comprehensive examples for all features
|
143
|
+
- **Architecture Decisions**: ADRs documenting design choices
|
144
|
+
- **Integration Guides**: Framework-specific integration examples
|
145
|
+
|
146
|
+
### ๐งช Testing Coverage
|
147
|
+
|
148
|
+
- **Line Coverage**: 97.8% (668/683 lines)
|
149
|
+
- **Branch Coverage**: 86.6% (259/299 branches)
|
150
|
+
- **Test Files**: 15 comprehensive test suites
|
151
|
+
- **Test Cases**: 323+ individual test cases
|
152
|
+
- **Cache Integration**: Tests with actual Redis and Dalli gems
|
153
|
+
|
154
|
+
### ๐ Dependencies
|
155
|
+
|
156
|
+
#### Core Dependencies
|
157
|
+
|
158
|
+
- `rack` (~> 3.0)
|
159
|
+
- `jwt` (~> 2.8)
|
160
|
+
|
161
|
+
#### Development Dependencies
|
162
|
+
|
163
|
+
- `redis` (~> 5.0) - For Redis cache adapter testing
|
164
|
+
- `dalli` (~> 3.0) - For Memcached cache adapter testing
|
165
|
+
- `minitest` (~> 5.25) - Test framework
|
166
|
+
- `mocha` (~> 2.7) - Mocking library
|
167
|
+
- `simplecov` (~> 0.22.0) - Coverage reporting
|
168
|
+
- `yard` (~> 0.9.37) - Documentation generation
|
169
|
+
|
170
|
+
### ๐ Performance Characteristics
|
171
|
+
|
172
|
+
- **Memory Efficient**: Optimized data structures with cleanup routines
|
173
|
+
- **High Throughput**: Thread-safe operations with minimal locking
|
174
|
+
- **Low Latency**: Multi-tier caching with intelligent invalidation
|
175
|
+
- **Scalable**: Distributed caching support with Redis/Memcached
|
176
|
+
|
177
|
+
### ๐ก๏ธ Security Features
|
178
|
+
|
179
|
+
- **Secure Defaults**: Conservative configuration out of the box
|
180
|
+
- **Input Validation**: Comprehensive validation of all inputs
|
181
|
+
- **Error Handling**: Secure error messages without information leakage
|
182
|
+
- **Cache Security**: Proper serialization and data isolation
|
183
|
+
- **Debug Safety**: No sensitive data in debug output
|
184
|
+
|
185
|
+
### ๐ Production Ready
|
186
|
+
|
187
|
+
This 1.0.0 release represents a production-ready JWT authentication middleware with:
|
188
|
+
|
189
|
+
- โ
**Battle-tested** architecture with comprehensive edge case handling
|
190
|
+
- โ
**High test coverage** ensuring reliability and stability
|
191
|
+
- โ
**Flexible configuration** supporting diverse deployment scenarios
|
192
|
+
- โ
**Performance optimized** with intelligent caching strategies
|
193
|
+
- โ
**Comprehensive documentation** for easy adoption and maintenance
|
194
|
+
- โ
**Active maintenance** with automated CI/CD and quality checks
|
195
|
+
|
196
|
+
---
|
197
|
+
|
198
|
+
**Migration Notes**: This is the initial release. No migration is required.
|
199
|
+
|
200
|
+
**Breaking Changes**: None (initial release).
|
201
|
+
|
202
|
+
**Deprecations**: None (initial release).
|
203
|
+
|
204
|
+
[1.0.0]: https://github.com/kanutocd/rack_jwt_aegis/releases/tag/v1.0.0
|