Simple plugin that ensures cookies of requests contains or does not contains some values. If the specified cookie is not in the request, then the plugin add the cookie.
Based on: https://github.com/SwissDataScienceCenter/cookiefilter
Navigate to the demo folder in the repo to run a quick docker-compose demonstration of this plugin. It includes additional information on how to start and use the demo.
The demo also illustrates how the plugin can be loaded in a traefik docker image and used without relying on the traefik Pilot. For more information about packaging plugins in an image see here.
Add the plugin in your static configuration
# Static configurationexperimental:plugins:cookiesmanager:moduleName: github.com/theoguidoux/cookiesmanagerversion: "0.0.1"
Use the plugin in your dynamic configuration like this
# Dynamic configurationhttp:routers:my-router:rule: host(`demo.localhost`)service: service-fooentryPoints:- webmiddlewares:- cookiesmanagerservices:service-foo:loadBalancer:servers:- url: http://127.0.0.1:5000middlewares:cookiesmanager:plugin:cookiesmanager:adder:- name: cookie1value: "foo=bar"- name: "SameSite"value: "none"remover:- name: "cookie2"value: "foo=bar"
The middleware defined above would make it so that requests to service-foo
have cookie1 containing foo=bar, SameSite containing none and cookie2 not containing foo=bar.