MariaDB Auth_gssapi_client Plugin Pymysql Support

Published
Length
3 min read

Luis Felipe Dias

All posts

To enable mariadb auth_gssapi_client plugin pymysql support, pair PyMySQL with a Python GSSAPI library. This setup lets Python apps log in to MariaDB using Kerberos tickets or Windows logins. Teams often map a whole directory group to one broad database role. When that role has wide permissions, any user or script can alter production tables. How mariadb auth_gssapi_client plugin pymysql support works MariaDB uses a server plugin to check Kerberos tickets during the login handshake. On the cl

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

To enable mariadb auth_gssapi_client plugin pymysql support, pair PyMySQL with a Python GSSAPI library. This setup lets Python apps log in to MariaDB using Kerberos tickets or Windows logins. Teams often map a whole directory group to one broad database role. When that role has wide permissions, any user or script can alter production tables.

How mariadb auth_gssapi_client plugin pymysql support works

MariaDB uses a server plugin to check Kerberos tickets during the login handshake. On the client side, the database driver must know how to respond. Standard PyMySQL handles password logins out of the box. For GSSAPI, it relies on helper libraries that read local Kerberos tickets.

First, the user or host gets a valid ticket from the key server. Next, the Python app starts a session with the MariaDB host. The server replies and asks for a GSSAPI token from the client. PyMySQL passes this request to the local GSSAPI module on the machine.

That module builds a signed token and sends it back over the wire. MariaDB checks the token against its own key file to confirm identity. If the principal name matches a database user, the login succeeds right away. No plain text password travels across the network during this process.

On Windows hosts, this flow can use native system credentials instead of Kerberos files. On Linux hosts, the app reads the ticket cache stored in memory or on disk. Both paths end with a standard database session mapped to a local MariaDB account.

What native GSSAPI login solves and what it misses

Using Kerberos with MariaDB and Python solves several big password problems. Teams do not need to store static database passwords in app files. When someone leaves the company, revoking their central directory account stops database logins too. Key servers also handle ticket renewal without human help.

Still, this login check only runs at the start of a session. Once MariaDB accepts the ticket, the user gets every right tied to that database role. The plugin does not watch what queries the Python script sends next. A single bad script can still drop a table or dump every row.

Customer Support Access to Production + Network Location-Based Auth: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Shared service principals make this problem much worse for audit teams. Many apps log in with one shared ticket and run thousands of queries. Database logs only show the shared principal name, not the person who triggered the job. Teams also lack a way to rewrite sensitive fields like emails or card numbers in results.

Why directory roles leave data exposed in flight

Central directory groups work well for broad app logins, not fine query control. Admins rarely build a custom MariaDB role for every single task or bug fix. Instead, developers get a general read or write role for the whole schema. That role stays active for the full life of the Kerberos ticket.

When an engineer runs a debug script with PyMySQL, every query runs at full speed. Nothing pauses a risky delete statement to ask a peer for approval. Nothing rewrites phone numbers or national IDs before rows reach the local laptop. Stopping bad queries requires controls that inspect database traffic after login completes.

Add wire guardrails and masking beside MySQL

Database grants and TLS setup decide who can reach MySQL. Even so, an open session can run broad updates or read raw personal data from allowed tables. In practice, hoop.dev runs beside the database as a sidecar for your MySQL. It keeps your login setup and drivers as they are while checking queries on the wire.

With hoop.dev MySQL support, guardrails refuse bad queries before they run and return a readable MySQL error. Data masking rewrites matched sensitive values in result rows in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for GDPR, HIPAA, and PCI DSS programs. Read the docs and source on GitHub.

Frequently asked questions

Does PyMySQL support MariaDB GSSAPI logins on its own?

PyMySQL needs an extra Python GSSAPI package installed on the client machine. This package handles the Kerberos token exchange during the initial MariaDB handshake.

Can Linux and Windows clients both use this login method?

Yes, Linux clients use standard Kerberos ticket caches to prove identity to MariaDB. Windows clients can use Active Directory tickets through native system interfaces.

Does GSSAPI encrypt the queries sent after login?

No, the GSSAPI plugin only checks identity during the initial login handshake. You must turn on TLS in MariaDB and PyMySQL to encrypt query traffic.

The query runs. The emails stay hidden.