Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing an Artifactory/Maven Repo that requires basic-auth

Tags:

I have an Artifactory repo that sits behind basic authentication. How would I configure the settings.xml to allow access?

<mirrors>     <mirror>         <id>artifactory</id>         <mirrorOf>*</mirrorOf>         <url>https://myserver.example.com/artifactory/repo</url>         <name>Artifactory</name>     </mirror> </mirrors> <servers>     <!--         This server configuration gives your personal username/password for         artifactory. Note that the server id must match that given in the         mirrors section.     -->     <server>         <id>Artifactory</id>         <username>someArtifactoryUser</username>         <password>someArtifactoryPassword</password>     </server> 

So server tag is the user credentials for the artifactory user, but I also need to provide another user/password to get through the basic-auth. Where would I put that?!?

like image 351
harschware Avatar asked Aug 14 '09 23:08

harschware


People also ask

How do I use JFrog Artifactory with Maven?

Once you have created your Maven repository, go to Application | Artifactory | Artifacts, select your Maven repository and click Set Me Up. In the Set Me Up dialog, click Generate Maven Settings. You can now specify the repositories you want to configure for Maven.

How do you unlock JFrog?

Unlocking User Accounts An administrator can unlock all locked-out users by clicking Unlock All Users in the User Management | Settings page where user locking is configured. An administrator can also unlock a specific user or a group of users in User Management | Users.

What is Artifactory API key?

API Key. Artifactory allows authentication for REST API calls using your API key as an alternative to your username and password in two ways: either by using the X-JFrog-Art-API header with which you can specify an API key , or through basic authentication using your username and API key (instead of your password).


2 Answers

The username and password go in the server settings as you have them. I think your problem is that you've specified the server by its name (Artifactory), rather than its id (artifactory).

I'd recommend you put the server settings in your user settings rather than the global settings. You can also encrypt the password in Maven 2.1.0+, see the mini guide for details.

Update: What version of Artifactory are you using? There is a discussion and corresponding issue that basic-auth fails. This has apparently been fixed in 2.0.7 and 2.1.0.

From the discussion, it seems that a workaround is to pass the properties via the command line, e.g.

-Dhttp.proxyHost=proxy -Dhttp.proxyPort=8080 -Dproxy.username=... -Dhttp.password=...  

Update: To let your Maven installation connect through a firewall, you'll need to configure the proxy section of the settings.xml, see this question for some pointers on doing that.


Update2: There are additional properties you can set in the server settings, see this blog for some background. I've not had an opportunity to test this, but from the blog and related http wagon javadoc, it appears you can set authenticationInfo on the server settings, something like this:

<server>     <id>Artifactory</id>   <username>someArtifactoryUser</username>   <password>someArtifactoryPassword</password>   <configuration>       <authenticationInfo>       <userName>auth-user</userName>       <password>auth-pass</password>     </authenticationInfo>   </configuration>   </server>  
like image 68
Rich Seller Avatar answered Sep 19 '22 08:09

Rich Seller


I was able to use the following configuration to enable HTTP basic authentication - by writing the necessary HTTP headers manually. In my situation I used it to access the build artifacts on my Go server as a poor man's staging repository.

    <server>         <id>go</id>         <configuration>             <httpHeaders>                 <property>                     <name>Authorization</name>                     <!-- Base64-encoded "guest:guest" -->                     <value>Basic Z3Vlc3Q6Z3Vlc3Q=</value>                 </property>             </httpHeaders>         </configuration>     </server> 
like image 38
Esko Luontola Avatar answered Sep 20 '22 08:09

Esko Luontola