otto 1.5.0 → 2.0.0.pre1
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 +44 -5
- data/.github/workflows/claude-code-review.yml +53 -0
- data/.github/workflows/claude.yml +49 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +24 -345
- data/CHANGELOG.rst +83 -0
- data/CLAUDE.md +56 -0
- data/Gemfile +21 -5
- data/Gemfile.lock +69 -31
- data/README.md +2 -0
- data/bin/rspec +16 -0
- data/changelog.d/20250911_235619_delano_next.rst +28 -0
- data/changelog.d/20250912_123055_delano_remove_ostruct.rst +21 -0
- data/changelog.d/20250912_175625_claude_delano_remove_ostruct.rst +21 -0
- data/changelog.d/README.md +120 -0
- data/changelog.d/scriv.ini +5 -0
- data/docs/.gitignore +1 -0
- data/docs/migrating/v2.0.0-pre1.md +276 -0
- data/examples/.gitignore +1 -0
- data/examples/advanced_routes/README.md +33 -0
- data/examples/advanced_routes/app/controllers/handlers/async.rb +9 -0
- data/examples/advanced_routes/app/controllers/handlers/dynamic.rb +9 -0
- data/examples/advanced_routes/app/controllers/handlers/static.rb +9 -0
- data/examples/advanced_routes/app/controllers/modules/auth.rb +9 -0
- data/examples/advanced_routes/app/controllers/modules/transformer.rb +9 -0
- data/examples/advanced_routes/app/controllers/modules/validator.rb +9 -0
- data/examples/advanced_routes/app/controllers/routes_app.rb +232 -0
- data/examples/advanced_routes/app/controllers/v2/admin.rb +9 -0
- data/examples/advanced_routes/app/controllers/v2/config.rb +9 -0
- data/examples/advanced_routes/app/controllers/v2/settings.rb +9 -0
- data/examples/advanced_routes/app/logic/admin/logic/manager.rb +27 -0
- data/examples/advanced_routes/app/logic/admin/panel.rb +27 -0
- data/examples/advanced_routes/app/logic/analytics_processor.rb +25 -0
- data/examples/advanced_routes/app/logic/complex/business/handler.rb +27 -0
- data/examples/advanced_routes/app/logic/data_logic.rb +23 -0
- data/examples/advanced_routes/app/logic/data_processor.rb +25 -0
- data/examples/advanced_routes/app/logic/input_validator.rb +24 -0
- data/examples/advanced_routes/app/logic/nested/feature/logic.rb +27 -0
- data/examples/advanced_routes/app/logic/reports_generator.rb +27 -0
- data/examples/advanced_routes/app/logic/simple_logic.rb +25 -0
- data/examples/advanced_routes/app/logic/system/config/manager.rb +27 -0
- data/examples/advanced_routes/app/logic/test_logic.rb +23 -0
- data/examples/advanced_routes/app/logic/transform_logic.rb +23 -0
- data/examples/advanced_routes/app/logic/upload_logic.rb +23 -0
- data/examples/advanced_routes/app/logic/v2/logic/dashboard.rb +27 -0
- data/examples/advanced_routes/app/logic/v2/logic/processor.rb +27 -0
- data/examples/advanced_routes/app.rb +33 -0
- data/examples/advanced_routes/config.rb +23 -0
- data/examples/advanced_routes/config.ru +7 -0
- data/examples/advanced_routes/puma.rb +20 -0
- data/examples/advanced_routes/routes +167 -0
- data/examples/advanced_routes/run.rb +39 -0
- data/examples/advanced_routes/test.rb +58 -0
- data/examples/authentication_strategies/README.md +32 -0
- data/examples/authentication_strategies/app/auth.rb +68 -0
- data/examples/authentication_strategies/app/controllers/auth_controller.rb +29 -0
- data/examples/authentication_strategies/app/controllers/main_controller.rb +28 -0
- data/examples/authentication_strategies/config.ru +24 -0
- data/examples/authentication_strategies/routes +37 -0
- data/examples/basic/README.md +29 -0
- data/examples/basic/app.rb +7 -35
- data/examples/basic/routes +0 -9
- data/examples/mcp_demo/README.md +87 -0
- data/examples/mcp_demo/app.rb +51 -0
- data/examples/mcp_demo/config.ru +17 -0
- data/examples/mcp_demo/routes +9 -0
- data/examples/security_features/README.md +46 -0
- data/examples/security_features/app.rb +23 -24
- data/examples/security_features/config.ru +8 -10
- data/lib/otto/core/configuration.rb +167 -0
- data/lib/otto/core/error_handler.rb +86 -0
- data/lib/otto/core/file_safety.rb +61 -0
- data/lib/otto/core/middleware_stack.rb +157 -0
- data/lib/otto/core/router.rb +183 -0
- data/lib/otto/core/uri_generator.rb +44 -0
- data/lib/otto/design_system.rb +7 -5
- data/lib/otto/helpers/base.rb +3 -0
- data/lib/otto/helpers/request.rb +10 -8
- data/lib/otto/helpers/response.rb +5 -4
- data/lib/otto/helpers/validation.rb +85 -0
- data/lib/otto/mcp/auth/token.rb +77 -0
- data/lib/otto/mcp/protocol.rb +164 -0
- data/lib/otto/mcp/rate_limiting.rb +155 -0
- data/lib/otto/mcp/registry.rb +100 -0
- data/lib/otto/mcp/route_parser.rb +77 -0
- data/lib/otto/mcp/server.rb +206 -0
- data/lib/otto/mcp/validation.rb +123 -0
- data/lib/otto/response_handlers/auto.rb +39 -0
- data/lib/otto/response_handlers/base.rb +16 -0
- data/lib/otto/response_handlers/default.rb +16 -0
- data/lib/otto/response_handlers/factory.rb +39 -0
- data/lib/otto/response_handlers/json.rb +28 -0
- data/lib/otto/response_handlers/redirect.rb +25 -0
- data/lib/otto/response_handlers/view.rb +24 -0
- data/lib/otto/response_handlers.rb +9 -135
- data/lib/otto/route.rb +9 -9
- data/lib/otto/route_definition.rb +30 -33
- data/lib/otto/route_handlers/base.rb +121 -0
- data/lib/otto/route_handlers/class_method.rb +89 -0
- data/lib/otto/route_handlers/factory.rb +29 -0
- data/lib/otto/route_handlers/instance_method.rb +69 -0
- data/lib/otto/route_handlers/lambda.rb +59 -0
- data/lib/otto/route_handlers/logic_class.rb +93 -0
- data/lib/otto/route_handlers.rb +10 -376
- data/lib/otto/security/authentication/auth_strategy.rb +44 -0
- data/lib/otto/security/authentication/authentication_middleware.rb +123 -0
- data/lib/otto/security/authentication/failure_result.rb +36 -0
- data/lib/otto/security/authentication/strategies/api_key_strategy.rb +40 -0
- data/lib/otto/security/authentication/strategies/permission_strategy.rb +47 -0
- data/lib/otto/security/authentication/strategies/public_strategy.rb +19 -0
- data/lib/otto/security/authentication/strategies/role_strategy.rb +57 -0
- data/lib/otto/security/authentication/strategies/session_strategy.rb +41 -0
- data/lib/otto/security/authentication/strategy_result.rb +223 -0
- data/lib/otto/security/authentication.rb +28 -282
- data/lib/otto/security/config.rb +15 -11
- data/lib/otto/security/configurator.rb +219 -0
- data/lib/otto/security/csrf.rb +8 -143
- data/lib/otto/security/middleware/csrf_middleware.rb +151 -0
- data/lib/otto/security/middleware/rate_limit_middleware.rb +38 -0
- data/lib/otto/security/middleware/validation_middleware.rb +252 -0
- data/lib/otto/security/rate_limiter.rb +86 -0
- data/lib/otto/security/rate_limiting.rb +16 -0
- data/lib/otto/security/validator.rb +8 -292
- data/lib/otto/static.rb +3 -0
- data/lib/otto/utils.rb +14 -0
- data/lib/otto/version.rb +3 -1
- data/lib/otto.rb +184 -414
- data/otto.gemspec +11 -6
- metadata +134 -25
- data/examples/dynamic_pages/app.rb +0 -115
- data/examples/dynamic_pages/config.ru +0 -30
- data/examples/dynamic_pages/routes +0 -21
- data/examples/helpers_demo/app.rb +0 -244
- data/examples/helpers_demo/config.ru +0 -26
- data/examples/helpers_demo/routes +0 -7
data/CHANGELOG.rst
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
CHANGELOG.rst
|
2
|
+
=============
|
3
|
+
|
4
|
+
All notable changes to Otto are documented here.
|
5
|
+
|
6
|
+
The format is based on `Keep a
|
7
|
+
Changelog <https://keepachangelog.com/en/1.1.0/>`__, and this project
|
8
|
+
adheres to `Semantic
|
9
|
+
Versioning <https://semver.org/spec/v2.0.0.html>`__.
|
10
|
+
|
11
|
+
.. raw:: html
|
12
|
+
|
13
|
+
<!--scriv-insert-here-->
|
14
|
+
|
15
|
+
.. _changelog-2.0.0-pre1:
|
16
|
+
|
17
|
+
2.0.0-pre1 — 2025-09-10
|
18
|
+
=======================
|
19
|
+
|
20
|
+
Added
|
21
|
+
-----
|
22
|
+
|
23
|
+
- Comprehensive test coverage for error handling methods (handle_error, secure_error_response,
|
24
|
+
json_error_response)
|
25
|
+
- Test coverage for private configuration methods (configure_locale, configure_security,
|
26
|
+
configure_authentication, configure_mcp)
|
27
|
+
- Expanded MCP functionality test coverage including route parsing and server initialization
|
28
|
+
- Security header validation in all error responses
|
29
|
+
- Content negotiation testing for JSON vs plain text error responses
|
30
|
+
- Development vs production mode error handling verification
|
31
|
+
|
32
|
+
- ``Otto::Security::Configurator`` class for consolidated security configuration
|
33
|
+
- ``Otto::Core::MiddlewareStack`` class for enhanced middleware management
|
34
|
+
- Unified ``security.configure()`` method for streamlined security setup
|
35
|
+
- Middleware introspection capabilities via ``middleware_list`` and ``middleware_details`` methods
|
36
|
+
|
37
|
+
Changed
|
38
|
+
-------
|
39
|
+
|
40
|
+
- **BREAKING**: Direct middleware_stack manipulation no longer supported. Use ``otto.use()`` instead
|
41
|
+
of ``otto.middleware_stack <<``. See `migration guide <docs/migrating/v2.0.0-pre1.md>`__ for upgrade
|
42
|
+
path.
|
43
|
+
|
44
|
+
- Refactored main Otto class from 767 lines to 348 lines using composition pattern (#29)
|
45
|
+
- Modernized initialization method with helper functions while maintaining backward compatibility
|
46
|
+
- Applied Ruby 3.2+ features including pattern matching and anonymous block forwarding
|
47
|
+
- Improved method organization and separation of concerns
|
48
|
+
|
49
|
+
- Refactored security configuration methods to use new ``Otto::Security::Configurator`` facade
|
50
|
+
- Enhanced middleware stack management with better registration and execution interfaces
|
51
|
+
- Improved separation of concerns between security configuration and middleware handling
|
52
|
+
|
53
|
+
- Unified middleware stack implementation for improved performance and consistency
|
54
|
+
- Optimized middleware lookup and registration with O(1) Set-based tracking
|
55
|
+
- Memoized middleware list to reduce array creation overhead
|
56
|
+
- Improved middleware registration to handle varied argument scenarios
|
57
|
+
|
58
|
+
Documentation
|
59
|
+
-------------
|
60
|
+
|
61
|
+
- Added changelog management system with Scriv configuration
|
62
|
+
- Created comprehensive changelog process documentation
|
63
|
+
|
64
|
+
AI Assistance
|
65
|
+
-------------
|
66
|
+
|
67
|
+
- Comprehensive test suite development covering 76 new test cases across 3 test files
|
68
|
+
- Error handling analysis and edge case identification
|
69
|
+
- Configuration method testing strategy development
|
70
|
+
- MCP functionality testing with proper mocking and stubbing techniques
|
71
|
+
- Test quality assurance ensuring all 460 examples pass with 0 failures
|
72
|
+
|
73
|
+
- Extracted core Otto class functionality into 5 focused modules (Router, FileSafety, Configuration,
|
74
|
+
ErrorHandler, UriGenerator) using composition pattern for improved maintainability while preserving
|
75
|
+
complete API backward compatibility (#28)
|
76
|
+
|
77
|
+
- Comprehensive refactoring implementation developed with AI assistance
|
78
|
+
- Systematic approach to maintaining backward compatibility during modernization
|
79
|
+
- Full test suite validation ensuring zero breaking changes across 460 test cases
|
80
|
+
|
81
|
+
- Comprehensive refactoring of middleware stack management
|
82
|
+
- Performance optimization and code quality improvements
|
83
|
+
- Developed detailed migration guide for smooth transition
|
data/CLAUDE.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# CLAUDE.md
|
2
|
+
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
4
|
+
|
5
|
+
## Development Commands
|
6
|
+
|
7
|
+
### Setup
|
8
|
+
```bash
|
9
|
+
# Install development and test dependencies
|
10
|
+
bundle config set with 'development test'
|
11
|
+
bundle install
|
12
|
+
|
13
|
+
# Lint code
|
14
|
+
bundle exec rubocop
|
15
|
+
|
16
|
+
# Run tests
|
17
|
+
bundle exec rspec
|
18
|
+
|
19
|
+
# Run a specific test
|
20
|
+
bundle exec rspec spec/path/to/specific_spec.rb
|
21
|
+
# rspec settings in .rspec
|
22
|
+
```
|
23
|
+
|
24
|
+
## Project Overview
|
25
|
+
|
26
|
+
### Core Components
|
27
|
+
- Ruby Rack-based web framework for defining web applications
|
28
|
+
- Focuses on security and simplicity
|
29
|
+
- Supports internationalization and optional security features
|
30
|
+
|
31
|
+
### Key Features
|
32
|
+
- Plain-text routes configuration
|
33
|
+
- Automatic locale detection
|
34
|
+
- Optional security features:
|
35
|
+
- CSRF protection
|
36
|
+
- Input validation
|
37
|
+
- Security headers
|
38
|
+
- Trusted proxy configuration
|
39
|
+
|
40
|
+
### Test Frameworks
|
41
|
+
- RSpec for unit and integration testing
|
42
|
+
- Tryouts for behavior-driven testing
|
43
|
+
|
44
|
+
### Development Tools
|
45
|
+
- Rubocop for linting
|
46
|
+
- Debug gem for debugging
|
47
|
+
- Tryouts for alternative testing approach
|
48
|
+
|
49
|
+
### Ruby Version Requirements
|
50
|
+
- Ruby 3.2+
|
51
|
+
- Rack 3.1+
|
52
|
+
|
53
|
+
### Important Notes
|
54
|
+
- Always validate and sanitize user inputs
|
55
|
+
- Leverage built-in security features
|
56
|
+
- Use locale helpers for internationalization support
|
data/Gemfile
CHANGED
@@ -1,14 +1,30 @@
|
|
1
|
+
# Gemfile
|
2
|
+
|
3
|
+
# To install all development and test dependencies:
|
4
|
+
#
|
5
|
+
# $ bundle config set with 'development test'
|
6
|
+
# $ bundle install
|
7
|
+
|
1
8
|
source 'https://rubygems.org'
|
2
9
|
|
3
10
|
gemspec
|
4
11
|
|
5
|
-
|
12
|
+
gem 'rackup'
|
13
|
+
|
14
|
+
group :test do
|
6
15
|
gem 'rack-test'
|
7
|
-
gem 'rspec', '~> 3.
|
16
|
+
gem 'rspec', '~> 3.13'
|
17
|
+
end
|
18
|
+
|
19
|
+
# bundle config set with 'optional'
|
20
|
+
group :development, :test, optional: true do
|
21
|
+
# Keep gems that need to be in both environments
|
22
|
+
gem 'json_schemer'
|
23
|
+
gem 'rack-attack'
|
8
24
|
end
|
9
25
|
|
10
|
-
group
|
11
|
-
gem '
|
26
|
+
group :development do
|
27
|
+
gem 'debug'
|
12
28
|
gem 'rubocop', require: false
|
13
29
|
gem 'rubocop-performance', require: false
|
14
30
|
gem 'rubocop-rspec', require: false
|
@@ -16,5 +32,5 @@ group 'development' do
|
|
16
32
|
gem 'ruby-lsp', require: false
|
17
33
|
gem 'stackprof', require: false
|
18
34
|
gem 'syntax_tree', require: false
|
19
|
-
gem 'tryouts', '~> 3.
|
35
|
+
gem 'tryouts', '~> 3.6.0', require: false
|
20
36
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
otto (
|
5
|
-
|
4
|
+
otto (2.0.0.pre.pre1)
|
5
|
+
facets (~> 3.1)
|
6
|
+
loofah (~> 2.20)
|
6
7
|
rack (~> 3.1, < 4.0)
|
7
8
|
rack-parser (~> 0.7)
|
8
9
|
rexml (>= 3.3.6)
|
@@ -11,23 +12,51 @@ GEM
|
|
11
12
|
remote: https://rubygems.org/
|
12
13
|
specs:
|
13
14
|
ast (2.4.3)
|
14
|
-
|
15
|
-
|
15
|
+
bigdecimal (3.2.3)
|
16
|
+
concurrent-ruby (1.3.5)
|
17
|
+
crass (1.0.6)
|
16
18
|
date (3.4.1)
|
19
|
+
debug (1.11.0)
|
20
|
+
irb (~> 1.10)
|
21
|
+
reline (>= 0.3.8)
|
17
22
|
diff-lcs (1.6.2)
|
18
23
|
erb (5.0.2)
|
24
|
+
facets (3.1.0)
|
25
|
+
hana (1.3.7)
|
19
26
|
io-console (0.8.1)
|
20
27
|
irb (1.15.2)
|
21
28
|
pp (>= 0.6.0)
|
22
29
|
rdoc (>= 4.0.0)
|
23
30
|
reline (>= 0.4.2)
|
24
31
|
json (2.13.2)
|
32
|
+
json_schemer (2.4.0)
|
33
|
+
bigdecimal
|
34
|
+
hana (~> 1.3)
|
35
|
+
regexp_parser (~> 2.0)
|
36
|
+
simpleidn (~> 0.2)
|
25
37
|
language_server-protocol (3.17.0.5)
|
26
38
|
lint_roller (1.1.0)
|
27
39
|
logger (1.7.0)
|
28
|
-
|
40
|
+
loofah (2.24.1)
|
41
|
+
crass (~> 1.0.2)
|
42
|
+
nokogiri (>= 1.12.0)
|
29
43
|
minitest (5.25.5)
|
30
|
-
|
44
|
+
nokogiri (1.18.9-aarch64-linux-gnu)
|
45
|
+
racc (~> 1.4)
|
46
|
+
nokogiri (1.18.9-aarch64-linux-musl)
|
47
|
+
racc (~> 1.4)
|
48
|
+
nokogiri (1.18.9-arm-linux-gnu)
|
49
|
+
racc (~> 1.4)
|
50
|
+
nokogiri (1.18.9-arm-linux-musl)
|
51
|
+
racc (~> 1.4)
|
52
|
+
nokogiri (1.18.9-arm64-darwin)
|
53
|
+
racc (~> 1.4)
|
54
|
+
nokogiri (1.18.9-x86_64-darwin)
|
55
|
+
racc (~> 1.4)
|
56
|
+
nokogiri (1.18.9-x86_64-linux-gnu)
|
57
|
+
racc (~> 1.4)
|
58
|
+
nokogiri (1.18.9-x86_64-linux-musl)
|
59
|
+
racc (~> 1.4)
|
31
60
|
parallel (1.27.0)
|
32
61
|
parser (3.3.9.0)
|
33
62
|
ast (~> 2.4.1)
|
@@ -39,31 +68,29 @@ GEM
|
|
39
68
|
prettier_print (1.2.1)
|
40
69
|
prettyprint (0.2.0)
|
41
70
|
prism (1.4.0)
|
42
|
-
pry (0.15.2)
|
43
|
-
coderay (~> 1.1)
|
44
|
-
method_source (~> 1.0)
|
45
|
-
pry-byebug (3.11.0)
|
46
|
-
byebug (~> 12.0)
|
47
|
-
pry (>= 0.13, < 0.16)
|
48
71
|
psych (5.2.6)
|
49
72
|
date
|
50
73
|
stringio
|
51
74
|
racc (1.8.1)
|
52
|
-
rack (3.2.
|
75
|
+
rack (3.2.1)
|
76
|
+
rack-attack (6.7.0)
|
77
|
+
rack (>= 1.0, < 4)
|
53
78
|
rack-parser (0.7.0)
|
54
79
|
rack
|
55
80
|
rack-test (2.2.0)
|
56
81
|
rack (>= 1.3)
|
82
|
+
rackup (2.2.1)
|
83
|
+
rack (>= 3)
|
57
84
|
rainbow (3.1.1)
|
58
|
-
rbs (3.9.
|
85
|
+
rbs (3.9.5)
|
59
86
|
logger
|
60
87
|
rdoc (6.14.2)
|
61
88
|
erb
|
62
89
|
psych (>= 4.0.0)
|
63
|
-
regexp_parser (2.11.
|
90
|
+
regexp_parser (2.11.2)
|
64
91
|
reline (0.6.2)
|
65
92
|
io-console (~> 0.5)
|
66
|
-
rexml (3.4.
|
93
|
+
rexml (3.4.3)
|
67
94
|
rspec (3.13.1)
|
68
95
|
rspec-core (~> 3.13.0)
|
69
96
|
rspec-expectations (~> 3.13.0)
|
@@ -76,8 +103,8 @@ GEM
|
|
76
103
|
rspec-mocks (3.13.5)
|
77
104
|
diff-lcs (>= 1.2.0, < 2.0)
|
78
105
|
rspec-support (~> 3.13.0)
|
79
|
-
rspec-support (3.13.
|
80
|
-
rubocop (1.
|
106
|
+
rspec-support (3.13.5)
|
107
|
+
rubocop (1.80.2)
|
81
108
|
json (~> 2.3)
|
82
109
|
language_server-protocol (~> 3.17.0.2)
|
83
110
|
lint_roller (~> 1.1.0)
|
@@ -91,11 +118,11 @@ GEM
|
|
91
118
|
rubocop-ast (1.46.0)
|
92
119
|
parser (>= 3.3.7.2)
|
93
120
|
prism (~> 1.4)
|
94
|
-
rubocop-performance (1.
|
121
|
+
rubocop-performance (1.26.0)
|
95
122
|
lint_roller (~> 1.1)
|
96
123
|
rubocop (>= 1.75.0, < 2.0)
|
97
|
-
rubocop-ast (>= 1.
|
98
|
-
rubocop-rspec (3.
|
124
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
125
|
+
rubocop-rspec (3.7.0)
|
99
126
|
lint_roller (~> 1.1)
|
100
127
|
rubocop (~> 1.72, >= 1.72.1)
|
101
128
|
rubocop-thread_safety (0.7.3)
|
@@ -107,11 +134,13 @@ GEM
|
|
107
134
|
prism (>= 1.2, < 2.0)
|
108
135
|
rbs (>= 3, < 5)
|
109
136
|
ruby-progressbar (1.13.0)
|
137
|
+
simpleidn (0.2.3)
|
110
138
|
stackprof (0.2.27)
|
111
139
|
stringio (3.1.7)
|
112
140
|
syntax_tree (6.3.0)
|
113
141
|
prettier_print (>= 1.2.0)
|
114
|
-
tryouts (3.
|
142
|
+
tryouts (3.6.0)
|
143
|
+
concurrent-ruby (~> 1.0)
|
115
144
|
irb
|
116
145
|
minitest (~> 5.0)
|
117
146
|
pastel (~> 0.8)
|
@@ -122,19 +151,28 @@ GEM
|
|
122
151
|
tty-color (0.6.0)
|
123
152
|
tty-cursor (0.7.1)
|
124
153
|
tty-screen (0.8.2)
|
125
|
-
unicode-display_width (3.
|
126
|
-
unicode-emoji (~> 4.
|
127
|
-
unicode-emoji (4.0
|
154
|
+
unicode-display_width (3.2.0)
|
155
|
+
unicode-emoji (~> 4.1)
|
156
|
+
unicode-emoji (4.1.0)
|
128
157
|
|
129
158
|
PLATFORMS
|
130
|
-
|
131
|
-
|
159
|
+
aarch64-linux-gnu
|
160
|
+
aarch64-linux-musl
|
161
|
+
arm-linux-gnu
|
162
|
+
arm-linux-musl
|
163
|
+
arm64-darwin
|
164
|
+
x86_64-darwin
|
165
|
+
x86_64-linux-gnu
|
166
|
+
x86_64-linux-musl
|
132
167
|
|
133
168
|
DEPENDENCIES
|
169
|
+
debug
|
170
|
+
json_schemer
|
134
171
|
otto!
|
135
|
-
|
172
|
+
rack-attack
|
136
173
|
rack-test
|
137
|
-
|
174
|
+
rackup
|
175
|
+
rspec (~> 3.13)
|
138
176
|
rubocop
|
139
177
|
rubocop-performance
|
140
178
|
rubocop-rspec
|
@@ -142,7 +180,7 @@ DEPENDENCIES
|
|
142
180
|
ruby-lsp
|
143
181
|
stackprof
|
144
182
|
syntax_tree
|
145
|
-
tryouts (~> 3.
|
183
|
+
tryouts (~> 3.6.0)
|
146
184
|
|
147
185
|
BUNDLED WITH
|
148
|
-
2.
|
186
|
+
2.7.1
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
**Define your rack-apps in plain-text with built-in security.**
|
4
4
|
|
5
|
+
> **v2.0.0-pre1 Available**: This pre-release includes major improvements to middleware management and test coverage. See [changelog](CHANGELOG.rst) and [migration guide](docs/migrating/v2.0.0-pre1.md) for upgraders.
|
6
|
+
|
5
7
|

|
6
8
|
|
7
9
|
Otto apps have three files: a rackup file, a Ruby class, and a routes file. The routes file is just plain text that maps URLs to Ruby methods.
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
@@ -0,0 +1,28 @@
|
|
1
|
+
Added
|
2
|
+
-----
|
3
|
+
|
4
|
+
- ``Otto::RequestContext`` Data class providing immutable, structured authentication context for Logic classes
|
5
|
+
- Helper methods ``authenticated?``, ``has_role?``, ``has_permission?``, ``user_name``, ``session_id`` for cleaner Logic class implementation
|
6
|
+
- Factory methods for creating RequestContext from AuthResult or anonymous contexts
|
7
|
+
|
8
|
+
Changed
|
9
|
+
-------
|
10
|
+
|
11
|
+
- **BREAKING**: Logic class constructor signature changed from ``initialize(session, user, params, locale)`` to ``initialize(context, params, locale)``
|
12
|
+
- Logic classes now receive immutable RequestContext instead of separate session/user parameters
|
13
|
+
- LogicClassHandler simplified to single arity pattern, removing backward compatibility code
|
14
|
+
- Authentication middleware now creates RequestContext instances for all requests
|
15
|
+
|
16
|
+
Documentation
|
17
|
+
-------------
|
18
|
+
|
19
|
+
- Updated migration guide with comprehensive RequestContext examples and step-by-step conversion instructions
|
20
|
+
- Updated Logic class examples in advanced_routes and authentication_strategies to demonstrate new pattern
|
21
|
+
- Enhanced documentation with RequestContext API reference and helper method examples
|
22
|
+
|
23
|
+
AI Assistance
|
24
|
+
-------------
|
25
|
+
|
26
|
+
- RequestContext Data class design developed with AI architectural guidance for immutability and clean API
|
27
|
+
- Comprehensive migration of all example Logic classes with AI assistance for consistency and best practices
|
28
|
+
- Documentation improvements ensuring clarity of breaking changes and migration path
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Changed
|
2
|
+
-------
|
3
|
+
|
4
|
+
- Replaced `RequestContext` with `StrategyResult` class for better authentication handling
|
5
|
+
- Simplified authentication strategy API to return `StrategyResult` or `nil` for success/failure
|
6
|
+
- Enhanced route handlers to support JSON request body parsing
|
7
|
+
- Updated authentication middleware to use `StrategyResult` throughout
|
8
|
+
|
9
|
+
Added
|
10
|
+
-----
|
11
|
+
|
12
|
+
- Added `StrategyResult` class with improved user model compatibility and cleaner API
|
13
|
+
- Added JSON request body parsing support in Logic class handlers
|
14
|
+
|
15
|
+
Removed
|
16
|
+
-------
|
17
|
+
|
18
|
+
- Removed `RequestContext` class (replaced by `StrategyResult`)
|
19
|
+
- Removed `AuthResult` class from authentication system
|
20
|
+
- Removed OpenStruct dependency across the framework
|
21
|
+
- Removed `ConcurrentCacheStore` example class for an ActiveSupport::Cache::MemoryStore-compatible interface with Rack::Attack
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Changed
|
2
|
+
-------
|
3
|
+
|
4
|
+
- Reorganized Otto security module structure for better maintainability and separation of concerns
|
5
|
+
- Moved authentication strategies to ``Otto::Security::Authentication::Strategies`` namespace
|
6
|
+
- Moved security middleware to ``Otto::Security::Middleware`` namespace
|
7
|
+
- Moved ``StrategyResult`` and ``FailureResult`` to ``Otto::Security::Authentication`` namespace
|
8
|
+
|
9
|
+
Added
|
10
|
+
-----
|
11
|
+
|
12
|
+
- Added new modular directory structure under ``lib/otto/security/``
|
13
|
+
- Added backward compatibility aliases to maintain existing API compatibility
|
14
|
+
- Added proper namespacing for authentication components and middleware classes
|
15
|
+
|
16
|
+
AI Assistance
|
17
|
+
-------------
|
18
|
+
|
19
|
+
- Comprehensive security module reorganization with systematic namespace restructuring
|
20
|
+
- Automated test validation to ensure backward compatibility during refactoring
|
21
|
+
- Intelligent file organization following Ruby conventions and single responsibility principles
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# Otto Changelog Process
|
2
|
+
|
3
|
+
This directory contains Otto's changelog management using [Scriv](https://scriv.readthedocs.io/).
|
4
|
+
|
5
|
+
## Developer Workflow
|
6
|
+
|
7
|
+
### Creating a Changelog Fragment
|
8
|
+
|
9
|
+
When making changes that affect users, create a changelog fragment:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
# Create a new fragment
|
13
|
+
scriv create
|
14
|
+
|
15
|
+
# Edit the generated file in changelog.d/
|
16
|
+
# Add entries under appropriate categories
|
17
|
+
```
|
18
|
+
|
19
|
+
### Categories
|
20
|
+
|
21
|
+
Use these categories in your fragments:
|
22
|
+
|
23
|
+
- **Added**: New features
|
24
|
+
- **Changed**: Changes in existing functionality
|
25
|
+
- **Deprecated**: Soon-to-be removed features
|
26
|
+
- **Removed**: Removed features
|
27
|
+
- **Fixed**: Bug fixes
|
28
|
+
- **Security**: Security fixes and improvements
|
29
|
+
- **Documentation**: Documentation changes
|
30
|
+
- **AI Assistance**: AI-assisted development, analysis, and improvements
|
31
|
+
|
32
|
+
### Fragment Format
|
33
|
+
|
34
|
+
Each fragment uses reStructuredText format:
|
35
|
+
|
36
|
+
```rst
|
37
|
+
Added
|
38
|
+
-----
|
39
|
+
|
40
|
+
- New feature description
|
41
|
+
|
42
|
+
Fixed
|
43
|
+
-----
|
44
|
+
|
45
|
+
- Bug fix description
|
46
|
+
|
47
|
+
AI Assistance
|
48
|
+
-------------
|
49
|
+
|
50
|
+
- Comprehensive test coverage development with AI assistance
|
51
|
+
```
|
52
|
+
|
53
|
+
### Committing Changes
|
54
|
+
|
55
|
+
Always commit the fragment alongside your code:
|
56
|
+
|
57
|
+
```bash
|
58
|
+
# Stage both code and fragment
|
59
|
+
git add changelog.d/YYYYMMDD_HHmmss_username_branch.rst
|
60
|
+
git add [your code files]
|
61
|
+
|
62
|
+
# Commit together
|
63
|
+
git commit -m "Your commit message
|
64
|
+
|
65
|
+
Includes changelog fragment documenting changes."
|
66
|
+
```
|
67
|
+
|
68
|
+
## Release Process
|
69
|
+
|
70
|
+
During releases, maintainers aggregate all fragments:
|
71
|
+
|
72
|
+
```bash
|
73
|
+
# Collect all fragments into CHANGELOG.rst
|
74
|
+
scriv collect
|
75
|
+
|
76
|
+
# Review the updated CHANGELOG.rst
|
77
|
+
git add CHANGELOG.rst
|
78
|
+
git commit -m "Release changelog for vX.Y.Z"
|
79
|
+
```
|
80
|
+
|
81
|
+
## Guidelines
|
82
|
+
|
83
|
+
### When to Create Fragments
|
84
|
+
|
85
|
+
Create fragments for:
|
86
|
+
- ✅ New features users will notice
|
87
|
+
- ✅ Bug fixes that affect user experience
|
88
|
+
- ✅ Breaking changes or deprecations
|
89
|
+
- ✅ Security fixes
|
90
|
+
- ✅ API changes
|
91
|
+
- ✅ Significant internal improvements (use AI Assistance category)
|
92
|
+
|
93
|
+
Skip fragments for:
|
94
|
+
- ❌ Internal refactoring with no user impact
|
95
|
+
- ❌ Test-only changes (unless they represent significant coverage improvements)
|
96
|
+
- ❌ Documentation typo fixes
|
97
|
+
- ❌ CI/build changes
|
98
|
+
|
99
|
+
### Fragment Quality
|
100
|
+
|
101
|
+
Good fragments:
|
102
|
+
- Are concise but descriptive
|
103
|
+
- Focus on user impact, not implementation details
|
104
|
+
- Link to issues/PRs when helpful: `(#123)`
|
105
|
+
- Use active voice: "Fixed authentication bug" not "Authentication bug was fixed"
|
106
|
+
|
107
|
+
### AI Assistance Category
|
108
|
+
|
109
|
+
Use the "AI Assistance" category to document:
|
110
|
+
- Security analysis and hardened design discussions
|
111
|
+
- Implementation development with AI pair programming
|
112
|
+
- Comprehensive test coverage development
|
113
|
+
- Architecture improvements developed with AI
|
114
|
+
- Code review and debugging sessions with AI
|
115
|
+
|
116
|
+
This category ensures transparency about AI contributions to the project while highlighting areas where AI provided particular value.
|
117
|
+
|
118
|
+
## Configuration
|
119
|
+
|
120
|
+
See `scriv.ini` for configuration details. The setup automatically detects Otto's version from `lib/otto/version.rb`.
|
data/docs/.gitignore
CHANGED