aris 1.4.2 → 1.5.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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +259 -0
  3. data/README.md +18 -0
  4. data/docs/ADAPTERS.md +478 -0
  5. data/docs/ARCHITECTURE.md +222 -0
  6. data/docs/CONTENT.md +967 -0
  7. data/docs/PERFORMANCE.md +492 -0
  8. data/docs/PLUGIN_DEVELOPMENT.md +688 -0
  9. data/docs/USAGE.md +4998 -0
  10. data/docs/plugins/API_KEY_AUTH.md +232 -0
  11. data/docs/plugins/BASIC_AUTH.md +582 -0
  12. data/docs/plugins/BEARER_AUTH.md +394 -0
  13. data/docs/plugins/CACHE.md +369 -0
  14. data/docs/plugins/COMPRESSION.md +216 -0
  15. data/docs/plugins/COOKIES.md +30 -0
  16. data/docs/plugins/CORS.md +283 -0
  17. data/docs/plugins/CSRF.md +751 -0
  18. data/docs/plugins/ETAG.md +308 -0
  19. data/docs/plugins/FORM_PARSER.md +193 -0
  20. data/docs/plugins/HEALTH_CHECK.md +469 -0
  21. data/docs/plugins/JSON.md +291 -0
  22. data/docs/plugins/MULTIPART.md +427 -0
  23. data/docs/plugins/RATE_LIMITER.md +368 -0
  24. data/docs/plugins/REQUEST_ID.md +369 -0
  25. data/docs/plugins/REQUEST_LOGGER.md +151 -0
  26. data/docs/plugins/SECURITY.md +193 -0
  27. data/docs/plugins/SESSION.md +98 -0
  28. data/lib/aris/adapters/rack/adapter.rb +17 -2
  29. data/lib/aris/adapters/rack/request.rb +29 -11
  30. data/lib/aris/plugins/basic_auth.rb +3 -1
  31. data/lib/aris/plugins/cookies.rb +4 -32
  32. data/lib/aris/plugins/cors.rb +8 -1
  33. data/lib/aris/plugins/csrf.rb +63 -22
  34. data/lib/aris/plugins/flash.rb +3 -1
  35. data/lib/aris/plugins/form_parser.rb +52 -31
  36. data/lib/aris/plugins/multipart.rb +34 -6
  37. data/lib/aris/plugins/request_logger.rb +8 -1
  38. data/lib/aris/plugins/security_headers.rb +8 -1
  39. data/lib/aris/plugins/session.rb +150 -99
  40. data/lib/aris/response_helpers.rb +41 -0
  41. data/lib/aris/router.rb +7 -0
  42. data/lib/aris/version.rb +2 -2
  43. metadata +31 -3
@@ -1,5 +1,6 @@
1
1
  # lib/aris/response_helpers.rb
2
2
  require 'json'
3
+ require 'time'
3
4
 
4
5
  module Aris
5
6
  module ResponseHelpers
@@ -73,6 +74,37 @@ module Aris
73
74
  redirect(path, status: status)
74
75
  end
75
76
 
77
+ # --- Cookies -----------------------------------------------------------
78
+ # Available on every response (Rack and Mock). Emits Rack 3 compliant
79
+ # headers: the key is lowercase `set-cookie`, and several cookies become
80
+ # an Array of values instead of a comma-joined string (which browsers
81
+ # cannot parse).
82
+ #
83
+ # res.set_cookie('theme', 'dark', max_age: 3600)
84
+ # res.set_cookie('sid', token, httponly: true, secure: true, same_site: :lax)
85
+ # res.delete_cookie('sid')
86
+ #
87
+ # Defaults come from Aris::Config.cookie_options.
88
+ def set_cookie(name, value, options = {})
89
+ merged = (Aris::Config.cookie_options || {}).merge(options)
90
+ parts = ["#{name}=#{value}"]
91
+ parts << "Domain=#{merged[:domain]}" if merged[:domain]
92
+ parts << "Path=#{merged[:path]}" if merged[:path]
93
+ parts << "Max-Age=#{merged[:max_age]}" if merged.key?(:max_age) && !merged[:max_age].nil?
94
+ parts << "Expires=#{merged[:expires].httpdate}" if merged[:expires].respond_to?(:httpdate)
95
+ parts << "HttpOnly" if merged[:httponly]
96
+ parts << "Secure" if merged[:secure]
97
+ if merged[:same_site]
98
+ parts << "SameSite=#{merged[:same_site].to_s.capitalize}"
99
+ end
100
+ add_set_cookie_header(parts.join('; '))
101
+ self
102
+ end
103
+
104
+ def delete_cookie(name, options = {})
105
+ set_cookie(name, '', options.merge(max_age: 0, expires: Time.at(0).utc))
106
+ end
107
+
76
108
  # No content response
77
109
  def no_content
78
110
  self.status = 204
@@ -115,6 +147,15 @@ module Aris
115
147
  end
116
148
 
117
149
  private
150
+
151
+ def add_set_cookie_header(cookie_string)
152
+ existing = headers['set-cookie']
153
+ headers['set-cookie'] = case existing
154
+ when nil then cookie_string
155
+ when Array then existing + [cookie_string]
156
+ else [existing, cookie_string]
157
+ end
158
+ end
118
159
 
119
160
  def detect_content_type(file_path)
120
161
  # Handle Tempfile paths that may have random extensions
data/lib/aris/router.rb CHANGED
@@ -696,6 +696,13 @@ module Aris
696
696
  path.length > 1 && path.end_with?('/') ? path.chomp('/') : path
697
697
  end
698
698
 
699
+ # Servers hand PATH_INFO over as raw bytes (ASCII-8BIT). Path params must be
700
+ # text: a binary "coop" is a BLOB to SQLite and never equals the text 'coop'.
701
+ unless normalized.encoding == Encoding::UTF_8
702
+ normalized = normalized.dup.force_encoding(Encoding::UTF_8)
703
+ normalized = normalized.scrub unless normalized.valid_encoding?
704
+ end
705
+
699
706
  if normalized.include?('%')
700
707
  begin
701
708
  normalized = URI.decode_www_form_component(normalized)
data/lib/aris/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Aris
2
- VERSION = "1.4.2"
3
- end
2
+ VERSION = "1.5.1"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aris
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.2
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Garcia
@@ -87,8 +87,33 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - CHANGELOG.md
90
91
  - LICENSE.txt
91
92
  - README.md
93
+ - docs/ADAPTERS.md
94
+ - docs/ARCHITECTURE.md
95
+ - docs/CONTENT.md
96
+ - docs/PERFORMANCE.md
97
+ - docs/PLUGIN_DEVELOPMENT.md
98
+ - docs/USAGE.md
99
+ - docs/plugins/API_KEY_AUTH.md
100
+ - docs/plugins/BASIC_AUTH.md
101
+ - docs/plugins/BEARER_AUTH.md
102
+ - docs/plugins/CACHE.md
103
+ - docs/plugins/COMPRESSION.md
104
+ - docs/plugins/COOKIES.md
105
+ - docs/plugins/CORS.md
106
+ - docs/plugins/CSRF.md
107
+ - docs/plugins/ETAG.md
108
+ - docs/plugins/FORM_PARSER.md
109
+ - docs/plugins/HEALTH_CHECK.md
110
+ - docs/plugins/JSON.md
111
+ - docs/plugins/MULTIPART.md
112
+ - docs/plugins/RATE_LIMITER.md
113
+ - docs/plugins/REQUEST_ID.md
114
+ - docs/plugins/REQUEST_LOGGER.md
115
+ - docs/plugins/SECURITY.md
116
+ - docs/plugins/SESSION.md
92
117
  - lib/aris.rb
93
118
  - lib/aris/adapters/base.rb
94
119
  - lib/aris/adapters/joys_integration.rb
@@ -132,7 +157,10 @@ files:
132
157
  homepage: https://github.com/activestylus/aris
133
158
  licenses:
134
159
  - MIT
135
- metadata: {}
160
+ metadata:
161
+ source_code_uri: https://github.com/activestylus/aris
162
+ changelog_uri: https://github.com/activestylus/aris/blob/main/CHANGELOG.md
163
+ rubygems_mfa_required: 'true'
136
164
  rdoc_options: []
137
165
  require_paths:
138
166
  - lib
@@ -147,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
175
  - !ruby/object:Gem::Version
148
176
  version: '0'
149
177
  requirements: []
150
- rubygems_version: 3.6.9
178
+ rubygems_version: 4.0.17
151
179
  specification_version: 4
152
180
  summary: Fast, elegant Ruby web framework
153
181
  test_files: []