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

Authentication with additional_headers is not possible #265

Closed
dennis-ge opened this issue Mar 17, 2023 · 1 comment · Fixed by #267
Closed

Authentication with additional_headers is not possible #265

dennis-ge opened this issue Mar 17, 2023 · 1 comment · Fixed by #267

Comments

@dennis-ge
Copy link
Contributor

Bug Description

When creating a new client, setting the Authorization header via the additional_headers parameter is not working:

weviate_client = client.Client(
        url="http://localhost:8080",
        additional_headers={"Authorization:": "Bearer xyz"},
    )

The following error is thrown:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../venv/lib/python3.10/site-packages/weaviate/client.py", line 146, in __init__
    self._connection = Connection(
  File ".../venv/lib/python3.10/site-packages/weaviate/connect/connection.py", line 580, in __init__
    super().__init__(
  File ".../venv/lib/python3.10/site-packages/weaviate/connect/connection.py", line 117, in __init__
    self._create_session(auth_client_secret)
  File ".../venv/lib/python3.10/site-packages/weaviate/connect/connection.py", line 180, in _create_session
    raise AuthenticationFailedException(msg)
weaviate.exceptions.AuthenticationFailedException: "No login credentials provided. The weaviate instance at http://localhost:8080 requires login credentials.

                    Please check our documentation at https://weaviate.io/developers/weaviate/client-libraries/python#authentication
                    for more information about how to use authentication.

This error is thrown in the _create_session method because the used weviate instance has an OIDC configuration but no auth_client_secret was provided.

I also saw that a previous issue (#177) already adressed this, but the proposed solution didn't fix it.

Proposed Solution

The case when an Authorization header is present in the additional_headers dict can be handled in the same way as the newly introduced AuthApiKey at the top of the _create_session. If the header is present in the private _headers dict of the BaseConnection, a new session can be created and the method can be exited.

I can also provide a PR if wanted.

@dirkkul
Copy link
Collaborator

dirkkul commented Mar 18, 2023

I can also provide a PR if wanted.

That would be great, your proposed solutions sounds good. Please with a test in this file :)

dennis-ge added a commit to dennis-ge/weaviate-python-client that referenced this issue Mar 18, 2023
fixes weaviate#265

Test 'test_auth_header_with_catchall_proxy' was modified because the
OIDC configuration endpoint is not called anymore when the
authentication is provided via the 'additional_headers' parameter. Apart
from 'ApiAuthKey' any other auth method can be used.
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

Successfully merging a pull request may close this issue.

2 participants