1
0
Fork 0

Update plugin paths from /etc/haproxy to /etc/easyhaproxy across tests, configs, and documentation

This commit is contained in:
Joao Gilberto Magalhaes 2026-02-18 16:35:57 -05:00
parent 8532d49642
commit 3fd0fe0d46
9 changed files with 27 additions and 26 deletions

View file

@ -437,12 +437,12 @@ class ResourceRequest:
```python
ResourceRequest(
resource_type="directory",
path="/etc/haproxy/plugin_data"
path="/etc/easyhaproxy/plugin_data"
)
ResourceRequest(
resource_type="file",
path="/etc/haproxy/plugin_config.txt",
path="/etc/easyhaproxy/plugin_config.txt",
content="config data",
overwrite=True
)
@ -471,7 +471,7 @@ class InitializationResult:
def initialize(self) -> InitializationResult:
return InitializationResult(
resources=[
ResourceRequest(resource_type="directory", path="/etc/haproxy/jwt_keys")
ResourceRequest(resource_type="directory", path="/etc/easyhaproxy/jwt_keys")
]
)
```
@ -932,7 +932,7 @@ class JwtValidatorPlugin(PluginInterface):
self.paths = [] # List of paths that require JWT validation
self.only_paths = False # If true, only specified paths are accessible
# Make JWT_KEYS_DIR configurable via environment variable
self.jwt_keys_dir = os.getenv("EASYHAPROXY_JWT_KEYS_DIR", "/etc/haproxy/jwt_keys")
self.jwt_keys_dir = os.getenv("EASYHAPROXY_JWT_KEYS_DIR", "/etc/easyhaproxy/jwt_keys")
@property
def name(self) -> str:
@ -1292,7 +1292,7 @@ EASYHAPROXY_JWT_KEYS_DIR=/custom/path/jwt_keys # Plugin-defined env var
class MyPlugin(PluginInterface):
def __init__(self):
# Make resource directory configurable
self.data_dir = os.getenv("EASYHAPROXY_MY_PLUGIN_DATA_DIR", "/etc/haproxy/my_plugin_data")
self.data_dir = os.getenv("EASYHAPROXY_MY_PLUGIN_DATA_DIR", "/etc/easyhaproxy/my_plugin_data")
def initialize(self) -> InitializationResult:
return InitializationResult(

View file

@ -38,7 +38,7 @@ class PluginManager:
builtin_dir = os.path.join(os.path.dirname(__file__), "builtin")
self._load_plugins_from_directory(builtin_dir, "builtin")
# Load external plugins from /etc/haproxy/plugins
# Load external plugins from /etc/easyhaproxy/plugins
if os.path.exists(self.plugins_dir):
self._load_plugins_from_directory(self.plugins_dir, "external")
else:

View file

@ -264,16 +264,17 @@ class Kubernetes(ProcessorInterface):
ssl_hosts = []
certbot = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.certbot")
redirect_ssl = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.redirect_ssl")
redirect = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.redirect")
mode = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.mode")
listen_port = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.listen_port", 80)
plugins = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.plugins")
annotations = ingress.metadata.annotations or {}
certbot = self._check_annotation(annotations, "easyhaproxy.certbot")
redirect_ssl = self._check_annotation(annotations, "easyhaproxy.redirect_ssl")
redirect = self._check_annotation(annotations, "easyhaproxy.redirect")
mode = self._check_annotation(annotations, "easyhaproxy.mode")
listen_port = self._check_annotation(annotations, "easyhaproxy.listen_port", 80)
plugins = self._check_annotation(annotations, "easyhaproxy.plugins")
# Extract plugin-specific configurations
plugin_annotations = {}
for annotation_key, annotation_value in ingress.metadata.annotations.items():
for annotation_key, annotation_value in annotations.items():
if annotation_key.startswith("easyhaproxy.plugin."):
plugin_annotations[annotation_key] = annotation_value

View file

@ -7,6 +7,6 @@
"easyhaproxy.http.plugin.jwt_validator.algorithm": "RS256",
"easyhaproxy.http.plugin.jwt_validator.issuer": "https://auth.example.com/",
"easyhaproxy.http.plugin.jwt_validator.audience": "https://api.example.com",
"easyhaproxy.http.plugin.jwt_validator.pubkey_path": "/etc/haproxy/jwt_keys/api_pubkey.pem"
"easyhaproxy.http.plugin.jwt_validator.pubkey_path": "/etc/easyhaproxy/jwt_keys/api_pubkey.pem"
}
}

View file

@ -652,12 +652,12 @@ class TestJwtValidatorPlugin:
"algorithm": "RS512",
"issuer": "https://auth.example.com/",
"audience": "https://api.example.com",
"pubkey_path": "/etc/haproxy/keys/api.pem"
"pubkey_path": "/etc/easyhaproxy/keys/api.pem"
})
assert plugin.algorithm == "RS512"
assert plugin.issuer == "https://auth.example.com/"
assert plugin.audience == "https://api.example.com"
assert plugin.pubkey_path == "/etc/haproxy/keys/api.pem"
assert plugin.pubkey_path == "/etc/easyhaproxy/keys/api.pem"
# Test empty values skip validation (use fresh plugin)
plugin2 = JwtValidatorPlugin()
@ -672,7 +672,7 @@ class TestJwtValidatorPlugin:
plugin2b = JwtValidatorPlugin()
plugin2b.configure({
"algorithm": "RS256",
"pubkey_path": "/etc/haproxy/keys/api.pem"
"pubkey_path": "/etc/easyhaproxy/keys/api.pem"
})
assert plugin2b.issuer is None
assert plugin2b.audience is None

View file

@ -43,7 +43,7 @@
# # Edit your EasyHAProxy deployment and add:
# # volumeMounts:
# # - name: jwt-keys
# # mountPath: /etc/haproxy/jwt_keys
# # mountPath: /etc/easyhaproxy/jwt_keys
# # volumes:
# # - name: jwt-keys
# # configMap:

View file

@ -50,7 +50,7 @@
# # Expected: 200 OK with "App Behind Cloudflare"
#
# # Check HAProxy config includes Cloudflare IPs
# docker exec $(docker ps -q -f name=easyhaproxy_haproxy) cat /etc/haproxy/haproxy.cfg | grep -A 5 "cloudflare"
# docker exec $(docker ps -q -f name=easyhaproxy_haproxy) cat /etc/easyhaproxy/haproxy/haproxy.cfg | grep -A 5 "cloudflare"
# # Expected: ACL rules for Cloudflare IP ranges
# ```
#
@ -75,7 +75,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
configs:
- source: cloudflare_ips
target: /etc/haproxy/cloudflare_ips.lst
target: /etc/easyhaproxy/cloudflare_ips.lst
deploy:
replicas: 1
placement:
@ -109,7 +109,7 @@ services:
easyhaproxy.http.plugins: "cloudflare"
# Optional: Specify custom IP list path
# easyhaproxy.http.plugin.cloudflare.ip_list_path: "/etc/haproxy/cloudflare_ips.lst"
# easyhaproxy.http.plugin.cloudflare.ip_list_path: "/etc/easyhaproxy/cloudflare_ips.lst"
networks:
- easyhaproxy

View file

@ -83,7 +83,7 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
configs:
- source: jwt_api_pubkey
target: /etc/haproxy/jwt_keys/api_pubkey.pem
target: /etc/easyhaproxy/jwt_keys/api_pubkey.pem
deploy:
replicas: 1
placement:
@ -119,7 +119,7 @@ services:
easyhaproxy.http.plugin.jwt_validator.algorithm: "RS256"
easyhaproxy.http.plugin.jwt_validator.issuer: "https://auth.example.com/"
easyhaproxy.http.plugin.jwt_validator.audience: "https://api.example.com"
easyhaproxy.http.plugin.jwt_validator.pubkey_path: "/etc/haproxy/jwt_keys/api_pubkey.pem"
easyhaproxy.http.plugin.jwt_validator.pubkey_path: "/etc/easyhaproxy/jwt_keys/api_pubkey.pem"
networks:
- easyhaproxy

View file

@ -99,9 +99,9 @@ services:
- /var/run/docker.sock:/var/run/docker.sock
configs:
- source: cloudflare_ips
target: /etc/haproxy/cloudflare_ips.lst
target: /etc/easyhaproxy/cloudflare_ips.lst
- source: jwt_api_pubkey
target: /etc/haproxy/jwt_keys/api_pubkey.pem
target: /etc/easyhaproxy/jwt_keys/api_pubkey.pem
deploy:
replicas: 1
placement:
@ -160,7 +160,7 @@ services:
easyhaproxy.http.plugin.jwt_validator.algorithm: "RS256"
easyhaproxy.http.plugin.jwt_validator.issuer: "https://auth.example.com/"
easyhaproxy.http.plugin.jwt_validator.audience: "https://api.example.com"
easyhaproxy.http.plugin.jwt_validator.pubkey_path: "/etc/haproxy/jwt_keys/api_pubkey.pem"
easyhaproxy.http.plugin.jwt_validator.pubkey_path: "/etc/easyhaproxy/jwt_keys/api_pubkey.pem"
# Block internal/debug paths
easyhaproxy.http.plugin.deny_pages.paths: "/internal,/debug,/metrics"