web_package-rails 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 62816866d03b077345bed1d89d669f936d6cb8ba
4
+ data.tar.gz: ea2217a4bad02a5026d22efb8374cacbb981d522
5
+ SHA512:
6
+ metadata.gz: 6dc59287308fdd5aafdad31c5fed57e05b6eac6b9f082da2baaf6d773ae68b4c7c0d6e88cdff30d2df77988af9ff1c332005398a9147c2adf0311bbf91d12c70
7
+ data.tar.gz: 4f31cb9eeb9fb907878870c5b1397f644e7e0aee512e52220958bede2f50259bd4d9b19eb0ed0380260673e03e189dbc59457436f53427230bbc6af02ede01b9
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ Metrics/LineLength:
2
+ Max: 100
3
+ IgnoreCopDirectives: true
4
+
5
+ Naming/FileName:
6
+ Exclude:
7
+ - 'lib/web_package-rails.rb'
8
+
9
+ Naming/UncommunicativeMethodParamName:
10
+ AllowedNames:
11
+ - s
12
+
13
+ Style/CharacterLiteral:
14
+ Enabled: false
15
+
16
+ Style/FrozenStringLiteralComment:
17
+ Enabled: false
18
+
19
+ Style/RedundantReturn:
20
+ Enabled: false
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Oleg Afanasyev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Web packaging for Rails
2
+
3
+ This gem is a glue to stick underlying [web_package](https://github.com/gafrom/web_package) mechanism into Rails 3+ apps. It provides a way to extend existing routes in Rails application with `.sxg` formats. That is, for each known path `/articles/foo` the library handles `/articles/foo.sxg` path out of the box.
4
+
5
+ ## Required environment variables
6
+
7
+ For an http exchange to be signed a certificate with a special "CanSignHttpExchanges" extension must be provided. For testing purposes you may use just a self-signed one. Please refer to [web_package docs](https://github.com/gafrom/web_package#ever-thought-of-saving-the-internet-on-a-flash) to create such.
8
+
9
+ Also, an endpoint must be set up serving the certificate in `application/cert-chain+cbor` format. You can use `gen-certurl` tool from [here](https://github.com/WICG/webpackage/tree/master/go/signedexchange#creating-our-first-signed-exchange) to convert PEM certificate into this format.
10
+
11
+ Having done the above-said we are ready to assign env vars required to use the gem:
12
+ ```bash
13
+ export SXG_CERT_URL='https://my.cdn.com/cert.cbor' \
14
+ SXG_CERT_PATH='/local/path/to/cert.pem' \
15
+ SXG_PRIV_PATH='/local/path/to/priv.key'
16
+ ```
17
+ Please note, that the variables are fetched during class initialization. And <b>failing to provide valid paths will result in an exception.</b>
18
+
19
+ ## Install
20
+
21
+ First, please ensure the above environment variables are set up all right.
22
+
23
+ Next, add the gem into your `Gemfile`:
24
+ ```ruby
25
+ gem 'web_package-rails'
26
+ ```
27
+ And run `bundle install` command.
28
+
29
+ That's it. Once added, the gem will hook into your Rails initialization process to prepend middleware stack with `WebPackage::Middleware`.
30
+
31
+ ## What is inside
32
+
33
+ The gem is just a rack middleware comprising a lightweight scanner of request paths for the presence of `.sxg` extension. If found, the path is cleared of it, and modified request url is then passed further down the middleware stack to be handled as if no extension was ever given.
34
+
35
+ In case `.sxg` extension is not detected - the requests are simply proxied intact.
36
+
37
+ ## Contributing
38
+
39
+ Fork it, create your feature branch from develop, make changes and create new Pull Request. Please do not forget tests.
40
+
41
+ ## License
42
+
43
+ Web package for Rails is released under the [MIT License](../master/LICENSE).
@@ -0,0 +1,3 @@
1
+ require 'web_package'
2
+ require 'web_package/rails/version'
3
+ require 'web_package/railtie'
@@ -0,0 +1,5 @@
1
+ module WebPackage
2
+ module Rails
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ require 'rails/railtie'
2
+
3
+ module WebPackage
4
+ # Integration into Rails middleware pipeline.
5
+ class Railtie < ::Rails::Railtie
6
+ initializer 'web_package.configure_rails_initialization' do |app|
7
+ app.middleware.insert 0, Middleware
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path('lib/web_package/rails/version', __dir__)
2
+ require 'date'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'web_package-rails'
6
+ s.version = WebPackage::Rails::VERSION
7
+ s.date = Date.today.to_s
8
+ s.summary = 'Web packaging middleware for Rails.'
9
+ s.description = 'Provides integration of Signed HTTP Exchange format into Rails 3+, allowing a '\
10
+ 'browser to trust that a HTTP request-response pair was generated by the '\
11
+ 'origin it claims.'
12
+ s.authors = ['Oleg Afanasyev', 'Alexey Martynyuk']
13
+ s.email = ['gafrom@gmail.com']
14
+ s.homepage = 'https://github.com/gafrom/web_package-rails'
15
+ s.license = 'MIT'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.require_paths = ['lib']
19
+
20
+ s.required_ruby_version = '>= 2.2.0'
21
+
22
+ s.add_runtime_dependency 'railties', '>= 3.1'
23
+ s.add_runtime_dependency 'web_package', '~> 0.1'
24
+
25
+ s.add_development_dependency 'rubocop', '~> 0.67'
26
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: web_package-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Oleg Afanasyev
8
+ - Alexey Martynyuk
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2019-05-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '3.1'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '3.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: web_package
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '0.1'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '0.1'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rubocop
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.67'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.67'
56
+ description: Provides integration of Signed HTTP Exchange format into Rails 3+, allowing
57
+ a browser to trust that a HTTP request-response pair was generated by the origin
58
+ it claims.
59
+ email:
60
+ - gafrom@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - ".gitignore"
66
+ - ".rubocop.yml"
67
+ - LICENSE
68
+ - README.md
69
+ - lib/web_package-rails.rb
70
+ - lib/web_package/rails/version.rb
71
+ - lib/web_package/railtie.rb
72
+ - web_package-rails.gemspec
73
+ homepage: https://github.com/gafrom/web_package-rails
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 2.2.0
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.6.13
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Web packaging middleware for Rails.
97
+ test_files: []