-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I bypass Dex or use a proper secure way to access inferenceservices? #2575
Comments
This is what the log looks like in KubeFlow 1.5 with the Dex bypass described above:
Requests go to Knative and not to Central Dashboard. |
There is a difference in the output for the command
For version 1.8:
In the first case, the service address ends with |
There is a difference in the output for the command
For version 1.8:
No kubeflow/kubeflow-gateway specified for version 1.8. |
@juliusvonkohout, it seems impossible to do inference from the outside. Virtual Services of Inference Services do not contain a gateway looking out (kubeflow-gateway). |
Can you join the next manifest WG meeting for discussion? It has been possible before. Can you use path based routing? Why do you not want the oidc-authservice token based authorization? |
Yes, I can join the discussion. |
Any conclusion to this issue? Looking for the exact same solution where I want to bypass the oidc authuservice when exposing the Inference service to outside the cluster while making use of istio. Facing the same issue where the requests end up going to central dashboard. |
Patching the knative configmap config-domain with a custom domain atleast updates the virtual service so that it makes use of the kubeflow-gateway for external traffic. |
Got it to work with the authentication where I could pass the Cookie authservice_session. But would be better if we could have an option to bypass this. |
Unfortunately, I was never able to beat Dex in version 1.8. In addition, I was never able to access the InferenceService from the outside. @ksgnextuple, are you able to at least access InferenceService with a session? |
Yes @yurkoff-mv |
@ksgnextuple, сan you share the output of the following command? |
@yurkoff-mv I am not using dex, but the oidc-uservice. Here is the output:
|
I also had to update knative config domain, that was the key
|
@yurkoff-mv Which ConfigMap are you adding the extension provider? I haven't tried the steps you had mentioned for bypassing auth on my setup yet |
@yurkoff-mv Was able to achieve it. Disabled session token as well for Infer endpoints. Though not recommended for a production setup. We wanted it for our nonprod env. |
Thank you! It's interesting that
I didn't change the ConfigMap
How did you disable the session token? |
@yurkoff-mv The same steps you had mentioned above for disabling the session token. For the kubeflow-gateway to come up the knative configmap needs to be updated in the way I had mentioned. Reference on Knative website -> https://knative.dev/docs/serving/using-a-custom-domain/ |
https://kserve.github.io/website/0.10/admin/serverless/serverless/#1-install-knative-serving - Look at the warning here too. The changes was mostly from knative side |
@ksgnextuple, thank you very much! It worked for me! Now I will try to bypass authorization for the inference service. |
@ksgnextuple, Could you please provide your ConfigMap for clarity? |
|
It’s similar for me. Only when I try to perform inference I get
It’s also strange that there was no EnvoyFilter |
I had to remove the authn-filter Envoy filter. This RBAC access denied i think seems to be triggered by the global deny auth policy. Not too sure though. |
@ksgnextuple, thank you for the help. This is what the Extension Provider looks like for OAuth2-proxy:
Its definition can be found in the following yaml file. |
Yes, I did it!
For testing in Python:
Output:
Alternative for curl in console...
Request:
Response:
|
@yurkoff-mv @ksgnextuple this looks more like introducing a security flaw than using proper tokens from serviceaccounts with oauth2-proxy. I am very open to merge something with proper authentication. CC @kromanow94 |
@juliusvonkohout It was actually just more of a 'is it possible scenario' to bypass auth, ideally not recommended off course. And the changes we had to do were at auth, Isio and Knative level. |
I agree with Julius that this is making the setup less secure but if you really want to do this, the AuthorizationPolicy provided in this comment #2575 (comment) would be the way to go. In general, using AuthorizationPolicies is the preferred way of configuring authorization with the recent changes for Authz introduced in #2544. But, please consider using M2M tokens, functionality natively integrated with oauth2-proxy/istio, also configured as part of latest changes around Authz. Considering the above example in python, it should be enough to do: export TOKEN="$(kubectl -n kubeflow-user-example-com create token default-editor)"
export AUTHORIZATION = "Bearer: ${TOKEN}" AUTHORIZATION = os.getenv("AUTHORIZATION")
KUBEFLOW_ENDPOINT = "http://127.0.0.1:32333" # Cluster IP and port
MODEL_NAME = "sklearn-iris"
SERVICE_HOSTNAME = "sklearn-iris.kubeflow-user-example-com.example.com"
PREDICT_ENDPOINT = f"{KUBEFLOW_ENDPOINT}/v1/models/{MODEL_NAME}:predict"
iris_input = {"instances": [[6.8, 2.8, 4.8, 1.4], [6.0, 3.4, 4.5, 1.6]]}
res = requests.post(
url=PREDICT_ENDPOINT,
headers={"Host": SERVICE_HOSTNAME, "Content-Type": "application/json", "Authorization": AUTHORIZATION},
json=iris_input,
timeout=200,
)
print("Status Code: ", res.status_code)
print("Response: ", res.json()) With the above, you should be able to just use the latest |
@diegolovison is this something for the /contrib/kserve documentation? |
Looking at https://www.kubeflow.org/docs/external-add-ons/kserve/first_isvc_kserve/ I don't see any reference about |
@diegolovison probably because this is something considered to be relatively new. The setup with |
maybe if we document the secured way and have a note about how to disable it? |
The method didn't work for me. Redirects to http://127.0.0.1:32333/dex/auth?approval_prompt=force&client_id=kubeflow-oidc-authservice&code_challenge=C0155PrMpdTfBQl_e-_8MNDGph-JACiFFforSNGulGg&code_challenge_method=S256&redirect_uri=%2 Foauth2%2Fcallback&response_type=code&scope=profile+email+groups+openid&state=GEEipbxgOIyZ -TD71Dqi9E74OQ6oI6SdtvEkZIynS_Y%3A%2Fv1%2Fmodels%2Fsklearn-iris%3Apredict |
I did some investigation and I found out that this is because the So, I see two options:
@juliusvonkohout do you think we should add this |
Yes we should do so, because at some point this should be possible out of the Box. I have to deep dive into the gateways and kserve again, but maybe that is something for 1.10, because i will be very busy wit other stuff over the next weeks, especially GSOC. |
@kromanow94, This is don't working for external access. In general, it is necessary to add an initial Knative configuration to access scripts from outside the cluster. I don't see the point in using a cluster locally.
Please try:
|
My example:
|
you also have to expose kserve with different routing and probably an additional virtual service. Because the hostname based kserve routing does not work trough the ingressgateway. This is how i got it working years ago. But like i said i might come back to this in proper detail over the next months. |
Thanks Guys for the info. This worked for me.
|
this will open all the the whole kubeflow dashboard. is thre any solution just only open the inference servive only |
Lets continue with secure stuff in #2811 |
Whether the request was successfully received outside the cluster |
#2811 i will lock this issue here. |
In version 1.5 i was able to bypass Dex using extension provider.
I added it to the istio configmap:
and
Then I removed the filter and restarted istiod:
microk8s kubectl delete -n istio-system envoyfilters.networking.istio.io authn-filter
microk8s kubectl rollout restart deployment/istiod -n istio-system
After these manipulations, I could access Inference Services at the address
http://host_ip:host_port/v1/models/model_name:predict
without the need for authorization, since all requests from /v1* went bypassing Dex. Now I'm getting a 404 error.It seems that requests are redirected to the central dashboard...
microk8s kubectl logs -n istio-system istio-ingressgateway-8f46b776-8sbt5
Request:
How do I bypass Dex?
P.S. I can't get session.
The text was updated successfully, but these errors were encountered: