Skip to content

Commit b1e4191

Browse files
committed
Init traefik auth proxy
1 parent a08467f commit b1e4191

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

traefik-authproxy/justfile

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
APP_NAME := "traefik_authproxy"
1+
APP_NAME := "traefik-authproxy"
2+
3+
LOCAL_KEYCLOAK := "http://keycloak.localhost"
4+
LOCAL_KEYCLOAK_DOCKER := "http://host.docker.internal:8080"
5+
LOCAL_CLIENT_ID := "labs64io-api-gateway"
6+
LOCAL_CLIENT_SECRET := "mTEqlt1dDzcVyEOzFjBZV4X8jvEkaQnc"
27

38
# build application
49
docker:
@@ -10,12 +15,12 @@ docker:
1015
# run docker image
1116
run: docker
1217
docker run -p 8081:8081 \
13-
-e KEYCLOAK_DISCOVERY_URL="http://host.docker.internal:8080/realms/labs64io/.well-known/openid-configuration" \
14-
-e KEYCLOAK_URL="http://host.docker.internal:8080" \
18+
-e KEYCLOAK_DISCOVERY_URL="{{LOCAL_KEYCLOAK_DOCKER}}/realms/labs64io/.well-known/openid-configuration" \
19+
-e KEYCLOAK_URL="{{LOCAL_KEYCLOAK_DOCKER}}" \
1520
-e KEYCLOAK_REALM="labs64io" \
1621
-e KEYCLOAK_AUDIENCE="account" \
1722
-e ROLE_MAPPING_FILE="/home/l64user/role_mapping.yaml" \
18-
-v $(pwd)/role_mapping.yaml:/home/l64user/role_mapping.yaml \
23+
-v $(pwd)/sample_role_mapping.yaml:/home/l64user/role_mapping.yaml \
1924
{{APP_NAME}}:latest
2025

2126
# open documentation
@@ -26,12 +31,12 @@ docu:
2631

2732
# open Keycloak well-known configuration
2833
test-show-wellknown:
29-
open "http://keycloak.localhost/realms/labs64io/.well-known/openid-configuration"
34+
open "{{LOCAL_KEYCLOAK}}/realms/labs64io/.well-known/openid-configuration"
3035

3136
# generate JWT token
3237
test-generate-jwt-token:
33-
curl --location --request POST 'http://keycloak.localhost/realms/labs64io/protocol/openid-connect/token' \
38+
curl --location --request POST '{{LOCAL_KEYCLOAK}}/realms/labs64io/protocol/openid-connect/token' \
3439
--header 'Content-Type: application/x-www-form-urlencoded' \
3540
--data-urlencode 'grant_type=client_credentials' \
36-
--data-urlencode 'client_id=labs64io-api-gateway' \
37-
--data-urlencode 'client_secret=mTEqlt1dDzcVyEOzFjBZV4X8jvEkaQnc'
41+
--data-urlencode 'client_id={{LOCAL_CLIENT_ID}}' \
42+
--data-urlencode 'client_secret={{LOCAL_CLIENT_SECRET}}'
File renamed without changes.

traefik-authproxy/traefik_authproxy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ def load_role_mapping(file_path: str) -> Tuple[Dict[str, List[str]], List[str]]:
6060
return protected_paths, public_paths
6161

6262
except Exception as e:
63-
app_logger.error(f"load_role_mapping::Failed to load file: {e}")
64-
raise HTTPException(status_code=500, detail="Unable to load role mapping configuration")
63+
app_logger.warning(f"load_role_mapping::Skipping path check – failed to load mapping: {e}")
64+
return {}, []
6565

6666
PROTECTED_PATHS, PUBLIC_PATHS = load_role_mapping(ROLE_MAPPING_FILE)
6767

0 commit comments

Comments
 (0)