Skip to content
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

Unable to install package with basic authentication #2560

Open
pintify opened this issue Oct 23, 2019 · 19 comments
Open

Unable to install package with basic authentication #2560

pintify opened this issue Oct 23, 2019 · 19 comments

Comments

@pintify
Copy link

pintify commented Oct 23, 2019

Describe the bug
The download/install via URL is not capable to process URLs with user/pass authentication included.

To Reproduce

  1. Go to Packages tab -> Install/Upgrade package -> URL
  2. Insert a url with format https://username:[email protected]/packages/package1.dp
  3. 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:

@pintify
Copy link
Author

pintify commented Nov 27, 2019

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.

@pintify
Copy link
Author

pintify commented Jan 10, 2020

SSL issue solved, but the authentication problem remains. Is this an expected behaviour? How could basic authentication be achieved?

@pintify pintify reopened this Jan 10, 2020
@MMaiero
Copy link
Contributor

MMaiero commented Jan 10, 2020

From a brief look that should be the format for basic authentication.
Did you try with another tool to see if that resolves correctly?

@pintify
Copy link
Author

pintify commented Jan 10, 2020

Exactly the same URL works with curl or wget in the same device.

@pintify
Copy link
Author

pintify commented Jan 10, 2020

To remove any doubt, I've created a reproducible example.

  1. 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
  2. Enter in http://localhost:8080/kura with default credentials.

  3. Try to install a package via URL from http://admin:admin@localhost:8081

  4. 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

@MMaiero
Copy link
Contributor

MMaiero commented Jan 10, 2020

Having a look it seems that Java APIs do not support out of the box basic authentication as encoded directly in the URL.

@pintify
Copy link
Author

pintify commented Jan 14, 2020

Then, how would you suggest to make this? We are interested in use this service to install from Kapua.

@MMaiero
Copy link
Contributor

MMaiero commented Jan 14, 2020

I believe you can use the deployment feature in Kapua that should also support basic authentication. Maybe refer to that project for more info.

@pintify
Copy link
Author

pintify commented Jan 14, 2020

And in order to do it directly through the Kura web?

@MMaiero
Copy link
Contributor

MMaiero commented Jan 14, 2020

That requires a new feature in develop.

@pintify pintify closed this as completed Jan 14, 2020
@pintify pintify reopened this Jan 14, 2020
@pintify
Copy link
Author

pintify commented Jan 14, 2020

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.

@MMaiero
Copy link
Contributor

MMaiero commented Jan 14, 2020

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.

@pintify
Copy link
Author

pintify commented Jan 16, 2020

Ok, I've already achieved it through Kapua with a different configuration thanks to @lorthirk.

@MMaiero
Copy link
Contributor

MMaiero commented Feb 5, 2020

@alebianchin Can you take care of this enhancement in local web UI?

@github-actions
Copy link
Contributor

This issue is stale because it has been open for 60 days with no activity.

@github-actions github-actions bot added the Stale label Oct 29, 2023
Copy link
Contributor

This issue was closed because it has been inactive for 14 days since being marked as stale.

@pintify
Copy link
Author

pintify commented Nov 13, 2023

The need still stands and the issue was not fixed.

@mattdibi
Copy link
Contributor

mattdibi commented Nov 13, 2023

Hello there,
thanks for reporting. Still ironing out the details with our newly introduced stale-bot.

With regard to the feature you requested, currently it's not in our backlog (@MMaiero correct me if I'm wrong), but, if you feel adventurous, the change should be pretty straightforward here leveraging the newly introduced Deploy V2 REST api.

@mattdibi mattdibi reopened this Nov 13, 2023
@github-actions github-actions bot removed the Stale label Nov 14, 2023
Copy link
Contributor

This issue is stale because it has been open for 60 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants