Authenticate davfs2 Clients

JFrog Artifactory Documentation

Products
JFrog Artifactory
Content Type
User Guide

Because davfs2 does not use preemptive authentication, the client must be authenticated using two requests in order to authenticate with user credentials. 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.

To access your repository through Artifactory with your full user permissions, you need to add an authorization header to the client configuration. This ensures that all requests sent to Artifactory are preemptively authenticated, eliminating the need for a 401 challenge and response. In this way, you are immediately granted access based on your user credentials instead of being initially treated as an anonymous user.

Anonymous access with Artifactory

If Artifactory is configured to allow anonymous access, there will be no 401 challenge response. You will be granted file access with anonymous user permissions, which may be less than your own user permissions.

To add an authorization header to the client configuration:

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

    Basic ${”<USERNAME>:<PASSWORD>".bytes.encodeBase64()}

    Where:

    • <USERNAME>: Your Artifactory username

    • <PASSWORD>: Your Artifactory password

    For example:

    Basic ${”jeffry:Fr0gP4sswOrd!".bytes.encodeBase64()}
  2. Open one of these configuration files in a text editor:

    • /etc/davfs2/davfs2.conf

    • ~/.davfs2/davfs2.conf

  3. Add the encoded credentials to the authorization header as follows:

    add_header Authorization “Basic <AUTH>”

    Where <AUTH> is the Base64-encoded username and password. For example:

    add_header Authorization “Basic amVmZnJ5OkZyMGdQNHNzd09yZCE=”