$ istioctl version --remote
client version: 1.8.2
control plane version: 1.8.2
data plane version: 1.8.2 (9 proxies)
$ kubectl version --short
Client Version: v1.18.10
Server Version: v1.18.10
Istio was installed using Helm.
$ helm version --short
v3.3.1+g249e521
my JWT:
{
...
"iss": "https://test.qq/auth/realms/master",
...
}
$ cat test_auth_pol.yaml
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: jwt-allow-platform-admin
namespace: istio-system
spec:
selector:
matchLabels:
app: front-admin
action: ALLOW
rules:
- when:
- key: request.auth.claims[iss]
values: ["*"]
$ kubectl apply -f test_auth_pol.yaml
$ kubectl logs istiod-c578b5969-hfhlt -n istio-system -f|grep authorization
2021-01-30T05:21:11.629653Z debug authorization builder/builder.go:141 rule ns[istio-system]-policy[jwt-allow-platform-admin]-rule[0] generated policy: permissions:{and_rules:{rules:{any:true}}} principals:{and_ids:{ids:{or_ids:{ids:{metadata:{filter:"istio_authn" path:{key:"request.auth.claims"} path:{key:"iss"} value:{list_match:{one_of:{string_match:{safe_regex:{google_re2:{} regex:".+"}}}}}}}}}}}
$ kubectl exec front-admin-5c6c5bb7c5-pcs8g -c istio-proxy -n cp-front-admin – pilot-agent request GET config_dump|less
"principals": [
{
"and_ids": {
"ids": [
{
"or_ids": {
"ids": [
{
"metadata": {
"filter": "istio_authn",
"path": [
{
"key": "request.auth.claims"
},
{
"key": "iss"
}
],
"value": {
"list_match": {
"one_of": {
"string_match": {
"safe_regex": {
"google_re2": {},
"regex": ".+"
}
}
}
}
}
}
}
]
}
}
]
}
}
]
But after successful authentication in keycloak, I get “RBAC: access denied”.
Everything goes fine if I go to other services in the service mesh.
I’ve tried several variations of request.auth.claims, but none of them work. I took the data from the valid JWT. The data was not nested.
$ kubectl logs front-admin-5c6c5bb7c5-pcs8g -c istio-proxy -n cp-front-admin -f
2021-01-30T04:30:50.854804Z debug envoy rbac enforced denied
Any ideas on how can I fix this behavior?