Reputation: 1267
I have nginx for my maven repository with basic authorization.
My build.sbt has:
credentials += Credentials("maven repository", "rep.com", "sbt", "password")
resolvers ++= Seq(
"maven repository" at "http://rep.com:8080/"
)
but, sbt can't found module because sbt doesn't use basic authorization.
My nginx logs looks like:
012/07/22 20:02:21 [error] 3338#0: *14 no user/password was provided for basic authentication, client: 8.32.39.29, server: rep.com, request: "HEAD /some/cool_2.9.1/0.1-SNAPSHOT/cool_2.9.1-0.1-SNAPSHOT.pom HTTP/1.1", host: "rep.com:8080"
I don't wanna to publish artifacts through nginx. Basic auth need only for restricted access to artifacts.
How I can restrict access and working with repository in sbt?
Upvotes: 16
Views: 6575
Reputation: 41
I had the same problem with an SVN repository which uses basic AUTH. This post and the one alluded to above got me the answer which I summarise below.
As alluded to above its all about getting the realm correct:
In build.sbt i set my resolver as follows:
resolvers += {
Credentials.add("<realm>", "<svnhost?", "<username>", "<password>")
Resolver.url("name", url("http://<svnhost>/<path>/"))(Resolver.ivyStylePatterns)
}
To find the realm value which is the first param for Credentials.add, i did
curl http://<svn host> -v
and used the Basic Realm value reported in the WWW-Authenticate header:
WWW-Authenticate: Basic realm="<realm>"
Hope this helps.
Upvotes: 2
Reputation: 6020
What about adding the following to your ~/.ivy2/.credentials:
realm=maven repository
host=rep.com:8080
user=username
password=password
and then use Credentials(Path.userHome / ".ivy2" / ".credentials")
you need to ensure that your realm is configured correctly: curl http://rep.com:8080 -vv 2>&1 | egrep "realm|host"
(I might be mistaken, but 'host' may have to match the host header, i.e. rep.com:8080, not just rep.com).
hth
Upvotes: 20
Reputation: 21564
Don't know if it works, but just try adding the basic auth in the URL:
resolvers ++= Seq(
"maven repository" at "http://username:[email protected]:8080/"
)
Upvotes: 0