简体   繁体   中英

How can I get a Kerberos ticket in Python

Is there a way to create a Kerberos ticket in Python if you know the username/password?

I have MIT Kerberos in place and I can do this interactively through KINIT but want to do it from Python.

From what i learned when working with kerberos (although in my work i used C) is that you can hardly replace KINIT. There are two ways you can simulate KINIT behaviour using programming and those are: Calling kinit shell command from python with the appropriate arguments or (as I did) calling one method that pretty much does everything:

krb5_get_init_creds_password(k5ctx, &cred, k5princ, password, NULL, NULL, 0, NULL, NULL);

So this is a C primitive but you should find one for python(i assume) that will do the same. Basically this method will receive the kerberos session, a principal(built from the username) and the password. In order to fully replace KINIT behaviour you do need a bit more than this though(start session, build principal, etc). Sorry, since i did not work with python my answer may not be what you want but i hope i shed you some light. Feel free to ask any conceptual question about how kerberized-applications work.

You are obviously looking for this but I guess the Python binding is overaged. I would recommend to create a SWIG-based binding just for a few functions by yourself. That should solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM