How can I access header data for my AuthZ request?...
# talk-oathkeeper
c
How can I access header data for my AuthZ request? I tried
Copy code
"orig_address": "{{ .MatchContext.Header.Get \"x-forwarded-for\" }}
as descibed in https://www.ory.sh/docs/oathkeeper/pipeline#session but Oathkeeper throws a
Copy code
{
  "audience": "application",
  "authorization_handler": "remote_json",
  "error": {
    "message": "template: 804bdd63c9d640e41404db676c8576973540f2e2e5088df63a8b140e6b792ea3:8: unexpected \"\\\\\" in operand"
  },
  "granted": false,
  "http_host": "...",
  "http_method": "GET",
  "http_url": "https://...",
  "http_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0",
  "level": "warning",
  "msg": "The authorization handler encountered an error",
  "reason_id": "authorization_handler_error",
  "rule_id": "api:custom-app-protected",
  "service_name": "ORY Oathkeeper",
  "service_version": "v0.38.25-beta.1",
  "subject": "4d8a5195-fa74-4742-a515-b242e32a0a17",
  "time": "2022-06-20T12:31:41Z"
}
s
I don't think you have to escape the quotes, as we first process the go template and then produce string output for the json payload
the docs sometimes unfortunately contain wrong escaping. sorry for that
@magnificent-energy-493 @damp-sunset-69236
c
Thanks, that would have been my guess as well. But this just throws a different kind of error
Copy code
...
"ip": "{{ .MatchContext.Header.Get Host }}"
...
Copy code
{
  "audience": "application",
  "error": {
    "message": "template: 908274a47c78e96b4d42bb243c37391f754ddf6c789e4fa54b9b72a7ac29fb18:8: function \"Host\" not defined"
  },
  "granted": false,
  "http_host": "...",
  "http_method": "GET",
  "http_url": "https://...",
  "http_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0",
  "level": "warning",
  "msg": "Access request denied",
  "service_name": "ORY Oathkeeper",
  "service_version": "v0.38.25-beta.1",
  "time": "2022-06-20T14:46:55Z"
}
Oops, you meant to not escape the quotes at all instead of omitting them. This works now. Thanks 🙂
s
nice, could you by any chance open a PR to fix the documentation? ❤️