Skip to content

Airflow SambaHook authentication issue with SpnegoError and Kerberos #29590

Closed

Description

@mrBlackHat777

Apache Airflow Provider(s)

samba

Versions of Apache Airflow Providers

I am trying to connect to a Samba server in Airflow using the SambaHook class. The Samba server requires Kerberos authentication.

I have already defined a Samba connection in Airflow using the following parameters: Host,Schema and Extra {"auth": "kerberos"}

airflow connections add "samba_repo" --conn-type "samba" --conn-host "myhost.mywork.com" --conn-schema "fld" --conn-extra '{"auth": "kerberos"}'

I'm trying to use the SambaHook class in Airflow to connect to a Samba server. When I run my code, I get the following error:

Failed to authenticate with server: SpnegoError (1): SpnegoError (16): Operation not supported or available, Context: Retrieving NTLM store without NTLM_USER_FILE set to a filepath, Context: Unable to negotiate common mechanism

However, when I use smbclient to connect to the same server using Kerberos authentication from the Docker terminal, it works fine with the command: smbclient //'myhost'/'fld' -c 'ls "\workpath\*" ' -k

What I tried: I set up a connection to the Samba server in Airflow using the SambaHook class and tried to use the listdirmethod to retrieve a list of files in a specific directory.

What I expected to happen: I expected the listdir method to successfully retrieve a list of files in the specified directory from the Samba server.

What actually resulted: Instead, I encountered the following error message: Failed to authenticate with server: SpnegoError (1): SpnegoError (16): Operation not supported or available, Context: Retrieving NTLM store without NTLM_USER_FILE set to a filepath, Context: Unable to negotiate common mechanism

Apache Airflow version

2.2.0

Operating System

Debian GNU/Linux

Deployment

Docker-Compose

Deployment details

No response

What happened

No response

What you think should happen instead

No response

How to reproduce

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. boring-cyborg commented on Feb 17, 2023

    @boring-cyborg

    Thanks for opening your first issue here! Be sure to follow the issue template!

  2. added and removed
    kind:bugThis is a clearly a bug
    on Feb 17, 2023
  3. Taragolis commented on Feb 17, 2023

    @Taragolis
    Contributor

    I have already defined a Samba connection in Airflow using the following parameters: Host,Schema and Extra {"auth": "kerberos"}

    According to the the sources SambaHook not implements kerberos auth:

    def __init__(self, samba_conn_id: str = default_conn_name, share: str | None = None) -> None:
    super().__init__()
    conn = self.get_connection(samba_conn_id)
    if not conn.login:
    self.log.info("Login not provided")
    if not conn.password:
    self.log.info("Password not provided")
    connection_cache: dict[str, smbprotocol.connection.Connection] = {}
    self._host = conn.host
    self._share = share or conn.schema
    self._connection_cache = connection_cache
    self._conn_kwargs = {
    "username": conn.login,
    "password": conn.password,
    "port": conn.port or 445,
    "connection_cache": connection_cache,
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions