apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: custom-{{ .To.ServiceName }}
spec:
  selector:
    matchLabels:
      "app": "{{ .To.ServiceName }}"
  action: CUSTOM
  provider:
    name: "{{ .Provider.Name }}"
  rules:
  - to:
    - operation: # HTTP
        ports: [ "{{ (.To.PortForName `http`).WorkloadPort }}", "{{ (.To.PortForName `http2`).WorkloadPort }}" ]
        paths: [ "/custom" ]
        methods: [ "GET" ]
  - to:
    - operation: # GRPC
        ports: [ "{{ (.To.PortForName `grpc`).WorkloadPort }}" ]
        paths: [ "/proto.EchoTestService/Echo" ]
        methods: [ "POST" ]
  - to:
    - operation: # TCP
        ports: [ "{{ (.To.PortForName `tcp`).WorkloadPort }}" ]
