I have recently built a POC to test using the ForwardAuth middleware on a traefik v3 IngressRoute to process a firebase token. The ForwardAuth uses a spring boot app to validate and parse the token. The service that the request gets forwarded to is also a spring boot app. We are making calls from a vuejs app. Ultimately, Vue -> Traefik::ForwardAuth -> REST API service.
I will admit I have limited experience with Traefik, and am coming from a little more experience with KONG. I have found that the preflight request (Method.OPTIONS) is failing at the middleware. The only way around it is I either have to remove the ForwardAuth middleware from the IngressRoute or add an extra route to handle the Options method.
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
name: forward-auth
namespace: traefik
spec:
forwardAuth:
address: "http://auth-validator.traefik.svc.cluster.local/api/auth/v1/validate"
trustForwardHeader: true
authResponseHeadersRegex: ^X-
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: api-ingress-route-options
namespace: traefik
annotations:
kubernetes.io/ingress.class: traefik
spec:
entryPoints:
- web
routes:
- match: Host(`example.com`) && PathPrefix(`/api/v1`) && Method(`OPTIONS`)
kind: Rule
services:
- name: rest-api
namespace: external-apis
port: 8080
By doing this the Options call skips the middleware. I feel there has got to be another way, but have not been able to find anything on forums or in the docs.
Any advice on handling CORS with ForwardAuth would be greatly appreciated.