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

Fix typing of kerberos mutual_authentication #542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

e1senh0rn
Copy link

Description

Fix #513 by correcting mutual_authentication type annotation and adding corresponding mutual authentication modes constants.

  • Introduce constants for Kerberos and GSSAPI mutual authentication modes within KerberosAuthentication and GSSAPIAuthentication classes.
  • Set proper type annotations and default values for mutual_authentication attributes.
    • Default values are replicated from corresponding defaults in requests_kerberos/requests_gssapi.

Non-technical explanation

Kerberos/GSSAPI libraries (requests_kerberos and requests_gssapi) expect mutual_authentication parameter to be an integer:

  • 1 for "required"
  • 2 for "optional"
  • 3 for "disabled"

However, the same parameter in trino-python-client is annotated as bool. By luck, due to the order of conditions and the fact that True == 1, Kerberos/GSSAPI libraries handle True/False as "required"/"disabled" modes.

This is non-breaking change, but it can streamline the usage of KerberosAuthentication a bit:

### before
from requests_kerberos import OPTIONAL
from trino.auth import KerberosAuthentication

auth = KerberosAuthentication(
    principal="username",
    mutual_authentication=OPTIONAL,  # type: ignore
    service_name="HTTP",
)

### after
from trino.auth import KerberosAuthentication

auth = KerberosAuthentication(
    principal="username",
    mutual_authentication=KerberosAuthentication.OPTIONAL,
    service_name="HTTP",
)

Release notes

( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text:

* Fix type annotation for `mutual_authentication` parameter in Kerberos/GSSAPI authentication ({issue}`513`).

Copy link

cla-bot bot commented Mar 19, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@e1senh0rn
Copy link
Author

Submitted signed CLA.

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

Successfully merging this pull request may close these issues.

Wrong type of mutual_authentication in Kerberos/GSSAPI authentication
1 participant