otto 2.0.0.pre8 → 2.0.0.pre9
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/ci.yml +1 -1
- data/.github/workflows/claude-code-review.yml +1 -1
- data/.github/workflows/claude.yml +1 -1
- data/.github/workflows/code-smells.yml +2 -2
- data/CHANGELOG.rst +54 -35
- data/Gemfile.lock +6 -6
- data/README.md +20 -0
- data/docs/.gitignore +2 -0
- data/docs/modern-authentication-authorization-landscape.md +558 -0
- data/docs/multi-strategy-authentication-design.md +1401 -0
- data/lib/otto/core/error_handler.rb +19 -8
- data/lib/otto/core/freezable.rb +0 -2
- data/lib/otto/core/middleware_stack.rb +12 -8
- data/lib/otto/core/router.rb +25 -31
- data/lib/otto/errors.rb +92 -0
- data/lib/otto/mcp/rate_limiting.rb +6 -2
- data/lib/otto/mcp/schema_validation.rb +1 -1
- data/lib/otto/response_handlers/json.rb +1 -3
- data/lib/otto/response_handlers/view.rb +1 -1
- data/lib/otto/route_handlers/base.rb +86 -1
- data/lib/otto/route_handlers/class_method.rb +9 -67
- data/lib/otto/route_handlers/instance_method.rb +10 -57
- data/lib/otto/route_handlers/logic_class.rb +85 -90
- data/lib/otto/security/authentication/auth_strategy.rb +2 -2
- data/lib/otto/security/authentication/strategy_result.rb +9 -9
- data/lib/otto/security/authorization_error.rb +1 -1
- data/lib/otto/security/config.rb +3 -3
- data/lib/otto/security/rate_limiter.rb +7 -3
- data/lib/otto/version.rb +1 -1
- data/lib/otto.rb +47 -3
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a99ac23967768247096e9bb9664a9efcc0452ea485496389ff3909209fd12d6c
|
|
4
|
+
data.tar.gz: 209178d26d3b46ddade717d471c8b10755ea6e79a43b8522a5f1d10dfca3d935
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d7a07ad3b7b22dbae59038b9edaf26f5db11f041ae808e3c9430a862956a6e874c47afeae3731f1eff7cb065cb38c125c688ea54900e745288d2e17c4462416
|
|
7
|
+
data.tar.gz: 42867d3c6a0d1eb17c440e9b854c826abf5bc0c48b72fa5e76053b00926972a9ba18586f5fbb71f85cb6e5e54426e2c25fff30d77c865fcc21a0e24ab88233de
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -21,7 +21,7 @@ jobs:
|
|
|
21
21
|
|
|
22
22
|
steps:
|
|
23
23
|
- name: Checkout code
|
|
24
|
-
uses: actions/checkout@
|
|
24
|
+
uses: actions/checkout@v6
|
|
25
25
|
|
|
26
26
|
- name: Set up Ruby
|
|
27
27
|
uses: ruby/setup-ruby@v1
|
|
@@ -88,7 +88,7 @@ jobs:
|
|
|
88
88
|
|
|
89
89
|
steps:
|
|
90
90
|
- name: Checkout code
|
|
91
|
-
uses: actions/checkout@
|
|
91
|
+
uses: actions/checkout@v6
|
|
92
92
|
|
|
93
93
|
- name: Set up Ruby
|
|
94
94
|
uses: ruby/setup-ruby@v1
|
data/CHANGELOG.rst
CHANGED
|
@@ -7,6 +7,48 @@ The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.1.0/>`
|
|
|
7
7
|
|
|
8
8
|
<!--scriv-insert-here-->
|
|
9
9
|
|
|
10
|
+
.. _changelog-2.0.0.pre9:
|
|
11
|
+
|
|
12
|
+
2.0.0.pre9 — 2025-12-06
|
|
13
|
+
=======================
|
|
14
|
+
|
|
15
|
+
Added
|
|
16
|
+
-----
|
|
17
|
+
|
|
18
|
+
- Base HTTP error classes (``Otto::NotFoundError``, ``Otto::BadRequestError``, ``Otto::ForbiddenError``, ``Otto::UnauthorizedError``, ``Otto::PayloadTooLargeError``) that implementing projects can subclass for consistent error handling
|
|
19
|
+
- Auto-registration of all framework error classes during ``Otto#initialize`` - framework errors now automatically return correct HTTP status codes without manual registration
|
|
20
|
+
|
|
21
|
+
Changed
|
|
22
|
+
-------
|
|
23
|
+
|
|
24
|
+
- Framework error classes now inherit from new base classes: ``Otto::Security::AuthorizationError`` < ``Otto::ForbiddenError``, ``Otto::Security::CSRFError`` < ``Otto::ForbiddenError``, ``Otto::Security::RequestTooLargeError`` < ``Otto::PayloadTooLargeError``, ``Otto::Security::ValidationError`` < ``Otto::BadRequestError``, ``Otto::MCP::ValidationError`` < ``Otto::BadRequestError``
|
|
25
|
+
- ``Otto::Security::RequestTooLargeError`` now returns HTTP 413 (Payload Too Large) instead of 500, semantically correct per RFC 7231
|
|
26
|
+
|
|
27
|
+
- Consolidated route handler implementation using Template Method pattern, reducing duplication by ~120 lines while improving maintainability
|
|
28
|
+
|
|
29
|
+
Fixed
|
|
30
|
+
-----
|
|
31
|
+
|
|
32
|
+
- Error handlers now respect route's ``response=json`` parameter for content
|
|
33
|
+
negotiation, ensuring API routes always return JSON error responses regardless
|
|
34
|
+
of the Accept header.
|
|
35
|
+
|
|
36
|
+
- Rate limiters now respect route ``response=json`` declarations when returning
|
|
37
|
+
throttled responses, matching the error handler fix for consistent content
|
|
38
|
+
negotiation across all error paths.
|
|
39
|
+
|
|
40
|
+
- ClassMethodHandler direct testing context now respects route ``response_type``
|
|
41
|
+
when generating error responses.
|
|
42
|
+
|
|
43
|
+
- Unified error handling across ClassMethodHandler and InstanceMethodHandler to consistently support JSON content negotiation
|
|
44
|
+
|
|
45
|
+
AI Assistance
|
|
46
|
+
-------------
|
|
47
|
+
|
|
48
|
+
- Implementation design and architecture developed with AI pair programming
|
|
49
|
+
- Comprehensive test coverage (31 new base class tests, 12 auto-registration tests) developed with AI assistance
|
|
50
|
+
- Error class hierarchy and inheritance patterns refined through AI-guided architectural discussion
|
|
51
|
+
|
|
10
52
|
.. _changelog-2.0.0.pre8:
|
|
11
53
|
|
|
12
54
|
2.0.0.pre8 — 2025-11-27
|
|
@@ -25,53 +67,30 @@ Fixed
|
|
|
25
67
|
Added
|
|
26
68
|
-----
|
|
27
69
|
|
|
28
|
-
- Error handler registration system for expected business logic errors
|
|
70
|
+
- Error handler registration system for expected business logic errors via ``otto.register_error_handler(ErrorClass, status:, log_level:)``. Supports custom response handlers via blocks.
|
|
29
71
|
|
|
30
72
|
Changed
|
|
31
73
|
-------
|
|
32
74
|
|
|
33
|
-
- Backtrace logging now always logs at ERROR level
|
|
34
|
-
- Increased backtrace limit from 10 to 20 lines for
|
|
35
|
-
|
|
36
|
-
AI Assistance
|
|
37
|
-
-------------
|
|
38
|
-
|
|
39
|
-
- Implemented error handler registration architecture with comprehensive test coverage (17 test cases) using sequential thinking to work through security implications and design decisions. AI assisted with path sanitization strategy, error classification patterns, and ensuring backward compatibility with existing error handling.
|
|
40
|
-
|
|
41
|
-
Improved backtrace sanitization security and readability
|
|
42
|
-
--------------------------------------------------------
|
|
43
|
-
|
|
44
|
-
**Security Enhancements:**
|
|
75
|
+
- Backtrace logging now always logs at ERROR level with sanitized file paths (was DEBUG level with full paths)
|
|
76
|
+
- Increased backtrace limit from 10 to 20 lines for better debugging context
|
|
77
|
+
- Improved gem path formatting in backtraces (e.g., ``[GEM] rack/lib/rack.rb:20``)
|
|
45
78
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- Strips git hash suffixes from bundler gems (``otto-abc123def456`` → ``otto``)
|
|
49
|
-
- Removes version numbers from regular gems (``rack-3.2.4`` → ``rack``)
|
|
50
|
-
- Prevents exposure of absolute paths, usernames, and project names in logs
|
|
51
|
-
|
|
52
|
-
**Improvements:**
|
|
79
|
+
Fixed
|
|
80
|
+
-----
|
|
53
81
|
|
|
54
|
-
-
|
|
55
|
-
- Regular gems show cleaner output: ``[GEM] rack/lib/rack.rb:20`` instead of ``[GEM] rack-3.2.4/lib/rack.rb:20``
|
|
56
|
-
- Multi-hyphenated gem names handled correctly (``active-record-import-1.5.0`` → ``active-record-import``)
|
|
57
|
-
- Better handling of version-only directory names in gem paths
|
|
82
|
+
- Fixed path sanitization for bundler git-based gems and multi-hyphenated gem names
|
|
58
83
|
|
|
59
|
-
|
|
84
|
+
Documentation
|
|
85
|
+
-------------
|
|
60
86
|
|
|
61
|
-
- Added comprehensive backtrace sanitization section to CLAUDE.md
|
|
62
87
|
- Documented security guarantees and sanitization rules
|
|
63
88
|
- Added examples showing before/after path transformations
|
|
64
|
-
- Created comprehensive test suite for backtrace sanitization
|
|
65
89
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Raw backtraces expose sensitive information:
|
|
69
|
-
- Usernames (``/Users/alice/``, ``/home/admin/``)
|
|
70
|
-
- Project structure and internal organization
|
|
71
|
-
- Gem installation paths and Ruby versions
|
|
72
|
-
- System architecture details
|
|
90
|
+
AI Assistance
|
|
91
|
+
-------------
|
|
73
92
|
|
|
74
|
-
|
|
93
|
+
- Implemented error handler registration architecture with comprehensive test coverage (17 test cases) using sequential thinking to work through security implications and design decisions. AI assisted with path sanitization strategy, error classification patterns, and ensuring backward compatibility with existing error handling.
|
|
75
94
|
|
|
76
95
|
.. _changelog-2.0.0.pre6:
|
|
77
96
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
otto (2.0.0.
|
|
4
|
+
otto (2.0.0.pre9)
|
|
5
5
|
concurrent-ruby (~> 1.3, < 2.0)
|
|
6
6
|
facets (~> 3.1)
|
|
7
7
|
ipaddr (~> 1, < 2.0)
|
|
@@ -62,7 +62,7 @@ GEM
|
|
|
62
62
|
pp (>= 0.6.0)
|
|
63
63
|
rdoc (>= 4.0.0)
|
|
64
64
|
reline (>= 0.4.2)
|
|
65
|
-
json (2.
|
|
65
|
+
json (2.16.0)
|
|
66
66
|
json_schemer (2.4.0)
|
|
67
67
|
bigdecimal
|
|
68
68
|
hana (~> 1.3)
|
|
@@ -156,21 +156,21 @@ GEM
|
|
|
156
156
|
rubocop-ast (>= 1.47.1, < 2.0)
|
|
157
157
|
ruby-progressbar (~> 1.7)
|
|
158
158
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
159
|
-
rubocop-ast (1.
|
|
159
|
+
rubocop-ast (1.48.0)
|
|
160
160
|
parser (>= 3.3.7.2)
|
|
161
161
|
prism (~> 1.4)
|
|
162
162
|
rubocop-performance (1.26.1)
|
|
163
163
|
lint_roller (~> 1.1)
|
|
164
164
|
rubocop (>= 1.75.0, < 2.0)
|
|
165
165
|
rubocop-ast (>= 1.47.1, < 2.0)
|
|
166
|
-
rubocop-rspec (3.
|
|
166
|
+
rubocop-rspec (3.8.0)
|
|
167
167
|
lint_roller (~> 1.1)
|
|
168
|
-
rubocop (~> 1.
|
|
168
|
+
rubocop (~> 1.81)
|
|
169
169
|
rubocop-thread_safety (0.7.3)
|
|
170
170
|
lint_roller (~> 1.1)
|
|
171
171
|
rubocop (~> 1.72, >= 1.72.1)
|
|
172
172
|
rubocop-ast (>= 1.44.0, < 2.0)
|
|
173
|
-
ruby-lsp (0.26.
|
|
173
|
+
ruby-lsp (0.26.4)
|
|
174
174
|
language_server-protocol (~> 3.17.0)
|
|
175
175
|
prism (>= 1.2, < 2.0)
|
|
176
176
|
rbs (>= 3, < 5)
|
data/README.md
CHANGED
|
@@ -84,6 +84,26 @@ app = Otto.new("./routes", {
|
|
|
84
84
|
|
|
85
85
|
Security features include CSRF protection, input validation, security headers, and trusted proxy configuration.
|
|
86
86
|
|
|
87
|
+
## Error Handling
|
|
88
|
+
|
|
89
|
+
Otto provides base error classes that automatically return correct HTTP status codes:
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
# Use built-in error classes directly
|
|
93
|
+
raise Otto::NotFoundError, "Product not found" # Returns 404
|
|
94
|
+
raise Otto::BadRequestError, "Invalid parameter" # Returns 400
|
|
95
|
+
raise Otto::UnauthorizedError, "Login required" # Returns 401
|
|
96
|
+
raise Otto::ForbiddenError, "Access denied" # Returns 403
|
|
97
|
+
|
|
98
|
+
# Or subclass them for your application
|
|
99
|
+
class MyApp::ResourceNotFound < Otto::NotFoundError; end
|
|
100
|
+
|
|
101
|
+
# Optionally customize status or logging (overrides auto-registration)
|
|
102
|
+
app.register_error_handler(MyApp::ResourceNotFound, status: 410, log_level: :warn)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
All framework errors are auto-registered during initialization. No manual registration required unless you want custom behavior.
|
|
106
|
+
|
|
87
107
|
## Privacy by Default
|
|
88
108
|
|
|
89
109
|
Otto automatically masks public IP addresses and anonymizes user agents to comply with GDPR, CCPA, and other privacy regulations:
|