Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic Authentication Not Working as Expected - Can't Even Get Version Number #813

Open
joshglenn opened this issue Oct 3, 2024 · 0 comments

Comments

@joshglenn
Copy link

I'm encountering an issue with basic authentication when using ArangoJS to connect to my ArangoDB instance. The authentication information provided in the constructor or via the useBasicAuth method doesn't seem to be applied correctly to the requests.

I am able to do what I want to do if I use curl or python. But using node, it doesn't work.

Environment:

  • ArangoJS version: [email protected]
  • ArangoDB Version: 3.12.2
  • Node.js version: 20.9.0
  • Operating System: Windows 11 host / ArrangoDB running in docker container with port exposed to host

Steps to Reproduce:

  1. Set up an ArangoDB instance using docker with the command docker run -e ARANGO_ROOT_PASSWORD=openSesame -e ARANGO_NO_AUTH=1 -p 8529:8529 -v arangodb_data:/var/lib/arangodb3 arangodb/arangodb:latest --http.trusted-origin "*"
  2. Attempt to make a request (e.g., fetching the database version).

Expected Behavior:
The request should include the proper authentication headers and successfully authenticate with the database.

Actual Behavior:
The request is made without authentication headers, resulting in an authentication failure.

Code Example:

const { Database } = require('arangojs');

const db = new Database({
    url: 'http://localhost:8529',
    databaseName: '_system',
    auth: { username: 'root', password: 'yourPassword' }
});

async function getVersion() {
    try {
        const version = await db.version();
        console.log('ArangoDB Version:', version);
    } catch (err) {
        console.error('Failed to fetch version:', err);
    }
}

getVersion();

Debugging Information:
When inspecting the Connection object after construction and before making a request, I noticed that the _requestConfig.credentials property is set to "same-origin" instead of containing the provided authentication information.

Additional Notes:

  • The connection works correctly when starting the ArangoDB container with -e ARANGO_NO_AUTH=1, confirming that the issue is specifically related to authentication.

Any assistance in resolving this issue would be awesome. I'm two days into trying to get this solved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant