{{- $values := .Values }}
{{- $namespace := ( printf "ix-%s" .Release.Name ) }}
{{- if or ( not .Values.ingressClass.enabled ) ( and ( .Values.ingressClass.enabled ) ( .Values.ingressClass.isDefaultClass ) ) }}
{{- $namespace = "default" }}
{{- end }}
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: tc-opencors-headers
  namespace: {{ $namespace }}
spec:
  headers:
    accessControlAllowHeaders:
    - '*'
    accessControlAllowMethods:
    - GET
    - OPTIONS
    - HEAD
    - PUT
    - POST
    accessControlAllowOriginList:
    - '*'
    accessControlMaxAge: 100
    browserXssFilter: true
    contentTypeNosniff: true
    customRequestHeaders:
      X-Forwarded-Proto: https
    customResponseHeaders:
      X-Robots-Tag: none
      server: ""
    forceSTSHeader: true
    referrerPolicy: same-origin
    sslForceHost: true
    sslRedirect: true
    stsSeconds: 63072000
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: tc-closedcors-headers
  namespace: {{ $namespace }}
spec:
  headers:
    accessControlAllowMethods:
      - GET
      - OPTIONS
      - HEAD
      - PUT
    accessControlMaxAge: 100
    sslRedirect: true
    stsSeconds: 63072000
    # stsIncludeSubdomains: false
    # stsPreload: false
    forceSTSHeader: true
    contentTypeNosniff: true
    browserXssFilter: true
    sslForceHost: true
    referrerPolicy: same-origin
    customRequestHeaders:
      X-Forwarded-Proto: "https"
    customResponseHeaders:
      X-Robots-Tag: 'none'
      server: ''
