For Example I have enabled the mTLS in my istio service in STRICT mode. and I have authorization policy that have kind of source.principals rule check.
Now I want to access these rules details like source.principals and source.namespace after request is authenticated and authorized so that I can do more business login in my flask(python) service.
My python code looks like this:
from flask import Flask
app = Flask(__name__)
@app.route("/mutate-hook", methods=['POST'])
def mutate():
source = request.headers.get('source')
# I am expacting source to the source from this: https://istio-releases.github.io/v0.1/docs/reference/config/mixer/attribute-vocabulary.html
print(source)
request_json = request.get_json()
# I am expacting source to the source from this: https://istio-releases.github.io/v0.1/docs/reference/config/mixer/attribute-vocabulary.html
request_source = request_json.get('source')
print(request_source["principal"], request_source['namespace'])