Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmurray committed Apr 17, 2021
0 parents commit 5c8c609
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 0 deletions.
1 change: 1 addition & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preset: laravel
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Laravel No FLoC

[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]
[![Build Status][ico-travis]][link-travis]
[![StyleCI][ico-styleci]][link-styleci]

This package will add the `Permissions-Policy: interest-cohort=()` to try and twart Google's usage of your site in it's FLoC tracking method.

**That being said, it might not be a foolproof method.** See [Seirdly.one's post](https://seirdy.one/2021/04/16/permissions-policy-floc-misinfo.html) to get to know why it might work well, why it might not.

## Installation & usage

Via Composer

``` bash
$ composer require jpmurray/laravel-nofloc
```

That's all. The header will be added to all request via a global middleware.

## Change log

Please see the [changelog](changelog.md) for more information on what has changed recently.

## Contributing

Please see [contributing.md](contributing.md) for details and a todolist.

## Security

If you discover any security related issues, please email author email instead of using the issue tracker.

## Credits

- [Jean-Philippe Murray][https://github.com/jpmurray]
- [All Contributors][link-contributors]

## License

license. Please see the [license file](license.md) for more information.

[ico-version]: https://img.shields.io/packagist/v/jpmurray/laravel-nofloc.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/jpmurray/laravel-nofloc.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/jpmurray/laravel-nofloc/master.svg?style=flat-square
[ico-styleci]: https://styleci.io/repos/12345678/shield

[link-packagist]: https://packagist.org/packages/jpmurray/laravel-nofloc
[link-downloads]: https://packagist.org/packages/jpmurray/laravel-nofloc
[link-travis]: https://travis-ci.org/jpmurray/laravel-nofloc
[link-styleci]: https://styleci.io/repos/12345678
[link-author]: https://github.com/jpmurray
[link-contributors]: ../../contributors
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to `LaravelNoFLoC` will be documented in this file.

## Version 1.0

### Added
- A global middleware to add the specified header.
38 changes: 38 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "jpmurray/laravel-nofloc",
"description": "Adds a header response that should be opting out your site from being used for Google's FloC tracking.",
"license": "license",
"authors": [
{
"name": "Jean-Philippe Murray",
"email": "[email protected]",
"homepage": "https://atomescroch.us"
}
],
"homepage": "https://github.com/jpmurray/laravel-nofloc",
"keywords": ["Laravel", "FLoC", "privacy"],
"require": {
"illuminate/support": "~7|~8"
},
"require-dev": {
"phpunit/phpunit": "~9.0",
"orchestra/testbench": "~5|~6"
},
"autoload": {
"psr-4": {
"jpmurray\\LaravelNoFLoC\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"jpmurray\\LaravelNoFLoC\\Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"jpmurray\\LaravelNoFLoC\\LaravelNoFLoCServiceProvider"
]
}
}
}
5 changes: 5 additions & 0 deletions config/laravel-nofloc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
//
];
26 changes: 26 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Contributing

Contributions are welcome and will be fully credited.

Contributions are accepted via Pull Requests on [Github](https://github.com/jpmurray/laravel-nofloc).

# Things you could do
If you want to contribute but do not know where to start, this list provides some starting points.
- Add license text
- Set up tests
- Set up TravisCI, StyleCI, ScrutinizerCI

## Pull Requests

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `readme.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.


**Happy coding**!
5 changes: 5 additions & 0 deletions license.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# The license

Copyright (c) author name <author email>

...Add your license text here...
22 changes: 22 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Package">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>src/</directory>
</whitelist>
</filter>
</phpunit>
31 changes: 31 additions & 0 deletions src/LaravelNoFLoCServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace jpmurray\LaravelNoFLoC;

use Illuminate\Contracts\Http\Kernel;
use Illuminate\Support\ServiceProvider;
use jpmurray\LaravelNoFLoC\Middleware\NoFLoCMiddleware;

class LaravelNoFLoCServiceProvider extends ServiceProvider
{
/**
* Perform post-registration booting of services.
*
* @return void
*/
public function boot(): void
{
$kernel = $this->app->make(Kernel::class);
$kernel->pushMiddleware(NoFLoCMiddleware::class);
}

/**
* Register any package services.
*
* @return void
*/
public function register(): void
{
//
}
}
17 changes: 17 additions & 0 deletions src/Middleware/NoFLoCMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace jpmurray\LaravelNoFLoC\Middleware;

use Closure;

class NoFLoCMiddleware
{
public function handle($request, Closure $next)
{
$response = $next($request);

$response->header('Permissions-Policy', 'interest-cohort=()');

return $response;
}
}

0 comments on commit 5c8c609

Please sign in to comment.