Hi everyone,
I am working on a PoC of Keto and Oathkeeper for our solution, initially thought we would do a direct integration with Keto but the Oathkeeper API access rules would really simplify our integration so I am trying to figure them out.
We already have an authentication solution in place: Cognito with Apigee gateway performing token verification.
Using a proxy configuration for Oathkeeper, I am trying to create an authorizer rule which which will only allow the requestor access to the mockservice API based on ladon policy I have configured in Keto. I am able to get this flow to work if I use a static value subject that is hardcoded into the rule. However, what I want to do is have the subject value populated by the email value from the Bearer token passed by the requestor.
[{
"id": "keto-api-health",
"upstream": {
"url": "http://keto:4466",
"preserve_host": true,
"strip_path": "/pd/ssup/accesspolicy/v1"
},
"match": {
"url": "http://localhost:4455/pd/ssup/accesspolicy/v1/health/<.*>",
"methods": [
"GET"
]
},
"authenticators": [{
"handler": "noop"
}],
"authorizer": { "handler": "allow" },
"mutators": [{ "handler": "noop" }]
},
{
"id": "mockservice-api-getpets",
"upstream": {
"url": "http://mock-service:4010",
"preserve_host": true,
"strip_path": "/mockservice/v1"
},
"match": {
"url": "http://localhost:4455/mockservice/v1/pets/<.*>",
"methods": [
"GET"
]
},
"authenticators": [{
"handler": "noop"
}],
"authorizer": {
"handler": "keto_engine_acp_ory",
"config": {
"required_action": "get",
"required_resource": "mockservice:pets",
"subject": "{{ .Extra.email }}",
"flavor": "regex"
}
},
"mutators": [{ "handler": "noop" }]
}
]
As my gateway is already performing verification on the JWT bearer token, I just want to read a value from it (email).
In the Oathkeeper documentation, the anonymous handler is used in the rule configuration:
However, when I test this using a Cognito provided id token in my request I get this error from Oathkeeper:
Access request denied" error="Access credentials are invalid"
Am I missing a step here?