I have a repository configured in Nexus that contains projects that are not for public release, but need access from a variety of sites so cannot host it on my LAN. I've therefore put it on a public server and set up the repository in Nexus to require username/password access, which is working fine. But I can't figure out where to put the configuration information for Maven to access this repository... Nexus doesn't seem to understand HTTP basic authentication, so I can't use an http://username:password@host/
URL format for the job. So what can I do to make this work?
Asked
Active
Viewed 2.5k times
5

Jules
- 14,841
- 9
- 83
- 130
-
3We can pass username / password in .m2/settings.xml. Are you looking for that? – Pramod S. Nikam Jun 10 '14 at 05:54
-
Probably. I'm finding this entire setup confusing... how do I associate a username and password with a particular repository, and how does maven know how to log in if basic auth doesn't work, as it appears not to for nexus? – Jules Jun 13 '14 at 06:25
-
possible duplicate of [Accessing an Artifactory/Maven Repo that requires basic-auth](http://stackoverflow.com/questions/1280747/accessing-an-artifactory-maven-repo-that-requires-basic-auth) – Joe Jun 14 '14 at 06:04
-
@Joe I'd agree, except that Nexus doesn't seem to permit basic auth, as I state in the question. – Jules Jun 15 '14 at 00:55
-
(continued from previous comment, which I left open for editing for too long...) It turns out that this doesn't matter, and whatever login scheme Nexus does use is supported by Maven without any additional configuration, but that isn't obvious from either the documentation or the answers on the question you link to, which only discuss using basic auth. – Jules Jun 15 '14 at 01:10
-
Basic auth is not the same thing as putting the username and password in the URL. Nexus supports basic auth, which is exactly what you're using here. Glad you got it working! – Joe Jun 15 '14 at 10:35
-
Username and password in the URL is a way of instructing the browser to use HTTP basic auth, so it is absolutely the same thing... – Jules Jun 16 '14 at 19:25
1 Answers
1
All you have to do is set a server element in settings.xml with your username and password and an id.
For deployment rights use that id in the distributionManagement of your pom file for the snapshotRepository and repository.
For access rights via read you typically do that via a public group and use that same id in the mirror as defined in the settings file. See an example at http://books.sonatype.com/nexus-book/reference/config-maven.html
Now if you want to give access to something only for authenticated users like yourself you create a repository target for that group and then give the appropriate security rights to your user.

Manfred Moser
- 29,539
- 13
- 92
- 123
-
This does seem to work, now I've fixed another problem (I had configured eclipse to use a maven settings.xml in a non-standard location, but it seems that this is only used by eclipse internally, and when you run an external maven target it ignores this file unless you provide the details explicity in your run options... very stupid, but then that's eclipse for you, I guess). Presumably there's (undocumented) support built into maven for whatever authentication scheme nexus uses. – Jules Jun 15 '14 at 01:12
-
Not sure what you are talking about to be honest. The setup above definitely works. – Manfred Moser Jun 16 '14 at 02:32
-
-
4I think it is worth to mention that you just need to add the server credentials in your $MAVEN_ROOT/conf/settings.xml and under
add – DGoiko Oct 28 '19 at 20:05your-server-id username password your-server-id artifactory-releases http://foo.bar:8081/artifactory/bar-foo