kura
kura copied to clipboard
Unable to install package with basic authentication
Describe the bug The download/install via URL is not capable to process URLs with user/pass authentication included.
To Reproduce
- Go to Packages tab -> Install/Upgrade package -> URL
- Insert a url with format https://username:[email protected]/packages/package1.dp
- Install fails with
2019-10-23T14:22:30,038 [DeploymentAgent] ERROR o.e.k.d.a.i.DeploymentAgent - Exception installing package at URL https://username:[email protected]/packages/package1.dp
java.io.IOException: Server returned HTTP response code: 401 for URL: https://username:[email protected]/packages/package1.dp
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1900) ~[?:1.8.0_232]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498) ~[?:1.8.0_232]
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:268) ~[?:1.8.0_232]
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.getFileFromRemote(DeploymentAgent.java:492) ~[?:?]
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.installDeploymentPackageInternal(DeploymentAgent.java:441) ~[?:?]
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.installer(DeploymentAgent.java:309) ~[?:?]
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.lambda$0(DeploymentAgent.java:173) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_232]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_232]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_232]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_232]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]
The URL works perfectly when used from curl
.
Expected behavior Authentication is processed and package installed.
Target Environment:
- OS version: Linux -- 4.4.0-cip #1 Thu Jan 31 17:58:56 CST 2019 armv7l GNU/Linux
- Additional info: Debian 9
Turned out it was the SSL the issue. We're working on it but it doesn't look like a Kura problem so I'm closing this issue.
SSL issue solved, but the authentication problem remains. Is this an expected behaviour? How could basic authentication be achieved?
From a brief look that should be the format for basic authentication. Did you try with another tool to see if that resolves correctly?
Exactly the same URL works with curl or wget in the same device.
To remove any doubt, I've created a reproducible example.
-
Launch two Kura containers, one with host network configuration:
docker run --name kura1 --net host -d eclipse/kura docker run --name kura2 -p 8081:8080 -d eclipse/kura
-
Enter in http://localhost:8080/kura with default credentials.
-
Try to install a package via URL from http://admin:admin@localhost:8081
-
Receive the error:
2020-01-10T10:30:52,712 [qtp83912762-73] INFO o.e.k.w.s.s.FileServlet - Installing package... 2020-01-10T10:30:52,712 [DeploymentAgent] INFO o.e.k.d.a.i.DeploymentAgent - About to install package at URL http://admin:admin@localhost:8081/kura 2020-01-10T10:30:53,242 [DeploymentAgent] ERROR o.e.k.d.a.i.DeploymentAgent - Exception installing package at URL http://admin:admin@localhost:8081/kura java.io.IOException: Server returned HTTP response code: 401 for URL: http://admin:admin@localhost:8081/kura at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492) at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.getFileFromRemote(DeploymentAgent.java:498) at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.installDeploymentPackageInternal(DeploymentAgent.java:450) at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.execInstall(DeploymentAgent.java:323) at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.installer(DeploymentAgent.java:307) at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.lambda$0(DeploymentAgent.java:172) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) 2020-01-10T10:30:53,243 [DeploymentAgent] INFO o.e.k.d.a.i.DeploymentAgent - Posting INSTALLED event for package at URL http://admin:admin@localhost:8081/kura: unsuccessful
Not that such URL could ever install anything, but the authentication should be properly achieved and it should give an error similar to:
2020-01-10T10:38:10,381 [qtp83912762-77] INFO o.e.k.w.s.s.FileServlet - Installing package...
2020-01-10T10:38:10,381 [DeploymentAgent] INFO o.e.k.d.a.i.DeploymentAgent - About to install package at URL http://www.google.com
2020-01-10T10:38:10,528 [DeploymentAgent] ERROR o.e.k.d.a.i.DeploymentAgent - Exception installing package at URL http://www.google.com
org.osgi.service.deploymentadmin.DeploymentException: No manifest present in deployment package!
at org.apache.felix.deploymentadmin.DeploymentAdminImpl.installDeploymentPackage(DeploymentAdminImpl.java:178)
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.installDeploymentPackageInternal(DeploymentAgent.java:464)
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.execInstall(DeploymentAgent.java:323)
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.installer(DeploymentAgent.java:307)
at org.eclipse.kura.deployment.agent.impl.DeploymentAgent.lambda$0(DeploymentAgent.java:172)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
2020-01-10T10:38:10,530 [DeploymentAgent] INFO o.e.k.d.a.i.DeploymentAgent - Posting INSTALLED event for package at URL http://www.google.com: unsuccessful
Having a look it seems that Java APIs do not support out of the box basic authentication as encoded directly in the URL.
Then, how would you suggest to make this? We are interested in use this service to install from Kapua.
I believe you can use the deployment feature in Kapua that should also support basic authentication. Maybe refer to that project for more info.
And in order to do it directly through the Kura web?
That requires a new feature in develop.
Sorry for the wrong closing. The feature will be part of the Deployment Package Service and integrated from Kapua? Just to be sure before making a decision regarding the deployment procedure.
The support for basic authentication is already there via deploy-v2 in Kapus. It is not there in the url upload from the Kura web ui. Maybe with a contribution, it can be there in the next release.
Ok, I've already achieved it through Kapua with a different configuration thanks to @lorthirk.
@alebianchin Can you take care of this enhancement in local web UI?