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

Wrong type of mutual_authentication in Kerberos/GSSAPI authentication #513

Open
1 task done
e1senh0rn opened this issue Jan 8, 2025 · 2 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@e1senh0rn
Copy link

e1senh0rn commented Jan 8, 2025

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!
@hashhar hashhar added the bug Something isn't working label Jan 10, 2025
@hashhar
Copy link
Member

hashhar commented Jan 10, 2025

Thanks for reporting. Since you have the ability to test are you interested in submitting a PR?

@e1senh0rn
Copy link
Author

Will do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants