<commit_before># Defines templates and a rule that connects to Apigee "helloworld" Proxy
# Configuration
#   apigeeproxy values must equal the name of a proxy you created on Apigee
#   The apikey value defines where to get the apikey - default is `apikey` header
#   The default rule below matches any Istio-enabled services
---
# instance configuration for template 'auth'
apiVersion: "config.istio.io/v1alpha2"
kind: auth
metadata:
  name: apigee
  namespace: istio-system
spec:
  apikey: request.headers["apikey"] | ""
  uripath: request.path | "/"
  apigeeproxy: '"helloworld"'
---
# instance configuration for template 'logentry'
apiVersion: "config.istio.io/v1alpha2"
kind: logentry
metadata:
  name: apigee
  namespace: istio-system
spec:
  severity: '"Default"'
  timestamp: request.time
  variables:
    apikey: request.headers["apikey"] | "" # HACK
    apigeeproxy: '"helloworld"'
    response_status_code: response.code | 0
    client_ip: source.ip | ip("0.0.0.0")
    request_verb: request.method | ""
    request_uri: request.path | ""
    request_path: request.path | ""
    useragent: request.useragent | ""
    client_received_start_timestamp: request.time
    client_received_end_timestamp: request.time
    client_sent_start_timestamp: response.time
    client_sent_end_timestamp: response.time
  monitoredResourceType: '"UNSPECIFIED"'
---
# rule to dispatch to handler 'apigee-handler'
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
  name: apigee
  namespace: istio-system
spec:
  match: "true"
  actions:
  - handler: apigee-handler.apigee
    instances:
    - apigee.auth
    - apigee.logentry
---<commit_msg>add a rule to deny all reqs without apikey - workaround for mixer bug<commit_after># Defines templates and a rule that connects to Apigee "helloworld" Proxy
# Configuration
#   apigeeproxy values must equal the name of a proxy you created on Apigee
#   The apikey value defines where to get the apikey - default is `apikey` header
#   The default rule below matches any Istio-enabled services
---
# instance configuration for template 'auth'
apiVersion: "config.istio.io/v1alpha2"
kind: auth
metadata:
  name: apigee
  namespace: istio-system
spec:
  apikey: request.headers["apikey"] | ""
  uripath: request.path | "/"
  apigeeproxy: '"helloworld"'
---
# instance configuration for template 'logentry'
apiVersion: "config.istio.io/v1alpha2"
kind: logentry
metadata:
  name: apigee
  namespace: istio-system
spec:
  severity: '"Default"'
  timestamp: request.time
  variables:
    apikey: request.headers["apikey"] | "" # HACK
    apigeeproxy: '"helloworld"'
    response_status_code: response.code | 0
    client_ip: source.ip | ip("0.0.0.0")
    request_verb: request.method | ""
    request_uri: request.path | ""
    request_path: request.path | ""
    useragent: request.useragent | ""
    client_received_start_timestamp: request.time
    client_received_end_timestamp: request.time
    client_sent_start_timestamp: response.time
    client_sent_end_timestamp: response.time
  monitoredResourceType: '"UNSPECIFIED"'
---
# rule: dispatch to handler 'apigee-handler'
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
  name: apigee
  namespace: istio-system
spec:
#  match: destination.labels["gateway"]=="apigee"
  match: "true"
  actions:
  - handler: apigee-handler.apigee
    instances:
    - apigee.auth
    - apigee.logentry
---

# hack to workaround Mixer bug: deny all requests without apikey header
apiVersion: "config.istio.io/v1alpha2"
kind: denier
metadata:
  name: reject-missing-api-key
  namespace: istio-system
spec:
  status:
    code: 401
    message: Unauthorized
---
apiVersion: "config.istio.io/v1alpha2"
kind: checknothing
metadata:
  name: reject-missing-api-key
  namespace: istio-system
spec:
---
apiVersion: "config.istio.io/v1alpha2"
kind: rule
metadata:
  name: reject-missing-api-key
  namespace: istio-system
spec:
  match: (request.headers["apikey"] | "AREYOUKIDDINGME?") == "AREYOUKIDDINGME?"
  actions:
  - handler: reject-missing-api-key.denier
    instances:
    - reject-missing-api-key.checknothing
{'fraction_non_alphanumeric': 0.1092108477889079, 'fraction_numerical': 0.007573906669924261, 'mean_word_length': 4.1175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5152615', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1349, 'n_words': 350}