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

  1. Think about the options and possible problems and solutions
  2. Think about possible security implications
  3. Design
  4. Implement
  5. Test
  6. Release

User interface changes

API changes

Data model changes

Issue fork cookies-3323225

Command icon 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

Anybody created an issue. See original summary.

anybody’s picture

Issue summary: View changes
anybody’s picture

Okay 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.

anybody’s picture

Title: Add a submodule for general third-party scripts or asset_injector support » Add COOKIES submodule for asset_injector support
anybody’s picture

anybody’s picture

Assigned: Unassigned » anybody
Status: Active » Needs work

Still WIP, but we're getting closer...

anybody’s picture

Assigned: anybody » grevil
Status: Needs work » Needs review
Issue tags: +Needs tests, +Needs manual testing

Yaay, 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!

Grevil made their first commit to this issue’s fork.

grevil’s picture

All done! Please review!

grevil’s picture

Final 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!

anybody’s picture

Assigned: grevil » Unassigned

Reviewed! :)

As soon as the tests are passing, RTBC! Can be committed then.

grevil’s picture

Yea no idea, tests all run green locally...

Really don't wanna waste another day for this.

anybody’s picture

@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.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

  • Anybody committed 4e04fb3 on 1.1.x
    Issue #3323225 by Grevil, Anybody: Add COOKIES submodule for...
anybody’s picture

Status: Reviewed & tested by the community » Fixed
anybody’s picture

Now part of 1.1.2 :)

anybody’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.