Update plugin paths from /etc/haproxy to /etc/easyhaproxy across tests, configs, and documentation
This commit is contained in:
parent
8532d49642
commit
3fd0fe0d46
9 changed files with 27 additions and 26 deletions
|
|
@ -437,12 +437,12 @@ class ResourceRequest:
|
||||||
```python
|
```python
|
||||||
ResourceRequest(
|
ResourceRequest(
|
||||||
resource_type="directory",
|
resource_type="directory",
|
||||||
path="/etc/haproxy/plugin_data"
|
path="/etc/easyhaproxy/plugin_data"
|
||||||
)
|
)
|
||||||
|
|
||||||
ResourceRequest(
|
ResourceRequest(
|
||||||
resource_type="file",
|
resource_type="file",
|
||||||
path="/etc/haproxy/plugin_config.txt",
|
path="/etc/easyhaproxy/plugin_config.txt",
|
||||||
content="config data",
|
content="config data",
|
||||||
overwrite=True
|
overwrite=True
|
||||||
)
|
)
|
||||||
|
|
@ -471,7 +471,7 @@ class InitializationResult:
|
||||||
def initialize(self) -> InitializationResult:
|
def initialize(self) -> InitializationResult:
|
||||||
return InitializationResult(
|
return InitializationResult(
|
||||||
resources=[
|
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.paths = [] # List of paths that require JWT validation
|
||||||
self.only_paths = False # If true, only specified paths are accessible
|
self.only_paths = False # If true, only specified paths are accessible
|
||||||
# Make JWT_KEYS_DIR configurable via environment variable
|
# 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
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
|
|
@ -1292,7 +1292,7 @@ EASYHAPROXY_JWT_KEYS_DIR=/custom/path/jwt_keys # Plugin-defined env var
|
||||||
class MyPlugin(PluginInterface):
|
class MyPlugin(PluginInterface):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# Make resource directory configurable
|
# 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:
|
def initialize(self) -> InitializationResult:
|
||||||
return InitializationResult(
|
return InitializationResult(
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class PluginManager:
|
||||||
builtin_dir = os.path.join(os.path.dirname(__file__), "builtin")
|
builtin_dir = os.path.join(os.path.dirname(__file__), "builtin")
|
||||||
self._load_plugins_from_directory(builtin_dir, "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):
|
if os.path.exists(self.plugins_dir):
|
||||||
self._load_plugins_from_directory(self.plugins_dir, "external")
|
self._load_plugins_from_directory(self.plugins_dir, "external")
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -264,16 +264,17 @@ class Kubernetes(ProcessorInterface):
|
||||||
|
|
||||||
ssl_hosts = []
|
ssl_hosts = []
|
||||||
|
|
||||||
certbot = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.certbot")
|
annotations = ingress.metadata.annotations or {}
|
||||||
redirect_ssl = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.redirect_ssl")
|
certbot = self._check_annotation(annotations, "easyhaproxy.certbot")
|
||||||
redirect = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.redirect")
|
redirect_ssl = self._check_annotation(annotations, "easyhaproxy.redirect_ssl")
|
||||||
mode = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.mode")
|
redirect = self._check_annotation(annotations, "easyhaproxy.redirect")
|
||||||
listen_port = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.listen_port", 80)
|
mode = self._check_annotation(annotations, "easyhaproxy.mode")
|
||||||
plugins = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.plugins")
|
listen_port = self._check_annotation(annotations, "easyhaproxy.listen_port", 80)
|
||||||
|
plugins = self._check_annotation(annotations, "easyhaproxy.plugins")
|
||||||
|
|
||||||
# Extract plugin-specific configurations
|
# Extract plugin-specific configurations
|
||||||
plugin_annotations = {}
|
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."):
|
if annotation_key.startswith("easyhaproxy.plugin."):
|
||||||
plugin_annotations[annotation_key] = annotation_value
|
plugin_annotations[annotation_key] = annotation_value
|
||||||
|
|
||||||
|
|
|
||||||
2
tests/fixtures/services-with-jwt-validator
vendored
2
tests/fixtures/services-with-jwt-validator
vendored
|
|
@ -7,6 +7,6 @@
|
||||||
"easyhaproxy.http.plugin.jwt_validator.algorithm": "RS256",
|
"easyhaproxy.http.plugin.jwt_validator.algorithm": "RS256",
|
||||||
"easyhaproxy.http.plugin.jwt_validator.issuer": "https://auth.example.com/",
|
"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.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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -652,12 +652,12 @@ class TestJwtValidatorPlugin:
|
||||||
"algorithm": "RS512",
|
"algorithm": "RS512",
|
||||||
"issuer": "https://auth.example.com/",
|
"issuer": "https://auth.example.com/",
|
||||||
"audience": "https://api.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.algorithm == "RS512"
|
||||||
assert plugin.issuer == "https://auth.example.com/"
|
assert plugin.issuer == "https://auth.example.com/"
|
||||||
assert plugin.audience == "https://api.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)
|
# Test empty values skip validation (use fresh plugin)
|
||||||
plugin2 = JwtValidatorPlugin()
|
plugin2 = JwtValidatorPlugin()
|
||||||
|
|
@ -672,7 +672,7 @@ class TestJwtValidatorPlugin:
|
||||||
plugin2b = JwtValidatorPlugin()
|
plugin2b = JwtValidatorPlugin()
|
||||||
plugin2b.configure({
|
plugin2b.configure({
|
||||||
"algorithm": "RS256",
|
"algorithm": "RS256",
|
||||||
"pubkey_path": "/etc/haproxy/keys/api.pem"
|
"pubkey_path": "/etc/easyhaproxy/keys/api.pem"
|
||||||
})
|
})
|
||||||
assert plugin2b.issuer is None
|
assert plugin2b.issuer is None
|
||||||
assert plugin2b.audience is None
|
assert plugin2b.audience is None
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
# # Edit your EasyHAProxy deployment and add:
|
# # Edit your EasyHAProxy deployment and add:
|
||||||
# # volumeMounts:
|
# # volumeMounts:
|
||||||
# # - name: jwt-keys
|
# # - name: jwt-keys
|
||||||
# # mountPath: /etc/haproxy/jwt_keys
|
# # mountPath: /etc/easyhaproxy/jwt_keys
|
||||||
# # volumes:
|
# # volumes:
|
||||||
# # - name: jwt-keys
|
# # - name: jwt-keys
|
||||||
# # configMap:
|
# # configMap:
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
# # Expected: 200 OK with "App Behind Cloudflare"
|
# # Expected: 200 OK with "App Behind Cloudflare"
|
||||||
#
|
#
|
||||||
# # Check HAProxy config includes Cloudflare IPs
|
# # 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
|
# # Expected: ACL rules for Cloudflare IP ranges
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
|
|
@ -75,7 +75,7 @@ services:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
configs:
|
configs:
|
||||||
- source: cloudflare_ips
|
- source: cloudflare_ips
|
||||||
target: /etc/haproxy/cloudflare_ips.lst
|
target: /etc/easyhaproxy/cloudflare_ips.lst
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
placement:
|
placement:
|
||||||
|
|
@ -109,7 +109,7 @@ services:
|
||||||
easyhaproxy.http.plugins: "cloudflare"
|
easyhaproxy.http.plugins: "cloudflare"
|
||||||
|
|
||||||
# Optional: Specify custom IP list path
|
# 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:
|
networks:
|
||||||
- easyhaproxy
|
- easyhaproxy
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ services:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
configs:
|
configs:
|
||||||
- source: jwt_api_pubkey
|
- source: jwt_api_pubkey
|
||||||
target: /etc/haproxy/jwt_keys/api_pubkey.pem
|
target: /etc/easyhaproxy/jwt_keys/api_pubkey.pem
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
placement:
|
placement:
|
||||||
|
|
@ -119,7 +119,7 @@ services:
|
||||||
easyhaproxy.http.plugin.jwt_validator.algorithm: "RS256"
|
easyhaproxy.http.plugin.jwt_validator.algorithm: "RS256"
|
||||||
easyhaproxy.http.plugin.jwt_validator.issuer: "https://auth.example.com/"
|
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.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:
|
networks:
|
||||||
- easyhaproxy
|
- easyhaproxy
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,9 @@ services:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
configs:
|
configs:
|
||||||
- source: cloudflare_ips
|
- source: cloudflare_ips
|
||||||
target: /etc/haproxy/cloudflare_ips.lst
|
target: /etc/easyhaproxy/cloudflare_ips.lst
|
||||||
- source: jwt_api_pubkey
|
- source: jwt_api_pubkey
|
||||||
target: /etc/haproxy/jwt_keys/api_pubkey.pem
|
target: /etc/easyhaproxy/jwt_keys/api_pubkey.pem
|
||||||
deploy:
|
deploy:
|
||||||
replicas: 1
|
replicas: 1
|
||||||
placement:
|
placement:
|
||||||
|
|
@ -160,7 +160,7 @@ services:
|
||||||
easyhaproxy.http.plugin.jwt_validator.algorithm: "RS256"
|
easyhaproxy.http.plugin.jwt_validator.algorithm: "RS256"
|
||||||
easyhaproxy.http.plugin.jwt_validator.issuer: "https://auth.example.com/"
|
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.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
|
# Block internal/debug paths
|
||||||
easyhaproxy.http.plugin.deny_pages.paths: "/internal,/debug,/metrics"
|
easyhaproxy.http.plugin.deny_pages.paths: "/internal,/debug,/metrics"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue