Authentication for davfs2 Clients

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide
ft:sourceType
Paligo

Davfs2 does not use preemptive authentication. Therefore, in order to authenticate using the user credentials, the client must be authenticated using two requests. The first request is sent without credentials and receives a 401 challenge in response. Then, a second request is sent, this time with the credentials.

Anonymous access with Artifactory

Artifactory may be configured to allow anonymous access and it will therefore accept requests without authentication.

In this case, Artifactory will not respond with a 401 challenge and you will get file access with anonymous user permissions which may be less than your own user permissions.

To access your repository through Artifactory with your full user permissions you need to add an authorization header to the client configuration. This way, the requests sent to Artifactory will be authenticated and there is no need to receive a 401 challenge and respond with a second request. Thus you are given anonymous access to Artifactory, and yet can still authenticate with your own credentials. This can be done as follows:

  1. Encode your username and password credentials in base64 using the following Groovy script:

    Groovy script

    Basic ${”username:password".bytes.encodeBase64()}
  2. Edit the file /etc/davfs2/davfs2.conf or ~/.davfs2/davfs2.conf and add the encoded credentials to the authorization header as follows:

    Adding authorization header

    add_header Authorization “Basic c2hheTpwYXNzd29yZA==”