rack_jwt_aegis 0.0.0 โ†’ 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2d574fb0978ebcc27c003f09163d7485e04ff9af359fbfacaaae62bb04ed484
4
- data.tar.gz: d9569601beeb497265025ab704860aaa9bb35f88e94d929ad2561ffc0a5f225a
3
+ metadata.gz: 6bc9e89c08947641810cb3c0a5aef91c56554dcf44e593abc10cb7b75ebe6478
4
+ data.tar.gz: bcbd0711caf2bd74d65ede714cf4cf24eb016146fc69e20bfdf76a165d8a009c
5
5
  SHA512:
6
- metadata.gz: 876bbe061f88ba9258b0d7c766984a71e09bd4043352b00b57f760d7910e1cbc8786898346a37d3eba7d0e9ba2bfbc0c3e5d3b0a4b129c4bcfb404eb25c06c57
7
- data.tar.gz: 94717f98a46ca598112b76084568ae1cf10c17518ef2305d611a45e672cb5f413bff70254b65411d5dfdcbfc81e0251ba36a85f390d6173b17d24d8e1fcd902f
6
+ metadata.gz: 7d279d25565397a64e45be0b157a01e63ca7c8e688fd1bb3592649cef8a2037380f5c9c1ddad645ad46f2326d5cd8cc279661207371825d26fe0c6cc036dd272
7
+ data.tar.gz: fe7e42dc37a5dca3a4fe443fc14e0a64178994b20406471ab6139be4e0b8917a663bcc45d29a819749875a9ef4cecd7d85cd8e13ef9cf5b6054ace0be090d540
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,243 @@
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.1] - 2025-08-13
9
+
10
+ ### ๐Ÿ”ง Fixed
11
+
12
+ #### Code Quality & Maintenance
13
+
14
+ - **DRY Refactoring**: Eliminated duplicate `debug_log` method implementations by creating a shared `DebugLogger` module
15
+ - Created `lib/rack_jwt_aegis/debug_logger.rb` with consistent debug logging functionality
16
+ - Updated `Middleware` and `RbacManager` classes to include the shared module
17
+ - Improved code maintainability by centralizing debug logging logic
18
+ - Maintains all existing functionality and logging behavior
19
+ - **RBAC Cache Validation**: Enhanced wildcard permission validation in `validate_rbac_cache_format` to support `admin/*` patterns
20
+ - **JWT Payload Resolution**: Fixed JWT payload key resolution to handle string keys consistently across components
21
+ - **Test Coverage**: Maintained high test coverage (98.17% line coverage) after refactoring
22
+
23
+ #### Developer Experience
24
+
25
+ - **Consistent Logging**: Unified debug log format across all components with automatic timestamp formatting
26
+ - **Component Identification**: Automatic component name inference for better log traceability
27
+ - **Configurable Log Levels**: Support for info, warn, and error log levels with appropriate output streams
28
+
29
+ ### ๐Ÿ—๏ธ Technical Details
30
+
31
+ #### Architecture Improvements
32
+
33
+ - **Shared Module Pattern**: Introduced consistent module inclusion pattern for cross-cutting concerns
34
+ - **Code Organization**: Better separation of concerns with dedicated debug logging module
35
+ - **Maintainability**: Reduced code duplication from ~40 lines to a single shared implementation
36
+
37
+ #### Testing & Quality
38
+
39
+ - **Test Suite**: All 340 tests pass with 975 assertions
40
+ - **Coverage Maintained**: 98.17% line coverage, 92.83% branch coverage
41
+ - **RBAC Integration**: Verified all role-based authorization tests pass after refactoring
42
+ - **Zero Regression**: No functional changes, only structural improvements
43
+
44
+ ---
45
+
46
+ ## [1.0.0] - 2025-08-13
47
+
48
+ ### ๐ŸŽ‰ Initial Release
49
+
50
+ This is the first stable release of Rack JWT Aegis, a JWT authentication middleware for hierarchical multi-tenant Rack applications.
51
+
52
+ ### โœจ Added
53
+
54
+ #### Core Authentication Features
55
+
56
+ - **JWT Token Validation** with configurable algorithms (HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512)
57
+ - **Multi-Tenant Support** with 2-level hierarchy (Company-Group โ†’ Company, Organization โ†’ Department, etc.)
58
+ - **Subdomain-based Tenant Isolation** for top-level tenants
59
+ - **URL Pathname Slug Access Control** for sub-level tenants with regex pattern support
60
+ - **Configurable Path Exclusions** for public endpoints with flexible pattern matching
61
+ - **Custom Payload Validation** with user-defined validation logic
62
+ - **Request Context Access** with convenient helper methods for accessing JWT payload data
63
+
64
+ #### RBAC (Role-Based Access Control)
65
+
66
+ - **Fine-grained Permission System** with resource:method format (e.g., `users:get`, `reports:post`)
67
+ - **Wildcard Method Support** (e.g., `admin/*` for all methods)
68
+ - **Regex Pattern Matching** for dynamic resource paths (e.g., `%r{users/\d+}:put`)
69
+ - **Multi-tier Caching** for performance optimization
70
+ - **Cache Write Control** with zero-trust mode support
71
+ - **Permission Cache TTL** with configurable expiration
72
+ - **Debug Mode** with comprehensive logging
73
+
74
+ #### Caching System
75
+
76
+ - **Multiple Cache Adapters**:
77
+ - Memory adapter (built-in, thread-safe)
78
+ - Redis adapter with connection pooling
79
+ - Memcached adapter with Dalli integration
80
+ - SolidCache adapter for Rails 8+ applications
81
+ - **Intelligent Cache Invalidation** based on RBAC updates
82
+ - **Performance Optimization** with counter caches and eager loading
83
+ - **Error Handling** with graceful fallback and retry logic
84
+
85
+ #### CLI Tool
86
+
87
+ - **JWT Secret Generation** with multiple formats (plain, base64, environment variable)
88
+ - **Batch Secret Generation** for multiple environments
89
+ - **Secure Random Generation** using cryptographically secure methods
90
+
91
+ #### Configuration & Validation
92
+
93
+ - **Flexible Configuration** with sensible defaults
94
+ - **Multi-tenant Validation** with header-based and URL-based strategies
95
+ - **Custom Validation Hooks** for business-specific requirements
96
+ - **Debug Mode** for development and troubleshooting
97
+
98
+ #### Developer Experience
99
+
100
+ - **Comprehensive Documentation** with YARD-generated API docs
101
+ - **GitHub Pages Integration** with automatic deployment
102
+ - **High Test Coverage** (97.8% line coverage, 86.6% branch coverage)
103
+ - **RuboCop Integration** with style enforcement
104
+ - **Code Examples** for common use cases
105
+
106
+ ### ๐Ÿ—๏ธ Technical Implementation
107
+
108
+ #### Architecture
109
+
110
+ - **Modular Design** with clear separation of concerns
111
+ - **Rack Middleware** integration for framework independence
112
+ - **Thread-safe Operations** for concurrent request handling
113
+ - **Memory Efficient** with optimized data structures
114
+ - **Error Boundary** with proper exception handling
115
+
116
+ #### Testing & Quality
117
+
118
+ - **Comprehensive Test Suite** with Minitest framework
119
+ - **Mock Integration** with Mocha for reliable testing
120
+ - **Cache Adapter Testing** with actual Redis and Dalli gems
121
+ - **Edge Case Coverage** for error handling and validation paths
122
+ - **Performance Testing** for cache operations and memory usage
123
+
124
+ #### Documentation & Workflows
125
+
126
+ - **GitHub Actions CI/CD** with multi-Ruby version testing
127
+ - **Automated Documentation Deployment** to GitHub Pages
128
+ - **Workflow Dispatch** for manual deployments
129
+ - **Coverage Reporting** with SimpleCov integration
130
+ - **Code Quality Checks** with RuboCop and documentation coverage
131
+
132
+ ### ๐Ÿ”ง Configuration Examples
133
+
134
+ #### Basic JWT Authentication
135
+
136
+ ```ruby
137
+ use RackJwtAegis::Middleware, {
138
+ jwt_secret: ENV['JWT_SECRET'],
139
+ jwt_algorithm: 'HS256'
140
+ }
141
+ ```
142
+
143
+ #### Multi-tenant with RBAC
144
+
145
+ ```ruby
146
+ use RackJwtAegis::Middleware, {
147
+ jwt_secret: ENV['JWT_SECRET'],
148
+ multi_tenant_enabled: true,
149
+ subdomain_validation_enabled: true,
150
+ rbac_enabled: true,
151
+ rbac_cache_store: :redis,
152
+ debug_mode: Rails.env.development?
153
+ }
154
+ ```
155
+
156
+ #### Enterprise Configuration
157
+
158
+ ```ruby
159
+ use RackJwtAegis::Middleware, {
160
+ jwt_secret: ENV['JWT_SECRET'],
161
+ jwt_algorithm: 'RS256',
162
+ multi_tenant_enabled: true,
163
+ subdomain_validation_enabled: true,
164
+ pathname_slug_pattern: /^\/api\/v1\/([^\/]+)\//,
165
+ rbac_enabled: true,
166
+ rbac_cache_store: :redis,
167
+ permission_cache_store: :memory,
168
+ user_permissions_ttl: 300,
169
+ cache_write_enabled: true,
170
+ skip_paths: [/^\/health/, /^\/metrics/, /^\/api\/public/],
171
+ custom_payload_validation: ->(payload) { payload['active'] == true },
172
+ debug_mode: false
173
+ }
174
+ ```
175
+
176
+ ### ๐Ÿ“š Documentation
177
+
178
+ - **Online Documentation**: Auto-deployed to GitHub Pages
179
+ - **API Reference**: Complete YARD documentation for all classes and methods
180
+ - **Usage Examples**: Comprehensive examples for all features
181
+ - **Architecture Decisions**: ADRs documenting design choices
182
+ - **Integration Guides**: Framework-specific integration examples
183
+
184
+ ### ๐Ÿงช Testing Coverage
185
+
186
+ - **Line Coverage**: 97.8% (668/683 lines)
187
+ - **Branch Coverage**: 86.6% (259/299 branches)
188
+ - **Test Files**: 15 comprehensive test suites
189
+ - **Test Cases**: 323+ individual test cases
190
+ - **Cache Integration**: Tests with actual Redis and Dalli gems
191
+
192
+ ### ๐Ÿ”— Dependencies
193
+
194
+ #### Core Dependencies
195
+
196
+ - `rack` (~> 3.0)
197
+ - `jwt` (~> 2.8)
198
+
199
+ #### Development Dependencies
200
+
201
+ - `redis` (~> 5.0) - For Redis cache adapter testing
202
+ - `dalli` (~> 3.0) - For Memcached cache adapter testing
203
+ - `minitest` (~> 5.25) - Test framework
204
+ - `mocha` (~> 2.7) - Mocking library
205
+ - `simplecov` (~> 0.22.0) - Coverage reporting
206
+ - `yard` (~> 0.9.37) - Documentation generation
207
+
208
+ ### ๐Ÿ† Performance Characteristics
209
+
210
+ - **Memory Efficient**: Optimized data structures with cleanup routines
211
+ - **High Throughput**: Thread-safe operations with minimal locking
212
+ - **Low Latency**: Multi-tier caching with intelligent invalidation
213
+ - **Scalable**: Distributed caching support with Redis/Memcached
214
+
215
+ ### ๐Ÿ›ก๏ธ Security Features
216
+
217
+ - **Secure Defaults**: Conservative configuration out of the box
218
+ - **Input Validation**: Comprehensive validation of all inputs
219
+ - **Error Handling**: Secure error messages without information leakage
220
+ - **Cache Security**: Proper serialization and data isolation
221
+ - **Debug Safety**: No sensitive data in debug output
222
+
223
+ ### ๐ŸŒŸ Production Ready
224
+
225
+ This 1.0.0 release represents a production-ready JWT authentication middleware with:
226
+
227
+ - โœ… **Battle-tested** architecture with comprehensive edge case handling
228
+ - โœ… **High test coverage** ensuring reliability and stability
229
+ - โœ… **Flexible configuration** supporting diverse deployment scenarios
230
+ - โœ… **Performance optimized** with intelligent caching strategies
231
+ - โœ… **Comprehensive documentation** for easy adoption and maintenance
232
+ - โœ… **Active maintenance** with automated CI/CD and quality checks
233
+
234
+ ---
235
+
236
+ **Migration Notes**: This is the initial release. No migration is required.
237
+
238
+ **Breaking Changes**: None (initial release).
239
+
240
+ **Deprecations**: None (initial release).
241
+
242
+ [1.0.1]: https://github.com/kanutocd/rack_jwt_aegis/releases/tag/v1.0.1
243
+ [1.0.0]: https://github.com/kanutocd/rack_jwt_aegis/releases/tag/v1.0.0