# Optional Proposed L7 guard; NOT existing SMS/APIGW security configuration.
# security v1beta1 example; verify support on the installed Istio/CRD release.
# Only works where this sidecar can actually decode the inbound HTTP request.
apiVersion: security.istio.io/v1beta1
kind: RequestAuthentication
metadata:
  name: example-consumer-jwt
  namespace: obrh-example
spec:
  selector:
    matchLabels:
      app: obrh-direct-example
  jwtRules:
  - issuer: https://identity.example.com
    jwksUri: https://identity.example.com/.well-known/jwks.json
    audiences: [obrh-example]
    forwardOriginalToken: true # Keep only if downstream application requires it.
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
  name: example-require-jwt-for-dispatch
  namespace: obrh-example
spec:
  selector:
    matchLabels:
      app: obrh-direct-example
  action: ALLOW
  rules:
  - from:
    - source:
        requestPrincipals: ['*'] # Validated JWT principal, not mesh source.principal.
    to:
    - operation:
        methods: [POST]
        paths: [/obrh/route/dispatch] # Replace with actual sidecar-visible context/path.
    when:
    - key: request.auth.claims[roles]
      values: [obrh.invoke] # Illustrative signed claim, not actual SMS role names.
# An ALLOW policy makes unmatched inbound traffic denied for this selector.
# This is deliberately NOT a deployable whole-workload policy: inventory other routes,
# authenticated restricted diagnostics, and probe capture before composing exceptions.
# Never add a public /health* wildcard allowance just to make probes green.
