From 77ab8127f23a17298bb9b0703e00a72ff488dcba Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Wed, 6 Nov 2024 14:17:13 +1100 Subject: [PATCH 1/2] Skip auth for /public endpoints --- k8s/manifest.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/k8s/manifest.yaml b/k8s/manifest.yaml index 99cbdec..b6919af 100644 --- a/k8s/manifest.yaml +++ b/k8s/manifest.yaml @@ -112,6 +112,11 @@ metadata: cert-manager.io/cluster-issuer: "letsencrypt-prod" nginx.ingress.kubernetes.io/auth-url: "https://id.junv.cc/oauth2/auth" nginx.ingress.kubernetes.io/auth-signin: "https://id.junv.cc/oauth2/start?rd=https%3A%2F%2F$host$request_uri" + # Skip authentication for /public + nginx.ingress.kubernetes.io/auth-snippet: | + if ($request_uri ~ "/public") { + return 200; + } spec: tls: - hosts: @@ -139,6 +144,33 @@ spec: name: links port: number: 80 +--- + +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: links-public-ingress + annotations: + kubernetes.io/ingress.class: "nginx" + kubernetes.io/tls-acme: "true" + cert-manager.io/cluster-issuer: "letsencrypt-prod" +spec: + tls: + - hosts: + - go.junv.cc + secretName: links-tls + rules: + - host: go.junv.cc + http: + paths: + - path: /public + pathType: Prefix + backend: + service: + name: links + port: + number: 80 + --- From 150820fa1bc1e18d16806f98159ba2c6d89333eb Mon Sep 17 00:00:00 2001 From: Junwei Zhao Date: Wed, 6 Nov 2024 14:19:21 +1100 Subject: [PATCH 2/2] Remove public ingress --- k8s/manifest.yaml | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/k8s/manifest.yaml b/k8s/manifest.yaml index b6919af..28d720b 100644 --- a/k8s/manifest.yaml +++ b/k8s/manifest.yaml @@ -146,34 +146,6 @@ spec: number: 80 --- -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: links-public-ingress - annotations: - kubernetes.io/ingress.class: "nginx" - kubernetes.io/tls-acme: "true" - cert-manager.io/cluster-issuer: "letsencrypt-prod" -spec: - tls: - - hosts: - - go.junv.cc - secretName: links-tls - rules: - - host: go.junv.cc - http: - paths: - - path: /public - pathType: Prefix - backend: - service: - name: links - port: - number: 80 - - ---- - apiVersion: networking.k8s.io/v1 kind: Ingress metadata: