Problem/Motivation
For some third-party integrations, like especially page-wide scripts like trackers, analytics, etc. where no Drupal module exists yet, it might be too much work and not worth to create a specific Drupal integration module plus a COOKiES integration for cookies blocking.
In such a case a general cookies_script (e.g.) submodule might help to add a script and relate it to a service for cookie information and blocking without having to custom-code anything.
Just paste the script, configure the COOKiES service and finished.
Besides the blocking functionality, this requirement is very close to the https://www.drupal.org/project/asset_injector module (for the JS part at least, while CSS might also be blocked, if it is loaded from outside / third-party). So instead of reinventing the wheel, we could also discuss writing a cookies_asset_injector submodule.
I thought I had already created such a feature request in the past, but can't find it anymore, so if anyone finds it, please link it here.
Steps to reproduce
Proposed resolution
There are several options:
a) Add a submodule to integrate with https://www.drupal.org/project/asset_injector and connect them with a service
b) Add an own submodule to add custom scripts with COOKiES protection
Remaining tasks
- Think about the options and possible problems and solutions
- Think about possible security implications
- Design
- Implement
- Test
- Release
User interface changes
API changes
Data model changes
Issue fork cookies-3323225
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyComment #3
anybodyOkay I just had a closer look at asset_injector and its features and I think it's just perfect to integrate it with COOKiES!
It provides all the features we'd otherwise have to (re-)implement.
So I'm going to create a cookies_asset_injector submodule, which extends asset_injector with COOKiES integration in the UI.
What I'm thinking of is adding a way to select COOKiES handling in the Script administration area (
/admin/config/development/asset-injector/js/XXX).If the module is enabled, we may hook into the asset_injector form and add a "COOKiES GDPR Handling" fieldset, which allows to optionally assign the script to a COOKiES Service.
If selected, based on the service configuration, the script will be blocked, until consent is given.
Comment #4
anybodyComment #5
anybodyComment #7
anybodyStill WIP, but we're getting closer...
Comment #8
anybodyYaay, it's working! :)
Please review @Grevil and if everything is fine, please write tests and a README.md on how to use the submodule.
Of course, I can show you how it works and resolve any issues!
Thanks!
Comment #10
grevil commentedAll done! Please review!
Comment #11
grevil commentedFinal review on https://git.drupalcode.org/issue/cookies-3323225/-/commit/b6168308bd995b... pls. Sorry for the bad commit message...
I can not directly compare two commits via commit hash, the UI says it works, but it doesn't in the Drupal Gitlab instance, on normal Gitlab it works... oh well, pls review!
Comment #12
anybodyReviewed! :)
As soon as the tests are passing, RTBC! Can be committed then.
Comment #13
grevil commentedYea no idea, tests all run green locally...
Really don't wanna waste another day for this.
Comment #14
anybody@Grevil: I'm with you. I'd suggest to put this back to the most clean implementation and commit as-is.
Add an @todo to each failing test with a link to a follow-up issue and let's merge this! Hopefully one of us will have a plan one day, but it's not that important yet.
Comment #15
anybodyFollow-up for the tests: #3323806: Re-implement failing cookies_asset_injector tests (Drupal-CI locally working)
Comment #17
anybodyComment #18
anybodyNow part of 1.1.2 :)
Comment #19
anybody@Grevil: See #3323880: Call to protected method Drupal\asset_injector\Entity\AssetInjectorBase::filePathRelativeToDrupalRoot() from global scope might that be the reason for this issue? -.-