Skip to content

Wrong type of mutual_authentication in Kerberos/GSSAPI authentication #513

@e1senh0rn

Description

@e1senh0rn

Expected behavior

In trino.auth.KerberosAuthentication class constructor, argument mutual_authentication is defined as bool.

I expect trino.auth.KerberosAuthentication to allow optional mutual authentication setting.
Same also applies to GSSAPIAuthentication.

Type checker used: pyright 1.1.382.

Actual behavior

Internally the value of mutual_authentication argument is passed to requests_kerberos.HTTPKerberosAuth, which expects it to be an instance of int (REQUIRED = 1, OPTIONAL = 2, DISABLED = 3).

This causes two issues:

  • inability to use optional mutual authentication (if boolean value is passed)
  • type checker errors (if numeric value is passed)

Steps To Reproduce

# pip install trino requests_kerberos
from trino.auth import KerberosAuthentication
from requests_kerberos import OPTIONAL

KerberosAuthentication(
    principal="[email protected]",
    mutual_authentication=OPTIONAL,
    service_name="HTTP",
)

Log output

kerberos_test.py:7:27 - error: Argument of type "Literal[2]" cannot be assigned to parameter "mutual_authentication" of type "bool" in function "__init__"
    "Literal[2]" is not assignable to "bool" (reportArgumentType)

Operating System

macOS 15.2

Trino Python client version

0.330.0

Trino Server version

N/A

Python version

3.12.7

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions