Skip to content

Commit 3833c23

Browse files
committed
Add missing public path and make logging level configurable
1 parent 837cb67 commit 3833c23

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

.github/workflows/labs64io-docker-publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,15 @@ jobs:
5050
labs64/api-gateway:${{ steps.get_release_tag.outputs.RELEASE_TAG }}
5151
cache-from: type=gha,scope=${{ github.workflow }}
5252
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
53+
54+
- name: Build and push Traefik AuthProxy Docker image
55+
uses: docker/build-push-action@v6
56+
with:
57+
context: ./traefik-authproxy
58+
push: true
59+
platforms: linux/amd64,linux/arm64/v8
60+
tags: |
61+
labs64/traefik-authproxy:latest
62+
labs64/traefik-authproxy:${{ steps.get_release_tag.outputs.RELEASE_TAG }}
63+
cache-from: type=gha,scope=${{ github.workflow }}-traefik-authproxy
64+
cache-to: type=gha,mode=max,scope=${{ github.workflow }}-traefik-authproxy

traefik-authproxy/traefik_authproxy.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
from jose import jwt
99
from jose.exceptions import JWTError, ExpiredSignatureError
1010

11+
# --- Caches ---
12+
DISCOVERY_CACHE: Dict[str, Any] = {}
13+
JWKS_CACHE: Dict[str, Any] = {}
14+
1115
# --- Configuration ---
1216
KEYCLOAK_URL = os.getenv("KEYCLOAK_URL", "http://keycloak.tools.svc.cluster.local")
1317
KEYCLOAK_REALM = os.getenv("KEYCLOAK_REALM", "default")
@@ -19,14 +23,14 @@
1923
KEYCLOAK_AUDIENCE = os.getenv("KEYCLOAK_AUDIENCE", "account")
2024
ROLE_MAPPING_FILE = os.getenv("ROLE_MAPPING_FILE", "role_mapping.yaml")
2125

22-
# --- Caches ---
23-
DISCOVERY_CACHE: Dict[str, Any] = {}
24-
JWKS_CACHE: Dict[str, Any] = {}
26+
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO").upper()
27+
LOG_FORMAT = "%(asctime)s - %(levelname)s - %(message)s"
2528

2629
# --- Logging ---
27-
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
28-
app_logger = logging.getLogger("forwardauth")
29-
app_logger.setLevel(logging.DEBUG)
30+
numeric_level = getattr(logging, LOG_LEVEL, logging.INFO)
31+
logging.basicConfig(level=numeric_level, format=LOG_FORMAT)
32+
app_logger = logging.getLogger("traefik_authproxy")
33+
app_logger.setLevel(numeric_level)
3034

3135
# --- App Initialization ---
3236
app = FastAPI(
@@ -150,6 +154,7 @@ def is_public_path(path: str) -> bool:
150154
@app.post("/auth")
151155
async def authenticate(request: Request):
152156
forwarded_uri = request.headers.get("X-Forwarded-Uri", "/")
157+
app_logger.debug(f"Received request on forwarded URI: {forwarded_uri}")
153158

154159
if is_public_path(forwarded_uri):
155160
app_logger.info(f"Public access granted to: {forwarded_uri}")

0 commit comments

Comments
 (0)