From f2aea695fca93fca7f4a845527ac56ba290a9922 Mon Sep 17 00:00:00 2001 From: mathieuHa Date: Tue, 19 Sep 2023 20:57:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Update=20regex=20to=20support=20?= =?UTF-8?q?=3D=20in=20lapikey=20update=20some=20exemples=20with=201.5.3=20?= =?UTF-8?q?crowdsec=20(#115)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.local.yml | 11 +++++------ docker-compose.yml | 13 ++++++------- exemples/redis-cache/docker-compose.redis.yml | 2 +- pkg/configuration/configuration.go | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/docker-compose.local.yml b/docker-compose.local.yml index 95b137e..b45777d 100644 --- a/docker-compose.local.yml +++ b/docker-compose.local.yml @@ -2,7 +2,7 @@ version: "3.8" services: traefik: - image: "traefik:v2.9.10" + image: "traefik:v2.10.4" container_name: "traefik" restart: unless-stopped command: @@ -36,7 +36,7 @@ services: - "traefik.http.routers.router-foo.middlewares=crowdsec-foo@docker" - "traefik.http.services.service-foo.loadbalancer.server.port=80" - "traefik.http.middlewares.crowdsec-foo.plugin.bouncer.enabled=true" - - "traefik.http.middlewares.crowdsec-foo.plugin.bouncer.crowdseclapikey=40796d93c2958f9e58345514e67740e5" + - "traefik.http.middlewares.crowdsec-foo.plugin.bouncer.crowdseclapikey=40796d93c2958f9e58345514e67740e5=" whoami2: image: traefik/whoami @@ -49,17 +49,16 @@ services: - "traefik.http.routers.router-bar.middlewares=crowdsec-bar@docker" - "traefik.http.services.service-bar.loadbalancer.server.port=80" - "traefik.http.middlewares.crowdsec-bar.plugin.bouncer.enabled=true" - - "traefik.http.middlewares.crowdsec-bar.plugin.bouncer.crowdseclapikey=44c36dac5c4140af9f06f397508e82c7" + - "traefik.http.middlewares.crowdsec-bar.plugin.bouncer.crowdseclapikey=40796d93c2958f9e58345514e67740e5=" crowdsec: - image: crowdsecurity/crowdsec:v1.4.6 + image: crowdsecurity/crowdsec:v1.5.3 container_name: "crowdsec" restart: unless-stopped environment: COLLECTIONS: crowdsecurity/traefik CUSTOM_HOSTNAME: crowdsec - BOUNCER_KEY_TRAEFIK_1: 40796d93c2958f9e58345514e67740e5 - BOUNCER_KEY_TRAEFIK_2: 44c36dac5c4140af9f06f397508e82c7 + BOUNCER_KEY_TRAEFIK: 40796d93c2958f9e58345514e67740e5= volumes: - ./acquis.yaml:/etc/crowdsec/acquis.yaml:ro - logs-local:/var/log/traefik:ro diff --git a/docker-compose.yml b/docker-compose.yml index ac15cd8..931784a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: traefik: - image: "traefik:v2.9.10" + image: "traefik:v2.10.4" container_name: "traefik" restart: unless-stopped command: @@ -14,7 +14,7 @@ services: - "--entrypoints.web.address=:80" - "--experimental.plugins.bouncer.modulename=github.com/maxlerebourg/crowdsec-bouncer-traefik-plugin" - - "--experimental.plugins.bouncer.version=v1.1.11" + - "--experimental.plugins.bouncer.version=v1.1.15" volumes: - "/var/run/docker.sock:/var/run/docker.sock:ro" - "logs:/var/log/traefik" @@ -39,7 +39,7 @@ services: # Definition of the middleware - "traefik.http.middlewares.crowdsec-foo.plugin.bouncer.enabled=true" # crowdseclapikey must be unique to the middleware attached to the service - - "traefik.http.middlewares.crowdsec-foo.plugin.bouncer.crowdseclapikey=FIXME-LAPI-KEY-1" + - "traefik.http.middlewares.crowdsec-foo.plugin.bouncer.crowdseclapikey=FIXME-LAPI-KEY-1=" # forwardedheaderstrustedips should be the IP of the proxy that is in front of traefik (if any) - "traefik.http.middlewares.crowdsec-foo.plugin.bouncer.forwardedheaderstrustedips=172.21.0.5" @@ -58,20 +58,19 @@ services: # Definitin of the middleware - "traefik.http.middlewares.crowdsec-bar.plugin.bouncer.enabled=true" # crowdseclapikey must be unique to the middleware attached to the service - - "traefik.http.middlewares.crowdsec-bar.plugin.bouncer.crowdseclapikey=FIXME-LAPI-KEY-2" + - "traefik.http.middlewares.crowdsec-bar.plugin.bouncer.crowdseclapikey=FIXME-LAPI-KEY-1=" # forwardedheaderstrustedips should be the IP of the proxy that is in front of traefik (if any) - "traefik.http.middlewares.crowdsec-bar.plugin.bouncer.forwardedheaderstrustedips=172.21.0.5" crowdsec: - image: crowdsecurity/crowdsec:v1.4.6 + image: crowdsecurity/crowdsec:v1.5.3 container_name: "crowdsec" restart: unless-stopped environment: COLLECTIONS: crowdsecurity/traefik CUSTOM_HOSTNAME: crowdsec # We need to register one api key per service we will use - BOUNCER_KEY_TRAEFIK_1: FIXME-LAPI-KEY-1 - BOUNCER_KEY_TRAEFIK_2: FIXME-LAPI-KEY-2 + BOUNCER_KEY_TRAEFIK: FIXME-LAPI-KEY-1= volumes: - ./acquis.yaml:/etc/crowdsec/acquis.yaml:ro - logs:/var/log/traefik:ro diff --git a/exemples/redis-cache/docker-compose.redis.yml b/exemples/redis-cache/docker-compose.redis.yml index 7717f83..ae7c93e 100644 --- a/exemples/redis-cache/docker-compose.redis.yml +++ b/exemples/redis-cache/docker-compose.redis.yml @@ -26,7 +26,7 @@ services: - 8080:8080 depends_on: - crowdsec - - redis-insecure + # - redis-insecure - redis-secure # Either use secure, or insecure but do not mix both diff --git a/pkg/configuration/configuration.go b/pkg/configuration/configuration.go index 36b1638..1c06eb2 100644 --- a/pkg/configuration/configuration.go +++ b/pkg/configuration/configuration.go @@ -195,7 +195,7 @@ func ValidateParams(config *Config) error { // valid ! # $ % & ' * + - . ^ _ ` | ~ DIGIT ALPHA // See https://httpwg.github.io/specs/rfc7230.html#rule.token.separators func validateParamsAPIKey(lapiKey string) error { - reg := regexp.MustCompile("^[a-zA-Z0-9 !#$%&'*+-.^_`|~]*$") + reg := regexp.MustCompile("^[a-zA-Z0-9 !#$%&'*+-.^_`|~=]*$") if !reg.Match([]byte(lapiKey)) { return fmt.Errorf("CrowdsecLapiKey doesn't valid this regexp: '/%s/'", reg.String()) }