rack-floc-off 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2e35378a703eeaf239c6b4db938aa42a6bbb1b05ffab67cc21ecd2f5b3a37e65
4
+ data.tar.gz: cc934aff6eaa1a153269d7cf7375bacb278912c0c941bda139f6736f01c5c183
5
+ SHA512:
6
+ metadata.gz: ae8f0ddf2e3051e9c163523880a2e0434d3c55eedf1f52793e26953153e74387ac14ca056c87e4b19a0fa4328c914c907980429b2736fba90a1e2e8bcc79b0fe
7
+ data.tar.gz: f70d5dd754daa95164cd72d21ced5416a53101255610602c63d1f748159d7088655828a52f1e07cecd9ed46c7417c07374b9494960e5a3f44cf10a57b2a6dda8
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2021 Gareth Rees [https://github.com/garethrees]
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Rack::FlocOff
2
+
3
+ Disables Google's Federated Learning of Cohorts (FLoC) for your site.
4
+
5
+ See https://plausible.io/blog/google-floc.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ # TODO: fix auto-require
12
+ gem 'rack-floc-off', require: 'rack_floc_off'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install rack-floc-off
21
+
22
+ ## Usage
23
+
24
+ Once the gem is installed, you're done.
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'test'
7
+ t.test_files = FileList['test/**/test*.rb']
8
+ t.verbose = true
9
+ end
@@ -0,0 +1,15 @@
1
+ module Rack
2
+ # Turns off Federated Learning of Cohorts (FLoC)
3
+ # https://plausible.io/blog/google-floc
4
+ class FlocOff
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ status, headers, body = @app.call(env)
11
+ headers['Permissions-Policy'] = 'interest-cohort=()'
12
+ [status, headers, body]
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ module Rack
2
+ class FlocOff::Railtie < Rails::Railtie
3
+ initializer 'rack.floc_off.initializer' do |app|
4
+ app.middleware.use Rack::FlocOff
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require 'rack/floc_off'
2
+ require 'rack/floc_off/railtie' if defined?(Rails)
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Gareth Rees"]
5
+ gem.email = ["gareth@garethrees.co.uk"]
6
+ gem.description = %q{Tells Google not to impose Federated Learning of Cohorts (FLoC) on users}
7
+ gem.summary = %q{Disables Google FLoC}
8
+ gem.homepage = "https://github.com/garethrees/rack-floc-off"
9
+
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.name = "rack-floc-off"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = '0.0.1'
16
+
17
+ gem.add_development_dependency('minitest')
18
+ gem.add_development_dependency('rack-test')
19
+ gem.add_runtime_dependency('rack')
20
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'minitest/autorun'
2
+ require 'rack_floc_off'
@@ -0,0 +1,22 @@
1
+ require 'helper'
2
+
3
+ class Rack::TestFlocOff < Minitest::Test
4
+ def parent_app
5
+ lambda do |env|
6
+ return [200, { 'Some' => 'Header' }, ['content']]
7
+ end
8
+ end
9
+
10
+ def setup
11
+ @app = Rack::FlocOff.new(parent_app)
12
+ end
13
+
14
+ def test_turns_off_floc
15
+ expected_headers = {
16
+ 'Permissions-Policy' => 'interest-cohort=()',
17
+ 'Some' => 'Header'
18
+ }
19
+
20
+ assert_equal [200, expected_headers, ['content']], @app.call({})
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-floc-off
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Gareth Rees
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-04-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-test
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Tells Google not to impose Federated Learning of Cohorts (FLoC) on users
56
+ email:
57
+ - gareth@garethrees.co.uk
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - lib/rack/floc_off.rb
68
+ - lib/rack/floc_off/railtie.rb
69
+ - lib/rack_floc_off.rb
70
+ - rack-floc-off.gemspec
71
+ - test/helper.rb
72
+ - test/rack/test_floc_off.rb
73
+ homepage: https://github.com/garethrees/rack-floc-off
74
+ licenses: []
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.2.3
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Disables Google FLoC
95
+ test_files:
96
+ - test/helper.rb
97
+ - test/rack/test_floc_off.rb